{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 600, "data": [ {"name": "selector001_store"}, { "name": "source_0", "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/flights-5k.json", "format": {"type": "json"}, "transform": [ { "type": "formula", "expr": "hours(datum.date) + minutes(datum.date) / 60", "as": "time" }, { "type": "extent", "field": "time", "signal": "concat_1_bin_maxbins_30_time_extent" }, { "type": "bin", "field": "time", "as": ["bin_maxbins_30_time", "bin_maxbins_30_time_end"], "signal": "concat_1_bin_maxbins_30_time_bins", "extent": {"signal": "concat_1_bin_maxbins_30_time_extent"}, "maxbins": 30 }, { "type": "extent", "field": "time", "signal": "concat_0_bin_extent_param_selector001_maxbins_30_time_extent" }, { "type": "bin", "field": "time", "as": [ "bin_extent_param_selector001_maxbins_30_time", "bin_extent_param_selector001_maxbins_30_time_end" ], "signal": "concat_0_bin_extent_param_selector001_maxbins_30_time_bins", "extent": { "signal": "concat_0_bin_extent_param_selector001_maxbins_30_time_extent" }, "span": {"signal": "span(selector001[\"time\"])"}, "maxbins": 30 } ] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "aggregate", "groupby": ["bin_maxbins_30_time", "bin_maxbins_30_time_end"], "ops": ["count"], "fields": [null], "as": ["__count"] }, { "type": "filter", "expr": "isValid(datum[\"bin_maxbins_30_time\"]) && isFinite(+datum[\"bin_maxbins_30_time\"])" } ] }, { "name": "data_1", "source": "source_0", "transform": [ { "type": "aggregate", "groupby": [ "bin_extent_param_selector001_maxbins_30_time", "bin_extent_param_selector001_maxbins_30_time_end" ], "ops": ["count"], "fields": [null], "as": ["__count"] }, { "type": "filter", "expr": "isValid(datum[\"bin_extent_param_selector001_maxbins_30_time\"]) && isFinite(+datum[\"bin_extent_param_selector001_maxbins_30_time\"])" } ] } ], "signals": [ {"name": "childHeight", "value": 100}, { "name": "unit", "value": {}, "on": [ {"events": "mousemove", "update": "isTuple(group()) ? group() : unit"} ] }, { "name": "selector001", "update": "vlSelectionResolve(\"selector001_store\", \"union\")" } ], "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"} } }, "marks": [ { "name": "concat_0_marks", "type": "rect", "clip": true, "style": ["bar"], "interactive": false, "from": {"data": "data_1"}, "encode": { "update": { "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"time (binned): \" + (!isValid(datum[\"bin_extent_param_selector001_maxbins_30_time\"]) || !isFinite(+datum[\"bin_extent_param_selector001_maxbins_30_time\"]) ? \"null\" : format(datum[\"bin_extent_param_selector001_maxbins_30_time\"], \"\") + \" – \" + format(datum[\"bin_extent_param_selector001_maxbins_30_time_end\"], \"\")) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\"))" }, "x2": { "scale": "concat_0_x", "field": "bin_extent_param_selector001_maxbins_30_time", "offset": 1 }, "x": { "scale": "concat_0_x", "field": "bin_extent_param_selector001_maxbins_30_time_end" }, "y": {"scale": "concat_0_y", "field": "__count"}, "y2": {"scale": "concat_0_y", "value": 0} } } } ], "axes": [ { "scale": "concat_0_y", "orient": "left", "gridScale": "concat_0_x", "grid": true, "tickCount": {"signal": "ceil(childHeight/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "concat_0_x", "orient": "bottom", "grid": false, "title": "time (binned)", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/10)"}, "zindex": 0 }, { "scale": "concat_0_y", "orient": "left", "grid": false, "title": "Count of Records", "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"} } }, "signals": [ { "name": "selector001_x", "value": [], "on": [ { "events": { "source": "scope", "type": "mousedown", "filter": [ "!event.item || event.item.mark.name !== \"selector001_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 !== \"selector001_brush\"" ] }, {"source": "window", "type": "mouseup"} ] }, "update": "[selector001_x[0], clamp(x(unit), 0, width)]" }, { "events": {"signal": "selector001_scale_trigger"}, "update": "[scale(\"concat_1_x\", selector001_time[0]), scale(\"concat_1_x\", selector001_time[1])]" }, { "events": [{"source": "view", "type": "dblclick"}], "update": "[0, 0]" }, { "events": {"signal": "selector001_translate_delta"}, "update": "clampRange(panLinear(selector001_translate_anchor.extent_x, selector001_translate_delta.x / span(selector001_translate_anchor.extent_x)), 0, width)" }, { "events": {"signal": "selector001_zoom_delta"}, "update": "clampRange(zoomLinear(selector001_x, selector001_zoom_anchor.x, selector001_zoom_delta), 0, width)" } ] }, { "name": "selector001_time", "on": [ { "events": {"signal": "selector001_x"}, "update": "selector001_x[0] === selector001_x[1] ? null : invert(\"concat_1_x\", selector001_x)" } ] }, { "name": "selector001_scale_trigger", "value": {}, "on": [ { "events": [{"scale": "concat_1_x"}], "update": "(!isArray(selector001_time) || (+invert(\"concat_1_x\", selector001_x)[0] === +selector001_time[0] && +invert(\"concat_1_x\", selector001_x)[1] === +selector001_time[1])) ? selector001_scale_trigger : {}" } ] }, { "name": "selector001_tuple", "on": [ { "events": [{"signal": "selector001_time"}], "update": "selector001_time ? {unit: \"concat_1\", fields: selector001_tuple_fields, values: [selector001_time]} : null" } ] }, { "name": "selector001_tuple_fields", "value": [{"field": "time", "channel": "x", "type": "R"}] }, { "name": "selector001_translate_anchor", "value": {}, "on": [ { "events": [ { "source": "scope", "type": "mousedown", "markname": "selector001_brush" } ], "update": "{x: x(unit), y: y(unit), extent_x: slice(selector001_x)}" } ] }, { "name": "selector001_translate_delta", "value": {}, "on": [ { "events": [ { "source": "window", "type": "mousemove", "consume": true, "between": [ { "source": "scope", "type": "mousedown", "markname": "selector001_brush" }, {"source": "window", "type": "mouseup"} ] } ], "update": "{x: selector001_translate_anchor.x - x(unit), y: selector001_translate_anchor.y - y(unit)}" } ] }, { "name": "selector001_zoom_anchor", "on": [ { "events": [ { "source": "scope", "type": "wheel", "consume": true, "markname": "selector001_brush" } ], "update": "{x: x(unit), y: y(unit)}" } ] }, { "name": "selector001_zoom_delta", "on": [ { "events": [ { "source": "scope", "type": "wheel", "consume": true, "markname": "selector001_brush" } ], "force": true, "update": "pow(1.001, event.deltaY * pow(16, event.deltaMode))" } ] }, { "name": "selector001_modify", "on": [ { "events": {"signal": "selector001_tuple"}, "update": "modify(\"selector001_store\", selector001_tuple, true)" } ] } ], "marks": [ { "name": "selector001_brush_bg", "type": "rect", "clip": true, "encode": { "enter": { "fill": {"value": "#333"}, "fillOpacity": {"value": 0.125} }, "update": { "x": [ { "test": "data(\"selector001_store\").length && data(\"selector001_store\")[0].unit === \"concat_1\"", "signal": "selector001_x[0]" }, {"value": 0} ], "y": [ { "test": "data(\"selector001_store\").length && data(\"selector001_store\")[0].unit === \"concat_1\"", "value": 0 }, {"value": 0} ], "x2": [ { "test": "data(\"selector001_store\").length && data(\"selector001_store\")[0].unit === \"concat_1\"", "signal": "selector001_x[1]" }, {"value": 0} ], "y2": [ { "test": "data(\"selector001_store\").length && data(\"selector001_store\")[0].unit === \"concat_1\"", "field": {"group": "height"} }, {"value": 0} ] } } }, { "name": "concat_1_marks", "type": "rect", "style": ["bar"], "interactive": true, "from": {"data": "data_0"}, "encode": { "update": { "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"time (binned): \" + (!isValid(datum[\"bin_maxbins_30_time\"]) || !isFinite(+datum[\"bin_maxbins_30_time\"]) ? \"null\" : format(datum[\"bin_maxbins_30_time\"], \"\") + \" – \" + format(datum[\"bin_maxbins_30_time_end\"], \"\")) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\"))" }, "x2": { "scale": "concat_1_x", "field": "bin_maxbins_30_time", "offset": 1 }, "x": {"scale": "concat_1_x", "field": "bin_maxbins_30_time_end"}, "y": {"scale": "concat_1_y", "field": "__count"}, "y2": {"scale": "concat_1_y", "value": 0} } } }, { "name": "selector001_brush", "type": "rect", "clip": true, "encode": { "enter": {"fill": {"value": "transparent"}}, "update": { "x": [ { "test": "data(\"selector001_store\").length && data(\"selector001_store\")[0].unit === \"concat_1\"", "signal": "selector001_x[0]" }, {"value": 0} ], "y": [ { "test": "data(\"selector001_store\").length && data(\"selector001_store\")[0].unit === \"concat_1\"", "value": 0 }, {"value": 0} ], "x2": [ { "test": "data(\"selector001_store\").length && data(\"selector001_store\")[0].unit === \"concat_1\"", "signal": "selector001_x[1]" }, {"value": 0} ], "y2": [ { "test": "data(\"selector001_store\").length && data(\"selector001_store\")[0].unit === \"concat_1\"", "field": {"group": "height"} }, {"value": 0} ], "stroke": [ { "test": "selector001_x[0] !== selector001_x[1]", "value": "white" }, {"value": null} ] } } } ], "axes": [ { "scale": "concat_1_y", "orient": "left", "gridScale": "concat_1_x", "grid": true, "tickCount": {"signal": "ceil(childHeight/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "concat_1_x", "orient": "bottom", "grid": false, "title": "time (binned)", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/10)"}, "zindex": 0 }, { "scale": "concat_1_y", "orient": "left", "grid": false, "title": "Count of Records", "labelOverlap": true, "tickCount": {"signal": "ceil(childHeight/40)"}, "zindex": 0 } ] } ], "scales": [ { "name": "concat_0_x", "type": "linear", "domain": { "signal": "[concat_0_bin_extent_param_selector001_maxbins_30_time_bins.start, concat_0_bin_extent_param_selector001_maxbins_30_time_bins.stop]" }, "domainRaw": {"signal": "selector001[\"time\"]"}, "range": [0, {"signal": "width"}], "bins": { "signal": "concat_0_bin_extent_param_selector001_maxbins_30_time_bins" }, "zero": false }, { "name": "concat_0_y", "type": "linear", "domain": {"data": "data_1", "field": "__count"}, "range": [{"signal": "childHeight"}, 0], "nice": true, "zero": true }, { "name": "concat_1_x", "type": "linear", "domain": { "signal": "[concat_1_bin_maxbins_30_time_bins.start, concat_1_bin_maxbins_30_time_bins.stop]" }, "range": [0, {"signal": "width"}], "bins": {"signal": "concat_1_bin_maxbins_30_time_bins"}, "zero": false }, { "name": "concat_1_y", "type": "linear", "domain": {"data": "data_0", "field": "__count"}, "range": [{"signal": "childHeight"}, 0], "nice": true, "zero": true } ] }