{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "style": "cell", "data": [ { "name": "source_0", "url": "https://raw.githubusercontent.com/vega/vega-datasets/master/data/movies.json", "format": {"type": "json"}, "transform": [ { "type": "aggregate", "groupby": ["Major Genre"], "ops": ["count", "mean"], "fields": [null, "IMDB Rating"], "as": ["__count", "mean_IMDB Rating"] }, { "type": "filter", "expr": "datum[\"Major Genre\"] !== null" } ] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"mean_IMDB Rating\"]) && isFinite(+datum[\"mean_IMDB Rating\"])" } ] } ], "signals": [ {"name": "y_step", "value": 16}, { "name": "height", "update": "bandspace(domain('y').length, 0.1, 0.05) * y_step" } ], "marks": [ { "name": "layer_0_marks", "type": "rect", "style": ["bar"], "from": {"data": "data_0"}, "encode": { "update": { "fill": {"value": "#ddd"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"Major Genre: \" + (isValid(datum[\"Major Genre\"]) ? datum[\"Major Genre\"] : \"\"+datum[\"Major Genre\"]) + \"; Mean IMDB Ratings: \" + (format(datum[\"mean_IMDB Rating\"], \"\"))" }, "x": {"scale": "x", "field": "mean_IMDB Rating"}, "x2": {"scale": "x", "value": 0}, "y": {"scale": "y", "field": "Major Genre"}, "height": {"scale": "y", "band": 1} } } }, { "name": "layer_1_marks", "type": "text", "style": ["text"], "from": {"data": "source_0"}, "encode": { "update": { "align": {"value": "left"}, "fill": {"value": "black"}, "description": { "signal": "\"Major Genre: \" + (isValid(datum[\"Major Genre\"]) ? datum[\"Major Genre\"] : \"\"+datum[\"Major Genre\"]) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\"))" }, "x": {"value": 5}, "y": {"scale": "y", "field": "Major Genre", "band": 0.5}, "text": { "signal": "isValid(datum[\"Major Genre\"]) ? datum[\"Major Genre\"] : \"\"+datum[\"Major Genre\"]" }, "baseline": {"value": "middle"} } } } ], "scales": [ { "name": "x", "type": "linear", "domain": [0, 10], "range": [0, {"signal": "width"}], "zero": true }, { "name": "y", "type": "band", "domain": { "fields": [ {"data": "data_0", "field": "Major Genre"}, {"data": "source_0", "field": "Major Genre"} ], "sort": true }, "range": {"step": {"signal": "y_step"}}, "paddingInner": 0.1, "paddingOuter": 0.05 } ], "axes": [ { "scale": "x", "orient": "bottom", "gridScale": "y", "grid": true, "tickCount": {"signal": "ceil(width/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "x", "orient": "bottom", "grid": false, "title": "Mean IMDB Ratings", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 } ] }