{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 500, "height": 200, "style": "cell", "data": [ {"name": "selection1_store"}, { "name": "movies", "url": "https://raw.githubusercontent.com/vega/vega-datasets/next/data/movies.json", "format": {"type": "json"}, "transform": [ { "type": "extent", "field": "IMDB Rating", "signal": "__drilldown_dataset1_bin_maxbins_40_IMDB_Rating_extent" }, { "type": "bin", "field": "IMDB Rating", "as": ["__bin_field_name", "__bin_field_name_end"], "signal": "__drilldown_dataset1_bin_maxbins_40_IMDB_Rating_bins", "extent": { "signal": "__drilldown_dataset1_bin_maxbins_40_IMDB_Rating_extent" }, "maxbins": 40 }, { "type": "extent", "field": "IMDB Rating", "signal": "layer_0_layer_1_bin_maxbins_20_IMDB_Rating_extent" }, { "type": "bin", "field": "IMDB Rating", "as": ["__bin_field_name", "__bin_field_name_end"], "signal": "layer_0_layer_1_bin_maxbins_20_IMDB_Rating_bins", "extent": { "signal": "layer_0_layer_1_bin_maxbins_20_IMDB_Rating_extent" }, "maxbins": 20 } ] }, { "name": "data_0", "source": "movies", "transform": [ { "type": "filter", "expr": "!isValid(selection1[\"__bin_field_name\"]) || (datum['__bin_field_name_end'] >= selection1['__bin_field_name'][0] && selection1['__bin_field_name'][1] >= datum['__bin_field_name'])" } ] }, { "name": "data_1", "source": "movies", "transform": [ { "type": "aggregate", "groupby": ["__bin_field_name", "__bin_field_name_end"], "ops": ["count"], "fields": [null], "as": ["__count"] } ] }, { "name": "data_2", "source": "data_1", "transform": [ { "type": "filter", "expr": "!isValid(selection1[\"__bin_field_name\"]) || (datum['__bin_field_name_end'] >= selection1['__bin_field_name'][0] && selection1['__bin_field_name'][1] >= datum['__bin_field_name'])" }, { "type": "filter", "expr": "isValid(datum[\"__bin_field_name\"]) && isFinite(+datum[\"__bin_field_name\"]) && isValid(datum[\"__count\"]) && isFinite(+datum[\"__count\"])" } ] }, { "name": "data_3", "source": "data_1", "transform": [ { "type": "filter", "expr": "isValid(datum[\"__bin_field_name\"]) && isFinite(+datum[\"__bin_field_name\"]) && isValid(datum[\"__count\"]) && isFinite(+datum[\"__count\"])" } ] } ], "signals": [ { "name": "unit", "value": {}, "on": [ {"events": "mousemove", "update": "isTuple(group()) ? group() : unit"} ] }, { "name": "selection1", "update": "vlSelectionResolve(\"selection1_store\", \"union\")" }, { "name": "selection1_x", "value": [], "on": [ { "events": {"source": "scope", "type": "mousedown"}, "update": "[x(unit), x(unit)]" }, { "events": { "source": "window", "type": "mousemove", "consume": true, "between": [ {"source": "scope", "type": "mousedown"}, {"source": "window", "type": "mouseup"} ] }, "update": "[selection1_x[0], clamp(x(unit), 0, width)]" }, { "events": {"signal": "selection1_scale_trigger"}, "update": "[scale(\"x\", selection1___bin_field_name[0]), scale(\"x\", selection1___bin_field_name[1])]" }, {"events": [{"source": "view", "type": "dblclick"}], "update": "[0, 0]"} ] }, { "name": "selection1___bin_field_name", "on": [ { "events": {"signal": "selection1_x"}, "update": "selection1_x[0] === selection1_x[1] ? null : invert(\"x\", selection1_x)" } ] }, { "name": "selection1_scale_trigger", "value": {}, "on": [ { "events": [{"scale": "x"}], "update": "(!isArray(selection1___bin_field_name) || (+invert(\"x\", selection1_x)[0] === +selection1___bin_field_name[0] && +invert(\"x\", selection1_x)[1] === +selection1___bin_field_name[1])) ? selection1_scale_trigger : {}" } ] }, { "name": "selection1_tuple", "on": [ { "events": [{"signal": "selection1___bin_field_name"}], "update": "selection1___bin_field_name ? {unit: \"layer_0_layer_0\", fields: selection1_tuple_fields, values: [selection1___bin_field_name]} : null" } ] }, { "name": "selection1_tuple_fields", "value": [{"field": "__bin_field_name", "channel": "x", "type": "R"}] }, { "name": "selection1_modify", "on": [ { "events": {"signal": "selection1_tuple"}, "update": "modify(\"selection1_store\", selection1_tuple, true)" } ] } ], "marks": [ { "name": "selection1_brush_bg", "type": "rect", "clip": true, "encode": { "enter": {"fill": {"value": "#333"}, "fillOpacity": {"value": 0.125}}, "update": { "x": [ { "test": "data(\"selection1_store\").length && data(\"selection1_store\")[0].unit === \"layer_0_layer_0\"", "signal": "selection1_x[0]" }, {"value": 0} ], "y": [ { "test": "data(\"selection1_store\").length && data(\"selection1_store\")[0].unit === \"layer_0_layer_0\"", "value": 0 }, {"value": 0} ], "x2": [ { "test": "data(\"selection1_store\").length && data(\"selection1_store\")[0].unit === \"layer_0_layer_0\"", "signal": "selection1_x[1]" }, {"value": 0} ], "y2": [ { "test": "data(\"selection1_store\").length && data(\"selection1_store\")[0].unit === \"layer_0_layer_0\"", "field": {"group": "height"} }, {"value": 0} ] } } }, { "name": "layer_0_layer_0_marks", "type": "rect", "clip": true, "style": ["bar"], "interactive": true, "from": {"data": "data_3"}, "encode": { "update": { "tooltip": { "signal": "{\"IMDB Rating (binned)\": format(datum[\"__bin_field_name\"], \"\"), \"Count of Records\": format(datum[\"__count\"], \"\"), \"__bin_field_name_end\": format(datum[\"__bin_field_name_end\"], \"\")}" }, "fill": {"value": "grey"}, "opacity": {"value": 0.5}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"IMDB Rating (binned): \" + (format(datum[\"__bin_field_name\"], \"\")) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\")) + \"; __bin_field_name_end: \" + (format(datum[\"__bin_field_name_end\"], \"\"))" }, "x": {"scale": "x", "field": "__bin_field_name"}, "x2": {"scale": "x", "field": "__bin_field_name_end"}, "y": {"scale": "y", "field": "__count"}, "y2": {"scale": "y", "value": 0} } } }, { "name": "layer_0_layer_1_marks", "type": "rect", "clip": true, "style": ["bar"], "interactive": false, "from": {"data": "data_2"}, "encode": { "update": { "tooltip": { "signal": "{\"IMDB Rating (binned)\": format(datum[\"__bin_field_name\"], \"\"), \"Count of Records\": format(datum[\"__count\"], \"\"), \"__bin_field_name_end\": format(datum[\"__bin_field_name_end\"], \"\")}" }, "fill": {"value": "#4c78a8"}, "opacity": {"value": 1}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"IMDB Rating (binned): \" + (format(datum[\"__bin_field_name\"], \"\")) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\")) + \"; __bin_field_name_end: \" + (format(datum[\"__bin_field_name_end\"], \"\"))" }, "x": {"scale": "x", "field": "__bin_field_name"}, "x2": {"scale": "x", "field": "__bin_field_name_end"}, "y": {"scale": "y", "field": "__count"}, "y2": {"scale": "y", "value": 0} } } }, { "name": "__drilldown_dataset1_marks", "type": "symbol", "style": ["point"], "interactive": false, "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0}, "fill": {"value": "transparent"}, "stroke": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "point"}, "x": {"signal": "width", "mult": 0.5}, "y": {"signal": "height", "mult": 0.5} } } }, { "name": "selection1_brush", "type": "rect", "clip": true, "encode": { "enter": {"fill": {"value": "transparent"}}, "update": { "x": [ { "test": "data(\"selection1_store\").length && data(\"selection1_store\")[0].unit === \"layer_0_layer_0\"", "signal": "selection1_x[0]" }, {"value": 0} ], "y": [ { "test": "data(\"selection1_store\").length && data(\"selection1_store\")[0].unit === \"layer_0_layer_0\"", "value": 0 }, {"value": 0} ], "x2": [ { "test": "data(\"selection1_store\").length && data(\"selection1_store\")[0].unit === \"layer_0_layer_0\"", "signal": "selection1_x[1]" }, {"value": 0} ], "y2": [ { "test": "data(\"selection1_store\").length && data(\"selection1_store\")[0].unit === \"layer_0_layer_0\"", "field": {"group": "height"} }, {"value": 0} ], "stroke": [ {"test": "selection1_x[0] !== selection1_x[1]", "value": "white"}, {"value": null} ] } } } ], "scales": [ { "name": "x", "type": "linear", "domain": { "fields": [ {"data": "data_3", "field": "__bin_field_name"}, {"data": "data_3", "field": "__bin_field_name_end"}, {"data": "data_2", "field": "__bin_field_name"}, {"data": "data_2", "field": "__bin_field_name_end"} ] }, "range": [0, {"signal": "width"}], "nice": true, "zero": false, "padding": 5 }, { "name": "y", "type": "linear", "domain": { "fields": [ {"data": "data_3", "field": "__count"}, {"data": "data_2", "field": "__count"} ] }, "range": [{"signal": "height"}, 0], "nice": true, "zero": true } ], "axes": [ { "scale": "x", "orient": "bottom", "grid": true, "tickCount": 40, "gridScale": "y", "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": true, "gridScale": "x", "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)", "labels": true, "tickCount": 40, "ticks": true, "labelFlush": true, "labelOverlap": true, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Count of Records", "labels": true, "ticks": true, "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ], "config": {"legend": {"orient": "right"}}, "usermeta": { "selectionConfigs": { "selection1": {"type": "interval", "datetimeFields": []} } } }