{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 300, "height": 300, "style": "cell", "data": [ { "name": "source_0", "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/movies.json", "format": {"type": "json"} }, {"name": "empty", "values": [{}]}, { "name": "data_0", "source": "source_0", "transform": [ {"type": "filter", "expr": "(datum['IMDB_Rating'] >= param_5)"}, { "type": "filter", "expr": "isValid(datum[\"IMDB_Rating\"]) && isFinite(+datum[\"IMDB_Rating\"]) && isValid(datum[\"Rotten_Tomatoes_Rating\"]) && isFinite(+datum[\"Rotten_Tomatoes_Rating\"])" } ] }, { "name": "data_1", "source": "source_0", "transform": [ { "type": "extent", "field": "IMDB_Rating", "signal": "layer_1_bin_maxbins_10_IMDB_Rating_extent" }, { "type": "bin", "field": "IMDB_Rating", "as": [ "bin_maxbins_10_IMDB_Rating", "bin_maxbins_10_IMDB_Rating_end" ], "signal": "layer_1_bin_maxbins_10_IMDB_Rating_bins", "extent": {"signal": "layer_1_bin_maxbins_10_IMDB_Rating_extent"}, "maxbins": 10 }, { "type": "extent", "field": "Rotten_Tomatoes_Rating", "signal": "layer_1_bin_maxbins_10_Rotten_Tomatoes_Rating_extent" }, { "type": "bin", "field": "Rotten_Tomatoes_Rating", "as": [ "bin_maxbins_10_Rotten_Tomatoes_Rating", "bin_maxbins_10_Rotten_Tomatoes_Rating_end" ], "signal": "layer_1_bin_maxbins_10_Rotten_Tomatoes_Rating_bins", "extent": { "signal": "layer_1_bin_maxbins_10_Rotten_Tomatoes_Rating_extent" }, "maxbins": 10 }, {"type": "filter", "expr": "(datum['IMDB_Rating'] < param_5)"}, { "type": "aggregate", "groupby": [ "bin_maxbins_10_IMDB_Rating", "bin_maxbins_10_IMDB_Rating_end", "bin_maxbins_10_Rotten_Tomatoes_Rating", "bin_maxbins_10_Rotten_Tomatoes_Rating_end" ], "ops": ["count"], "fields": [null], "as": ["__count"] }, { "type": "filter", "expr": "isValid(datum[\"bin_maxbins_10_IMDB_Rating\"]) && isFinite(+datum[\"bin_maxbins_10_IMDB_Rating\"]) && isValid(datum[\"bin_maxbins_10_Rotten_Tomatoes_Rating\"]) && isFinite(+datum[\"bin_maxbins_10_Rotten_Tomatoes_Rating\"])" } ] } ], "signals": [ { "name": "param_5", "value": 5, "bind": { "input": "range", "max": 10, "min": 0, "name": "threshold", "step": 0.1 } } ], "marks": [ { "name": "layer_0_marks", "type": "symbol", "style": ["circle"], "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "circle"}, "description": { "signal": "\"IMDB Rating: \" + (format(datum[\"IMDB_Rating\"], \"\")) + \"; Rotten Tomatoes Rating: \" + (format(datum[\"Rotten_Tomatoes_Rating\"], \"\"))" }, "x": {"scale": "x", "field": "IMDB_Rating"}, "y": {"scale": "y", "field": "Rotten_Tomatoes_Rating"}, "shape": {"value": "circle"} } } }, { "name": "layer_1_marks", "type": "symbol", "style": ["circle"], "from": {"data": "data_1"}, "encode": { "update": { "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "circle"}, "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\"], \"\")) + \"; Rotten_Tomatoes_Rating (binned): \" + (!isValid(datum[\"bin_maxbins_10_Rotten_Tomatoes_Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_Rotten_Tomatoes_Rating\"]) ? \"null\" : format(datum[\"bin_maxbins_10_Rotten_Tomatoes_Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_Rotten_Tomatoes_Rating_end\"], \"\")) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\"))" }, "x": { "signal": "scale(\"x\", 0.5 * datum[\"bin_maxbins_10_IMDB_Rating\"] + 0.5 * datum[\"bin_maxbins_10_IMDB_Rating_end\"])" }, "y": { "signal": "scale(\"y\", 0.5 * datum[\"bin_maxbins_10_Rotten_Tomatoes_Rating\"] + 0.5 * datum[\"bin_maxbins_10_Rotten_Tomatoes_Rating_end\"])" }, "size": {"scale": "size", "field": "__count"}, "shape": {"value": "circle"} } } }, { "name": "layer_2_marks", "type": "rule", "style": ["rule"], "from": {"data": "empty"}, "encode": { "update": { "stroke": {"value": "gray"}, "strokeWidth": {"value": 6}, "x": {"scale": "x", "signal": "param_5"}, "y": {"value": 0}, "y2": {"field": {"group": "height"}} } } } ], "scales": [ { "name": "x", "type": "linear", "domain": { "fields": [ {"data": "data_0", "field": "IMDB_Rating"}, { "signal": "[layer_1_bin_maxbins_10_IMDB_Rating_bins.start, layer_1_bin_maxbins_10_IMDB_Rating_bins.stop]" }, [{"expr": "param_5"}] ] }, "range": [0, {"signal": "width"}], "bins": {"signal": "layer_1_bin_maxbins_10_IMDB_Rating_bins"}, "nice": true, "zero": true }, { "name": "y", "type": "linear", "domain": { "fields": [ {"data": "data_0", "field": "Rotten_Tomatoes_Rating"}, { "signal": "[layer_1_bin_maxbins_10_Rotten_Tomatoes_Rating_bins.start, layer_1_bin_maxbins_10_Rotten_Tomatoes_Rating_bins.stop]" } ] }, "range": [{"signal": "height"}, 0], "bins": {"signal": "layer_1_bin_maxbins_10_Rotten_Tomatoes_Rating_bins"}, "nice": true, "zero": true }, { "name": "size", "type": "linear", "domain": [0, 160], "range": [ 0, { "signal": "pow(0.95 * min(width / ((layer_1_bin_maxbins_10_IMDB_Rating_bins.stop - layer_1_bin_maxbins_10_IMDB_Rating_bins.start) / layer_1_bin_maxbins_10_IMDB_Rating_bins.step), height / ((layer_1_bin_maxbins_10_Rotten_Tomatoes_Rating_bins.stop - layer_1_bin_maxbins_10_Rotten_Tomatoes_Rating_bins.start) / layer_1_bin_maxbins_10_Rotten_Tomatoes_Rating_bins.step)), 2)" } ], "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": "Rotten Tomatoes Rating", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ], "legends": [ { "size": "size", "symbolType": "circle", "title": "Count of Records", "encode": { "symbols": { "update": { "fill": {"value": "#4c78a8"}, "stroke": {"value": "transparent"} } } } } ] }