{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "data": [ {"name": "region_store"}, {"name": "source_0", "url": "data/cars.json", "format": {"type": "json"}}, { "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": "childHeight", "value": 200}, { "name": "unit", "value": {}, "on": [ {"events": "mousemove", "update": "isTuple(group()) ? group() : unit"} ] }, { "name": "region", "update": "{\"Horsepower\": region_Horsepower, \"Miles_per_Gallon\": region_Miles_per_Gallon}" }, {"name": "region_Horsepower"}, {"name": "region_Miles_per_Gallon"} ], "layout": {"padding": 20, "columns": 1, "bounds": "full", "align": "each"}, "marks": [ { "type": "group", "name": "concat_0_group", "style": "cell", "encode": { "update": { "width": {"signal": "width"}, "height": {"signal": "childHeight"} } }, "signals": [ { "name": "region_Horsepower", "on": [ { "events": [{"source": "view", "type": "dblclick"}], "update": "null" }, { "events": {"signal": "region_translate_delta"}, "update": "panLinear(region_translate_anchor.extent_x, -region_translate_delta.x / width)" }, { "events": {"signal": "region_zoom_delta"}, "update": "zoomLinear(domain(\"x\"), region_zoom_anchor.x, region_zoom_delta)" } ], "push": "outer" }, { "name": "region_Miles_per_Gallon", "on": [ { "events": [{"source": "view", "type": "dblclick"}], "update": "null" }, { "events": {"signal": "region_translate_delta"}, "update": "panLinear(region_translate_anchor.extent_y, region_translate_delta.y / childHeight)" }, { "events": {"signal": "region_zoom_delta"}, "update": "zoomLinear(domain(\"concat_0_y\"), region_zoom_anchor.y, region_zoom_delta)" } ], "push": "outer" }, { "name": "region_tuple", "on": [ { "events": [ {"signal": "region_Horsepower || region_Miles_per_Gallon"} ], "update": "region_Horsepower && region_Miles_per_Gallon ? {unit: \"concat_0\", fields: region_tuple_fields, values: [region_Horsepower,region_Miles_per_Gallon]} : null" } ] }, { "name": "region_tuple_fields", "value": [ {"field": "Horsepower", "channel": "x", "type": "R"}, {"field": "Miles_per_Gallon", "channel": "y", "type": "R"} ] }, { "name": "region_translate_anchor", "value": {}, "on": [ { "events": [{"source": "scope", "type": "mousedown"}], "update": "{x: x(unit), y: y(unit), extent_x: domain(\"x\"), extent_y: domain(\"concat_0_y\")}" } ] }, { "name": "region_translate_delta", "value": {}, "on": [ { "events": [ { "source": "window", "type": "mousemove", "consume": true, "between": [ {"source": "scope", "type": "mousedown"}, {"source": "window", "type": "mouseup"} ] } ], "update": "{x: region_translate_anchor.x - x(unit), y: region_translate_anchor.y - y(unit)}" } ] }, { "name": "region_zoom_anchor", "on": [ { "events": [{"source": "scope", "type": "wheel", "consume": true}], "update": "{x: invert(\"x\", x(unit)), y: invert(\"concat_0_y\", y(unit))}" } ] }, { "name": "region_zoom_delta", "on": [ { "events": [{"source": "scope", "type": "wheel", "consume": true}], "force": true, "update": "pow(1.001, event.deltaY * pow(16, event.deltaMode))" } ] }, { "name": "region_modify", "on": [ { "events": {"signal": "region_tuple"}, "update": "modify(\"region_store\", region_tuple, true)" } ] } ], "marks": [ { "name": "concat_0_marks", "type": "symbol", "clip": true, "style": ["point"], "interactive": true, "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "transparent"}, "stroke": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Miles_per_Gallon: \" + (format(datum[\"Miles_per_Gallon\"], \"\"))" }, "x": {"scale": "x", "field": "Horsepower"}, "y": {"scale": "concat_0_y", "field": "Miles_per_Gallon"} } } } ], "axes": [ { "scale": "x", "orient": "bottom", "gridScale": "concat_0_y", "grid": true, "tickCount": {"signal": "ceil(width/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "concat_0_y", "orient": "left", "gridScale": "x", "grid": true, "tickCount": {"signal": "ceil(childHeight/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "x", "orient": "bottom", "grid": false, "title": "Horsepower", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "concat_0_y", "orient": "left", "grid": false, "title": "Miles_per_Gallon", "labelOverlap": true, "tickCount": {"signal": "ceil(childHeight/40)"}, "zindex": 0 } ] }, { "type": "group", "name": "concat_1_group", "style": "cell", "encode": { "update": { "width": {"signal": "width"}, "height": {"signal": "childHeight"} } }, "marks": [ { "name": "concat_1_marks", "type": "symbol", "clip": true, "style": ["point"], "interactive": false, "from": {"data": "data_1"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "transparent"}, "stroke": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Acceleration: \" + (format(datum[\"Acceleration\"], \"\"))" }, "x": {"scale": "x", "field": "Horsepower"}, "y": {"scale": "concat_1_y", "field": "Acceleration"} } } } ], "axes": [ { "scale": "x", "orient": "bottom", "gridScale": "concat_1_y", "grid": true, "tickCount": {"signal": "ceil(width/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "concat_1_y", "orient": "left", "gridScale": "x", "grid": true, "tickCount": {"signal": "ceil(childHeight/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "x", "orient": "bottom", "grid": false, "title": "Horsepower", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "concat_1_y", "orient": "left", "grid": false, "title": "Acceleration", "labelOverlap": true, "tickCount": {"signal": "ceil(childHeight/40)"}, "zindex": 0 } ] } ], "scales": [ { "name": "x", "type": "linear", "domain": { "fields": [ {"data": "data_0", "field": "Horsepower"}, {"data": "data_1", "field": "Horsepower"} ] }, "domainRaw": {"signal": "region[\"Horsepower\"]"}, "range": [0, {"signal": "width"}], "nice": true, "zero": true }, { "name": "concat_0_y", "type": "linear", "domain": {"data": "data_0", "field": "Miles_per_Gallon"}, "domainRaw": {"signal": "region[\"Miles_per_Gallon\"]"}, "range": [{"signal": "childHeight"}, 0], "nice": true, "zero": true }, { "name": "concat_1_y", "type": "linear", "domain": {"data": "data_1", "field": "Acceleration"}, "range": [{"signal": "childHeight"}, 0], "nice": true, "zero": true } ] }