{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "height": 200, "style": "cell", "data": [ {"name": "hover_store"}, { "name": "source_0", "url": "data/seattle-weather.csv", "format": {"type": "csv", "parse": {"date": "date"}}, "transform": [ {"type": "identifier", "as": "_vgsid_"}, { "field": "date", "type": "timeunit", "units": ["year", "month", "date"], "as": ["yearmonthdate_date", "yearmonthdate_date_end"] } ] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "filter", "expr": "(isDate(datum[\"yearmonthdate_date\"]) || (isValid(datum[\"yearmonthdate_date\"]) && isFinite(+datum[\"yearmonthdate_date\"])))" } ] } ], "signals": [ { "name": "unit", "value": {}, "on": [ {"events": "mousemove", "update": "isTuple(group()) ? group() : unit"} ] }, { "name": "hover", "update": "vlSelectionResolve(\"hover_store\", \"union\", true, true)" }, { "name": "hover_tuple", "on": [ { "events": [{"source": "scope", "type": "mouseover"}], "update": "datum && item().mark.marktype !== 'group' ? {unit: \"layer_2\", 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": "layer_0_marks", "type": "line", "style": ["line"], "sort": {"field": "datum[\"yearmonthdate_date\"]"}, "interactive": true, "from": {"data": "source_0"}, "encode": { "update": { "stroke": {"value": "orange"}, "tooltip": { "signal": "{\"date (year-month-date)\": timeFormat(datum[\"yearmonthdate_date\"], timeUnitSpecifier([\"year\",\"month\",\"date\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})), \"temp_max\": format(datum[\"temp_max\"], \"\"), \"temp_min\": format(datum[\"temp_min\"], \"\")}" }, "description": { "signal": "\"date (year-month-date): \" + (timeFormat(datum[\"yearmonthdate_date\"], timeUnitSpecifier([\"year\",\"month\",\"date\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; temp_max: \" + (format(datum[\"temp_max\"], \"\")) + \"; temp_min: \" + (format(datum[\"temp_min\"], \"\"))" }, "x": {"scale": "x", "field": "yearmonthdate_date"}, "y": {"scale": "y", "field": "temp_max"}, "defined": { "signal": "isValid(datum[\"yearmonthdate_date\"]) && isFinite(+datum[\"yearmonthdate_date\"]) && isValid(datum[\"temp_max\"]) && isFinite(+datum[\"temp_max\"])" } } } }, { "name": "layer_1_marks", "type": "line", "style": ["line"], "sort": {"field": "datum[\"yearmonthdate_date\"]"}, "interactive": true, "from": {"data": "source_0"}, "encode": { "update": { "stroke": {"value": "red"}, "tooltip": { "signal": "{\"date (year-month-date)\": timeFormat(datum[\"yearmonthdate_date\"], timeUnitSpecifier([\"year\",\"month\",\"date\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})), \"temp_max\": format(datum[\"temp_max\"], \"\"), \"temp_min\": format(datum[\"temp_min\"], \"\")}" }, "description": { "signal": "\"date (year-month-date): \" + (timeFormat(datum[\"yearmonthdate_date\"], timeUnitSpecifier([\"year\",\"month\",\"date\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; temp_min: \" + (format(datum[\"temp_min\"], \"\")) + \"; temp_max: \" + (format(datum[\"temp_max\"], \"\"))" }, "x": {"scale": "x", "field": "yearmonthdate_date"}, "y": {"scale": "y", "field": "temp_min"}, "defined": { "signal": "isValid(datum[\"yearmonthdate_date\"]) && isFinite(+datum[\"yearmonthdate_date\"]) && isValid(datum[\"temp_min\"]) && isFinite(+datum[\"temp_min\"])" } } } }, { "name": "layer_2_marks", "type": "rule", "style": ["rule"], "interactive": true, "from": {"data": "data_0"}, "encode": { "update": { "stroke": [ { "test": "length(data(\"hover_store\")) && vlSelectionTest(\"hover_store\", datum)", "value": "black" }, {"value": "transparent"} ], "tooltip": { "signal": "{\"date (year-month-date)\": timeFormat(datum[\"yearmonthdate_date\"], timeUnitSpecifier([\"year\",\"month\",\"date\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})), \"temp_max\": format(datum[\"temp_max\"], \"\"), \"temp_min\": format(datum[\"temp_min\"], \"\")}" }, "description": { "signal": "\"date (year-month-date): \" + (timeFormat(datum[\"yearmonthdate_date\"], timeUnitSpecifier([\"year\",\"month\",\"date\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; temp_max: \" + (format(datum[\"temp_max\"], \"\")) + \"; temp_min: \" + (format(datum[\"temp_min\"], \"\"))" }, "x": {"scale": "x", "field": "yearmonthdate_date"}, "y": {"value": 0}, "y2": {"field": {"group": "height"}} } } } ], "scales": [ { "name": "x", "type": "time", "domain": { "fields": [ {"data": "source_0", "field": "yearmonthdate_date"}, {"data": "data_0", "field": "yearmonthdate_date"} ] }, "range": [0, {"signal": "width"}] }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "fields": ["temp_max", "temp_min"]}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true } ], "axes": [ { "scale": "x", "orient": "bottom", "gridScale": "y", "grid": true, "tickCount": {"signal": "ceil(width/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "y", "orient": "left", "gridScale": "x", "grid": true, "tickCount": {"signal": "ceil(height/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "x", "orient": "bottom", "grid": false, "title": "date (year-month-date)", "format": { "signal": "timeUnitSpecifier([\"year\",\"month\",\"date\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})" }, "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "temp_max, temp_min", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ], "config": {"axisY": {"minExtent": 30}} }