{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 400, "height": 400, "style": "cell", "data": [ {"name": "highlight_store"}, { "name": "source_0", "values": [ {"id": 1}, {"id": 2}, {"id": 3}, {"id": 4}, {"id": 5}, {"id": 6}, {"id": 7}, {"id": 8}, {"id": 9}, {"id": 10}, {"id": 11}, {"id": 12}, {"id": 13}, {"id": 14}, {"id": 15}, {"id": 16}, {"id": 17}, {"id": 18}, {"id": 19}, {"id": 20}, {"id": 21}, {"id": 22}, {"id": 23}, {"id": 24}, {"id": 25}, {"id": 26}, {"id": 27}, {"id": 28}, {"id": 29}, {"id": 30}, {"id": 31}, {"id": 32}, {"id": 33}, {"id": 34}, {"id": 35}, {"id": 36}, {"id": 37}, {"id": 38}, {"id": 39}, {"id": 40}, {"id": 41}, {"id": 42}, {"id": 43}, {"id": 44}, {"id": 45}, {"id": 46}, {"id": 47}, {"id": 48}, {"id": 49}, {"id": 50}, {"id": 51}, {"id": 52}, {"id": 53}, {"id": 54}, {"id": 55}, {"id": 56}, {"id": 57}, {"id": 58}, {"id": 59}, {"id": 60}, {"id": 61}, {"id": 62}, {"id": 63}, {"id": 64}, {"id": 65}, {"id": 66}, {"id": 67}, {"id": 68}, {"id": 69}, {"id": 70}, {"id": 71}, {"id": 72}, {"id": 73}, {"id": 74}, {"id": 75}, {"id": 76}, {"id": 77}, {"id": 78}, {"id": 79}, {"id": 80}, {"id": 81}, {"id": 82}, {"id": 83}, {"id": 84}, {"id": 85}, {"id": 86}, {"id": 87}, {"id": 88}, {"id": 89}, {"id": 90}, {"id": 91}, {"id": 92}, {"id": 93}, {"id": 94}, {"id": 95}, {"id": 96}, {"id": 97}, {"id": 98}, {"id": 99}, {"id": 100} ] }, { "name": "data_0", "source": "source_0", "transform": [ {"type": "formula", "expr": "ceil (datum.id/10)", "as": "col"}, {"type": "formula", "expr": "datum.id - datum.col*10", "as": "row"} ] } ], "signals": [ { "name": "unit", "value": {}, "on": [ {"events": "mousemove", "update": "isTuple(group()) ? group() : unit"} ] }, { "name": "highlight", "update": "vlSelectionResolve(\"highlight_store\", \"union\")" }, { "name": "highlight_x", "value": [], "on": [ { "events": { "source": "scope", "type": "mousedown", "filter": [ "!event.item || event.item.mark.name !== \"highlight_brush\"" ] }, "update": "[x(unit), x(unit)]" }, { "events": { "source": "window", "type": "mousemove", "consume": true, "between": [ { "source": "scope", "type": "mousedown", "filter": [ "!event.item || event.item.mark.name !== \"highlight_brush\"" ] }, {"source": "window", "type": "mouseup"} ] }, "update": "[highlight_x[0], clamp(x(unit), 0, width)]" }, {"events": {"signal": "highlight_scale_trigger"}, "update": "[0, 0]"}, { "events": [{"source": "view", "type": "dblclick"}], "update": "[0, 0]" }, { "events": {"signal": "highlight_translate_delta"}, "update": "clampRange(panLinear(highlight_translate_anchor.extent_x, highlight_translate_delta.x / span(highlight_translate_anchor.extent_x)), 0, width)" }, { "events": {"signal": "highlight_zoom_delta"}, "update": "clampRange(zoomLinear(highlight_x, highlight_zoom_anchor.x, highlight_zoom_delta), 0, width)" } ] }, { "name": "highlight_col", "on": [ { "events": {"signal": "highlight_x"}, "update": "highlight_x[0] === highlight_x[1] ? null : invert(\"x\", highlight_x)" } ] }, { "name": "highlight_y", "value": [], "on": [ { "events": { "source": "scope", "type": "mousedown", "filter": [ "!event.item || event.item.mark.name !== \"highlight_brush\"" ] }, "update": "[y(unit), y(unit)]" }, { "events": { "source": "window", "type": "mousemove", "consume": true, "between": [ { "source": "scope", "type": "mousedown", "filter": [ "!event.item || event.item.mark.name !== \"highlight_brush\"" ] }, {"source": "window", "type": "mouseup"} ] }, "update": "[highlight_y[0], clamp(y(unit), 0, height)]" }, {"events": {"signal": "highlight_scale_trigger"}, "update": "[0, 0]"}, { "events": [{"source": "view", "type": "dblclick"}], "update": "[0, 0]" }, { "events": {"signal": "highlight_translate_delta"}, "update": "clampRange(panLinear(highlight_translate_anchor.extent_y, highlight_translate_delta.y / span(highlight_translate_anchor.extent_y)), 0, height)" }, { "events": {"signal": "highlight_zoom_delta"}, "update": "clampRange(zoomLinear(highlight_y, highlight_zoom_anchor.y, highlight_zoom_delta), 0, height)" } ] }, { "name": "highlight_row", "on": [ { "events": {"signal": "highlight_y"}, "update": "highlight_y[0] === highlight_y[1] ? null : invert(\"y\", highlight_y)" } ] }, { "name": "highlight_scale_trigger", "value": {}, "on": [ { "events": [{"scale": "x"}, {"scale": "y"}], "update": "(!isArray(highlight_col) || (invert(\"x\", highlight_x)[0] === highlight_col[0] && invert(\"x\", highlight_x)[1] === highlight_col[1])) && (!isArray(highlight_row) || (invert(\"y\", highlight_y)[0] === highlight_row[0] && invert(\"y\", highlight_y)[1] === highlight_row[1])) ? highlight_scale_trigger : {}" } ] }, { "name": "highlight_tuple", "on": [ { "events": [{"signal": "highlight_col || highlight_row"}], "update": "highlight_col && highlight_row ? {unit: \"\", fields: highlight_tuple_fields, values: [highlight_col,highlight_row]} : null" } ] }, { "name": "highlight_tuple_fields", "value": [ {"field": "col", "channel": "x", "type": "E"}, {"field": "row", "channel": "y", "type": "E"} ] }, { "name": "highlight_translate_anchor", "value": {}, "on": [ { "events": [ { "source": "scope", "type": "mousedown", "markname": "highlight_brush" } ], "update": "{x: x(unit), y: y(unit), extent_x: slice(highlight_x), extent_y: slice(highlight_y)}" } ] }, { "name": "highlight_translate_delta", "value": {}, "on": [ { "events": [ { "source": "window", "type": "mousemove", "consume": true, "between": [ { "source": "scope", "type": "mousedown", "markname": "highlight_brush" }, {"source": "window", "type": "mouseup"} ] } ], "update": "{x: highlight_translate_anchor.x - x(unit), y: highlight_translate_anchor.y - y(unit)}" } ] }, { "name": "highlight_zoom_anchor", "on": [ { "events": [ { "source": "scope", "type": "wheel", "consume": true, "markname": "highlight_brush" } ], "update": "{x: x(unit), y: y(unit)}" } ] }, { "name": "highlight_zoom_delta", "on": [ { "events": [ { "source": "scope", "type": "wheel", "consume": true, "markname": "highlight_brush" } ], "force": true, "update": "pow(1.001, event.deltaY * pow(16, event.deltaMode))" } ] }, { "name": "highlight_modify", "on": [ { "events": {"signal": "highlight_tuple"}, "update": "modify(\"highlight_store\", highlight_tuple, true)" } ] } ], "marks": [ { "name": "highlight_brush_bg", "type": "rect", "clip": true, "encode": { "enter": {"fill": {"value": "#333"}, "fillOpacity": {"value": 0.125}}, "update": { "x": [ { "test": "data(\"highlight_store\").length && data(\"highlight_store\")[0].unit === \"\"", "signal": "highlight_x[0]" }, {"value": 0} ], "y": [ { "test": "data(\"highlight_store\").length && data(\"highlight_store\")[0].unit === \"\"", "signal": "highlight_y[0]" }, {"value": 0} ], "x2": [ { "test": "data(\"highlight_store\").length && data(\"highlight_store\")[0].unit === \"\"", "signal": "highlight_x[1]" }, {"value": 0} ], "y2": [ { "test": "data(\"highlight_store\").length && data(\"highlight_store\")[0].unit === \"\"", "signal": "highlight_y[1]" }, {"value": 0} ] } } }, { "name": "marks", "type": "symbol", "style": ["point"], "interactive": true, "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": [ { "test": "!length(data(\"highlight_store\")) || vlSelectionTest(\"highlight_store\", datum)", "value": "rgb(194,81,64)" }, {"value": "rgb(167,165,156)"} ], "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"col: \" + (isValid(datum[\"col\"]) ? datum[\"col\"] : \"\"+datum[\"col\"]) + \"; row: \" + (isValid(datum[\"row\"]) ? datum[\"row\"] : \"\"+datum[\"row\"])" }, "x": {"scale": "x", "field": "col"}, "y": {"scale": "y", "field": "row"}, "size": {"value": 90}, "shape": { "value": "M1.7 -1.7h-0.8c0.3 -0.2 0.6 -0.5 0.6 -0.9c0 -0.6 -0.4 -1 -1 -1c-0.6 0 -1 0.4 -1 1c0 0.4 0.2 0.7 0.6 0.9h-0.8c-0.4 0 -0.7 0.3 -0.7 0.6v1.9c0 0.3 0.3 0.6 0.6 0.6h0.2c0 0 0 0.1 0 0.1v1.9c0 0.3 0.2 0.6 0.3 0.6h1.3c0.2 0 0.3 -0.3 0.3 -0.6v-1.8c0 0 0 -0.1 0 -0.1h0.2c0.3 0 0.6 -0.3 0.6 -0.6v-2c0.2 -0.3 -0.1 -0.6 -0.4 -0.6z" } } } }, { "name": "highlight_brush", "type": "rect", "clip": true, "encode": { "enter": {"fill": {"value": "transparent"}}, "update": { "x": [ { "test": "data(\"highlight_store\").length && data(\"highlight_store\")[0].unit === \"\"", "signal": "highlight_x[0]" }, {"value": 0} ], "y": [ { "test": "data(\"highlight_store\").length && data(\"highlight_store\")[0].unit === \"\"", "signal": "highlight_y[0]" }, {"value": 0} ], "x2": [ { "test": "data(\"highlight_store\").length && data(\"highlight_store\")[0].unit === \"\"", "signal": "highlight_x[1]" }, {"value": 0} ], "y2": [ { "test": "data(\"highlight_store\").length && data(\"highlight_store\")[0].unit === \"\"", "signal": "highlight_y[1]" }, {"value": 0} ], "stroke": [ { "test": "highlight_x[0] !== highlight_x[1] && highlight_y[0] !== highlight_y[1]", "value": "white" }, {"value": null} ] } } } ], "scales": [ { "name": "x", "type": "point", "domain": {"data": "data_0", "field": "col", "sort": true}, "range": [0, {"signal": "width"}], "padding": 0.5 }, { "name": "y", "type": "point", "domain": {"data": "data_0", "field": "row", "sort": true}, "range": [0, {"signal": "height"}], "padding": 0.5 } ], "config": {"style": {"cell": {"stroke": ""}}} }