{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "Temperature normals in Seattle. Derived from [Seattle Annual Temperate](https://vega.github.io/vega/examples/annual-temperature/) example from the Vega example gallery.", "background": "white", "padding": 5, "title": {"text": "Seattle Temperature Normals", "anchor": "start"}, "data": [ { "name": "source_0", "url": "data/seattle-weather-hourly-normals.csv", "format": {"type": "csv", "parse": {"date": "date"}}, "transform": [ { "type": "formula", "expr": "(hours(datum.date) + 18) % 24", "as": "order" }, { "field": "date", "type": "timeunit", "units": ["hours"], "as": ["hours_date", "hours_date_end"] }, { "field": "date", "type": "timeunit", "units": ["month", "date"], "as": ["monthdate_date", "monthdate_date_end"] }, { "type": "aggregate", "groupby": ["monthdate_date", "hours_date"], "ops": ["mean"], "fields": ["temperature"], "as": ["mean_temperature"] } ] }, { "name": "row_domain", "source": "source_0", "transform": [ { "type": "aggregate", "groupby": ["hours_date"], "fields": ["order"], "ops": ["min"], "as": ["order"] } ] } ], "signals": [ {"name": "child_width", "value": 800}, {"name": "child_height", "value": 25} ], "layout": { "padding": {"row": 1, "column": 20}, "offset": {"rowTitle": 10}, "columns": 1, "bounds": "full", "align": "all" }, "marks": [ { "name": "row-title", "type": "group", "role": "row-title", "title": { "text": "date (hours)", "orient": "left", "style": "guide-title", "offset": -4 } }, { "name": "row_header", "type": "group", "role": "row-header", "from": {"data": "row_domain"}, "sort": {"field": "datum[\"order\"]", "order": "ascending"}, "title": { "text": { "signal": "hours(parent[\"hours_date\"]) == 0 ? 'Midnight' : hours(parent[\"hours_date\"]) == 12 ? 'Noon' : timeFormat(parent[\"hours_date\"], '%I:%M %p')" }, "orient": "left", "style": "guide-label", "frame": "group", "baseline": "middle", "align": "left", "angle": 0, "offset": 2 }, "encode": {"update": {"height": {"signal": "child_height"}}}, "axes": [ { "scale": "y", "orient": "left", "grid": false, "labels": false, "ticks": false, "labelOverlap": true, "tickCount": {"signal": "ceil(child_height/40)"}, "zindex": 0 } ] }, { "name": "column_footer", "type": "group", "role": "column-footer", "encode": {"update": {"width": {"signal": "child_width"}}}, "axes": [ { "scale": "x", "orient": "bottom", "grid": false, "title": "Month", "format": "%b", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(child_width/40)"}, "zindex": 0 } ] }, { "name": "cell", "type": "group", "style": "cell", "from": { "facet": { "name": "facet", "data": "source_0", "groupby": ["hours_date"], "aggregate": { "fields": ["order"], "ops": ["min"], "as": ["order_by_hours_date"] } } }, "sort": { "field": ["datum[\"order_by_hours_date\"]"], "order": ["ascending"] }, "encode": { "update": { "width": {"signal": "child_width"}, "height": {"signal": "child_height"}, "stroke": {"value": null} } }, "marks": [ { "name": "child_marks", "type": "area", "style": ["area"], "sort": {"field": "datum[\"monthdate_date\"]"}, "from": {"data": "facet"}, "encode": { "update": { "orient": {"value": "vertical"}, "fill": {"value": "#4c78a8"}, "description": { "signal": "\"Month: \" + (timeFormat(datum[\"monthdate_date\"], '%b')) + \"; Mean of temperature: \" + (format(datum[\"mean_temperature\"], \"\"))" }, "x": {"scale": "x", "field": "monthdate_date"}, "y": {"scale": "y", "field": "mean_temperature"}, "y2": {"field": {"group": "height"}}, "defined": { "signal": "isValid(datum[\"monthdate_date\"]) && isFinite(+datum[\"monthdate_date\"]) && isValid(datum[\"mean_temperature\"]) && isFinite(+datum[\"mean_temperature\"])" } } } } ] } ], "scales": [ { "name": "x", "type": "time", "domain": {"data": "source_0", "field": "monthdate_date"}, "range": [0, {"signal": "child_width"}] }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "mean_temperature"}, "range": [{"signal": "child_height"}, 0], "zero": false, "nice": true } ], "config": {"axis": {"grid": false, "domain": false}} }