{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "Drag out a rectangular brush to highlight points.", "background": "white", "padding": 5, "height": 200, "data": [ {"name": "hover_store"}, { "name": "source_0", "url": "data/cars.json", "format": {"type": "json"}, "transform": [{"type": "identifier", "as": "_vgsid_"}] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"Horsepower\"]) && isFinite(+datum[\"Horsepower\"]) && isValid(datum[\"Miles_per_Gallon\"]) && isFinite(+datum[\"Miles_per_Gallon\"])" } ] }, { "name": "data_1", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"Horsepower\"]) && isFinite(+datum[\"Horsepower\"]) && isValid(datum[\"Acceleration\"]) && isFinite(+datum[\"Acceleration\"])" } ] } ], "signals": [ {"name": "childWidth", "value": 200}, { "name": "unit", "value": {}, "on": [ {"events": "mousemove", "update": "isTuple(group()) ? group() : unit"} ] }, { "name": "hover", "update": "vlSelectionResolve(\"hover_store\", \"union\", true, true)" } ], "layout": {"padding": 20, "bounds": "full", "align": "each"}, "marks": [ { "type": "group", "name": "concat_0_group", "style": "cell", "encode": { "update": { "width": {"signal": "childWidth"}, "height": {"signal": "height"} } }, "signals": [ { "name": "hover_tuple", "on": [ { "events": [{"source": "scope", "type": "mouseover"}], "update": "datum && item().mark.marktype !== 'group' ? {unit: \"concat_0\", fields: hover_tuple_fields, values: [(item().isVoronoi ? datum.datum : datum)[\"_vgsid_\"]]} : null", "force": true }, { "events": [{"source": "view", "type": "dblclick"}], "update": "null" } ] }, { "name": "hover_tuple_fields", "value": [{"type": "E", "field": "_vgsid_"}] }, { "name": "hover_toggle", "value": false, "on": [ { "events": [{"source": "scope", "type": "mouseover"}], "update": "event.shiftKey" }, { "events": [{"source": "view", "type": "dblclick"}], "update": "false" } ] }, { "name": "hover_modify", "on": [ { "events": {"signal": "hover_tuple"}, "update": "modify(\"hover_store\", hover_toggle ? null : hover_tuple, hover_toggle ? null : true, hover_toggle ? hover_tuple : null)" } ] } ], "marks": [ { "name": "concat_0_marks", "type": "symbol", "style": ["point"], "interactive": true, "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "transparent"}, "stroke": [ { "test": "length(data(\"hover_store\")) && vlSelectionTest(\"hover_store\", datum)", "scale": "color", "field": "Cylinders" }, {"value": "grey"} ], "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Miles_per_Gallon: \" + (format(datum[\"Miles_per_Gallon\"], \"\")) + \"; Cylinders: \" + (isValid(datum[\"Cylinders\"]) ? datum[\"Cylinders\"] : \"\"+datum[\"Cylinders\"])" }, "x": {"scale": "concat_0_x", "field": "Horsepower"}, "y": {"scale": "concat_0_y", "field": "Miles_per_Gallon"} } } } ], "axes": [ { "scale": "concat_0_x", "orient": "bottom", "gridScale": "concat_0_y", "grid": true, "tickCount": {"signal": "ceil(childWidth/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "concat_0_y", "orient": "left", "gridScale": "concat_0_x", "grid": true, "tickCount": {"signal": "ceil(height/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "concat_0_x", "orient": "bottom", "grid": false, "title": "Horsepower", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(childWidth/40)"}, "zindex": 0 }, { "scale": "concat_0_y", "orient": "left", "grid": false, "title": "Miles_per_Gallon", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ] }, { "type": "group", "name": "concat_1_group", "style": "cell", "encode": { "update": { "width": {"signal": "childWidth"}, "height": {"signal": "height"} } }, "signals": [ { "name": "hover_tuple", "on": [ { "events": [{"source": "scope", "type": "mouseover"}], "update": "datum && item().mark.marktype !== 'group' ? {unit: \"concat_1\", fields: hover_tuple_fields, values: [(item().isVoronoi ? datum.datum : datum)[\"_vgsid_\"]]} : null", "force": true }, { "events": [{"source": "view", "type": "dblclick"}], "update": "null" } ] }, { "name": "hover_tuple_fields", "value": [{"type": "E", "field": "_vgsid_"}] }, { "name": "hover_toggle", "value": false, "on": [ { "events": [{"source": "scope", "type": "mouseover"}], "update": "event.shiftKey" }, { "events": [{"source": "view", "type": "dblclick"}], "update": "false" } ] }, { "name": "hover_modify", "on": [ { "events": {"signal": "hover_tuple"}, "update": "modify(\"hover_store\", hover_toggle ? null : hover_tuple, hover_toggle ? null : true, hover_toggle ? hover_tuple : null)" } ] } ], "marks": [ { "name": "concat_1_marks", "type": "symbol", "style": ["point"], "interactive": true, "from": {"data": "data_1"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "transparent"}, "stroke": [ { "test": "length(data(\"hover_store\")) && vlSelectionTest(\"hover_store\", datum)", "scale": "color", "field": "Cylinders" }, {"value": "grey"} ], "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Acceleration: \" + (format(datum[\"Acceleration\"], \"\")) + \"; Cylinders: \" + (isValid(datum[\"Cylinders\"]) ? datum[\"Cylinders\"] : \"\"+datum[\"Cylinders\"])" }, "x": {"scale": "concat_1_x", "field": "Horsepower"}, "y": {"scale": "concat_1_y", "field": "Acceleration"} } } } ], "axes": [ { "scale": "concat_1_x", "orient": "bottom", "gridScale": "concat_1_y", "grid": true, "tickCount": {"signal": "ceil(childWidth/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "concat_1_y", "orient": "left", "gridScale": "concat_1_x", "grid": true, "tickCount": {"signal": "ceil(height/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "concat_1_x", "orient": "bottom", "grid": false, "title": "Horsepower", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(childWidth/40)"}, "zindex": 0 }, { "scale": "concat_1_y", "orient": "left", "grid": false, "title": "Acceleration", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ] } ], "scales": [ { "name": "color", "type": "ordinal", "domain": { "fields": [ {"data": "data_0", "field": "Cylinders"}, {"data": "data_1", "field": "Cylinders"} ], "sort": true }, "range": "ordinal", "interpolate": "hcl" }, { "name": "concat_0_x", "type": "linear", "domain": {"data": "data_0", "field": "Horsepower"}, "range": [0, {"signal": "childWidth"}], "nice": true, "zero": true }, { "name": "concat_0_y", "type": "linear", "domain": {"data": "data_0", "field": "Miles_per_Gallon"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true }, { "name": "concat_1_x", "type": "linear", "domain": {"data": "data_1", "field": "Horsepower"}, "range": [0, {"signal": "childWidth"}], "nice": true, "zero": true }, { "name": "concat_1_y", "type": "linear", "domain": {"data": "data_1", "field": "Acceleration"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true } ], "legends": [ { "stroke": "color", "symbolType": "circle", "title": "Cylinders", "encode": { "symbols": { "update": { "fill": {"value": "transparent"}, "opacity": {"value": 0.7} } } } } ] }