{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "height": 200, "style": "cell", "description": "https://vega.github.io/vega-lite/examples/layer_cumulative_histogram.html", "data": [ { "name": "source_0", "url": "https://raw.githubusercontent.com/vega/vega-datasets/master/data/movies.json", "format": {"type": "json"}, "transform": [ { "type": "extent", "field": "IMDB Rating", "signal": "bin_maxbins_10_IMDB_Rating_extent" }, { "type": "bin", "field": "IMDB Rating", "as": ["bin_IMDB_Rating", "bin_IMDB_Rating_end"], "signal": "bin_maxbins_10_IMDB_Rating_bins", "extent": {"signal": "bin_maxbins_10_IMDB_Rating_extent"}, "maxbins": 10 }, { "type": "aggregate", "groupby": ["bin_IMDB_Rating", "bin_IMDB_Rating_end"], "ops": ["count"], "fields": [null], "as": ["count"] }, {"type": "filter", "expr": "datum.bin_IMDB_Rating !== null"}, { "type": "window", "params": [null], "as": ["Cumulative Count"], "ops": ["sum"], "fields": ["count"], "sort": {"field": ["bin_IMDB_Rating"], "order": ["ascending"]}, "frame": [null, 0] } ] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"bin_IMDB_Rating\"]) && isFinite(+datum[\"bin_IMDB_Rating\"]) && isValid(datum[\"Cumulative Count\"]) && isFinite(+datum[\"Cumulative Count\"])" } ] }, { "name": "data_1", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"bin_IMDB_Rating\"]) && isFinite(+datum[\"bin_IMDB_Rating\"]) && isValid(datum[\"count\"]) && isFinite(+datum[\"count\"])" } ] } ], "marks": [ { "name": "layer_0_marks", "type": "rect", "style": ["bar"], "from": {"data": "data_0"}, "encode": { "update": { "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"IMDB Rating: \" + (format(datum[\"bin_IMDB_Rating\"], \"\")) + \"; bin_IMDB_Rating_end: \" + (format(datum[\"bin_IMDB_Rating_end\"], \"\")) + \"; Cumulative Count: \" + (format(datum[\"Cumulative Count\"], \"\"))" }, "x": [ { "test": "!isValid(datum[\"bin_IMDB_Rating\"]) || !isFinite(+datum[\"bin_IMDB_Rating\"])", "value": 0 }, {"scale": "x", "field": "bin_IMDB_Rating"} ], "x2": [ { "test": "!isValid(datum[\"bin_IMDB_Rating_end\"]) || !isFinite(+datum[\"bin_IMDB_Rating_end\"])", "value": 0 }, {"scale": "x", "field": "bin_IMDB_Rating_end"} ], "y": {"scale": "y", "field": "Cumulative Count"}, "y2": {"scale": "y", "value": 0} } } }, { "name": "layer_1_marks", "type": "rect", "style": ["bar"], "from": {"data": "data_1"}, "encode": { "update": { "opacity": {"value": 0.5}, "fill": {"value": "yellow"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"IMDB Rating: \" + (format(datum[\"bin_IMDB_Rating\"], \"\")) + \"; bin_IMDB_Rating_end: \" + (format(datum[\"bin_IMDB_Rating_end\"], \"\")) + \"; count: \" + (format(datum[\"count\"], \"\"))" }, "x": [ { "test": "!isValid(datum[\"bin_IMDB_Rating\"]) || !isFinite(+datum[\"bin_IMDB_Rating\"])", "value": 0 }, {"scale": "x", "field": "bin_IMDB_Rating"} ], "x2": [ { "test": "!isValid(datum[\"bin_IMDB_Rating_end\"]) || !isFinite(+datum[\"bin_IMDB_Rating_end\"])", "value": 0 }, {"scale": "x", "field": "bin_IMDB_Rating_end"} ], "y": {"scale": "y", "field": "count"}, "y2": {"scale": "y", "value": 0} } } } ], "scales": [ { "name": "x", "type": "linear", "domain": { "fields": [ {"data": "data_0", "field": "bin_IMDB_Rating"}, {"data": "data_0", "field": "bin_IMDB_Rating_end"}, {"data": "data_1", "field": "bin_IMDB_Rating"}, {"data": "data_1", "field": "bin_IMDB_Rating_end"} ] }, "range": [0, {"signal": "width"}], "zero": false, "nice": true, "padding": 5 }, { "name": "y", "type": "linear", "domain": { "fields": [ {"data": "data_0", "field": "Cumulative Count"}, {"data": "data_1", "field": "count"} ] }, "range": [{"signal": "height"}, 0], "nice": true, "zero": true } ], "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": "y", "orient": "left", "gridScale": "x", "grid": true, "tickCount": {"signal": "ceil(height/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "x", "orient": "bottom", "grid": false, "title": "IMDB Rating", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Cumulative Count, count", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ] }