{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "height": 200, "style": "cell", "data": [ { "name": "source_0", "url": "data/movies.json", "format": {"type": "json", "parse": {"IMDB Rating": "number"}}, "transform": [ { "type": "extent", "field": "IMDB Rating", "signal": "child__layer_Worldwide_Gross_bin_maxbins_10_IMDB_Rating_extent" }, { "type": "bin", "field": "IMDB Rating", "as": [ "bin_maxbins_10_IMDB Rating", "bin_maxbins_10_IMDB Rating_end" ], "signal": "child__layer_Worldwide_Gross_bin_maxbins_10_IMDB_Rating_bins", "extent": { "signal": "child__layer_Worldwide_Gross_bin_maxbins_10_IMDB_Rating_extent" }, "maxbins": 10 }, { "type": "aggregate", "groupby": [ "bin_maxbins_10_IMDB Rating", "bin_maxbins_10_IMDB Rating_end" ], "ops": ["mean", "mean"], "fields": ["US Gross", "Worldwide Gross"], "as": ["mean_US Gross", "mean_Worldwide Gross"] } ] } ], "marks": [ { "name": "child__layer_US_Gross_marks", "type": "line", "style": ["line"], "sort": {"field": "datum[\"bin_maxbins_10_IMDB Rating\"]"}, "from": {"data": "source_0"}, "encode": { "update": { "stroke": {"scale": "color", "value": "US Gross"}, "description": { "signal": "\"IMDB Rating (binned): \" + (!isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"null\" : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\")) + \"; Mean of US and Worldwide Gross: \" + (format(datum[\"mean_US Gross\"], \"\"))" }, "x": { "signal": "scale(\"x\", 0.5 * datum[\"bin_maxbins_10_IMDB Rating\"] + 0.5 * datum[\"bin_maxbins_10_IMDB Rating_end\"])" }, "y": {"scale": "y", "field": "mean_US Gross"}, "defined": { "signal": "isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) && isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) && isValid(datum[\"mean_US Gross\"]) && isFinite(+datum[\"mean_US Gross\"])" } } } }, { "name": "child__layer_Worldwide_Gross_marks", "type": "line", "style": ["line"], "sort": {"field": "datum[\"bin_maxbins_10_IMDB Rating\"]"}, "from": {"data": "source_0"}, "encode": { "update": { "stroke": {"scale": "color", "value": "Worldwide Gross"}, "description": { "signal": "\"IMDB Rating (binned): \" + (!isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"null\" : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\")) + \"; Mean of US and Worldwide Gross: \" + (format(datum[\"mean_Worldwide Gross\"], \"\"))" }, "x": { "signal": "scale(\"x\", 0.5 * datum[\"bin_maxbins_10_IMDB Rating\"] + 0.5 * datum[\"bin_maxbins_10_IMDB Rating_end\"])" }, "y": {"scale": "y", "field": "mean_Worldwide Gross"}, "defined": { "signal": "isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) && isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) && isValid(datum[\"mean_Worldwide Gross\"]) && isFinite(+datum[\"mean_Worldwide Gross\"])" } } } } ], "scales": [ { "name": "x", "type": "linear", "domain": { "signal": "[child__layer_Worldwide_Gross_bin_maxbins_10_IMDB_Rating_bins.start, child__layer_Worldwide_Gross_bin_maxbins_10_IMDB_Rating_bins.stop]" }, "range": [0, {"signal": "width"}], "bins": { "signal": "child__layer_Worldwide_Gross_bin_maxbins_10_IMDB_Rating_bins" }, "zero": false }, { "name": "y", "type": "linear", "domain": { "data": "source_0", "fields": ["mean_US Gross", "mean_Worldwide Gross"] }, "range": [{"signal": "height"}, 0], "nice": true, "zero": true }, { "name": "color", "type": "ordinal", "domain": {"fields": [["US Gross"], ["Worldwide Gross"]]}, "range": "category" } ], "axes": [ { "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 (binned)", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/10)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Mean of US and Worldwide Gross", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ], "legends": [{"stroke": "color", "symbolType": "stroke"}] }