{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "style": "cell", "data": [ {"name": "pts_store"}, { "name": "source_0", "url": "data/cars.json", "format": {"type": "json"}, "transform": [ {"type": "identifier", "as": "_vgsid_"}, { "type": "aggregate", "groupby": ["Cylinders", "Origin"], "ops": ["count"], "fields": [null], "as": ["__count"] }, {"type": "identifier", "as": "_vgsid_"} ] } ], "signals": [ {"name": "x_step", "value": 20}, {"name": "width", "update": "bandspace(domain('x').length, 0, 0) * x_step"}, {"name": "y_step", "value": 20}, { "name": "height", "update": "bandspace(domain('y').length, 0, 0) * y_step" }, { "name": "unit", "value": {}, "on": [ {"events": "mousemove", "update": "isTuple(group()) ? group() : unit"} ] }, { "name": "pts", "update": "vlSelectionResolve(\"pts_store\", \"union\", true, true)" }, { "name": "pts_tuple", "on": [ { "events": [{"source": "scope", "type": "click"}], "update": "datum && item().mark.marktype !== 'group' ? {unit: \"\", fields: pts_tuple_fields, values: [(item().isVoronoi ? datum.datum : datum)[\"_vgsid_\"]]} : null", "force": true }, {"events": [{"source": "view", "type": "dblclick"}], "update": "null"} ] }, {"name": "pts_tuple_fields", "value": [{"type": "E", "field": "_vgsid_"}]}, { "name": "pts_toggle", "value": false, "on": [ { "events": [{"source": "scope", "type": "click"}], "update": "event.shiftKey" }, {"events": [{"source": "view", "type": "dblclick"}], "update": "false"} ] }, { "name": "pts_modify", "on": [ { "events": {"signal": "pts_tuple"}, "update": "modify(\"pts_store\", pts_toggle ? null : pts_tuple, pts_toggle ? null : true, pts_toggle ? pts_tuple : null)" } ] } ], "marks": [ { "name": "marks", "type": "rect", "style": ["rect"], "interactive": true, "from": {"data": "source_0"}, "encode": { "update": { "fill": [ { "test": "!length(data(\"pts_store\")) || vlSelectionTest(\"pts_store\", datum)", "scale": "color", "field": "__count" }, {"value": "grey"} ], "description": { "signal": "\"Cylinders: \" + (isValid(datum[\"Cylinders\"]) ? datum[\"Cylinders\"] : \"\"+datum[\"Cylinders\"]) + \"; Origin: \" + (isValid(datum[\"Origin\"]) ? datum[\"Origin\"] : \"\"+datum[\"Origin\"]) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\"))" }, "x": {"scale": "x", "field": "Cylinders"}, "width": {"scale": "x", "band": 1}, "y": {"scale": "y", "field": "Origin"}, "height": {"scale": "y", "band": 1} } } } ], "scales": [ { "name": "x", "type": "band", "domain": {"data": "source_0", "field": "Cylinders", "sort": true}, "range": {"step": {"signal": "x_step"}}, "paddingInner": 0, "paddingOuter": 0 }, { "name": "y", "type": "band", "domain": {"data": "source_0", "field": "Origin", "sort": true}, "range": {"step": {"signal": "y_step"}}, "paddingInner": 0, "paddingOuter": 0 }, { "name": "color", "type": "linear", "domain": {"data": "source_0", "field": "__count"}, "range": "heatmap", "interpolate": "hcl", "zero": false } ], "axes": [ { "scale": "x", "orient": "bottom", "grid": false, "title": "Cylinders", "labelAlign": "right", "labelAngle": 270, "labelBaseline": "middle", "zindex": 1 }, { "scale": "y", "orient": "left", "grid": false, "title": "Origin", "zindex": 1 } ], "legends": [ { "fill": "color", "gradientLength": {"signal": "clamp(height, 64, 200)"}, "title": "Count of Records" } ] }