{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "title": { "text": "Daily Max Temperatures (C) in Seattle, WA", "frame": "group" }, "style": "cell", "data": [ { "name": "source_0", "url": "https://raw.githubusercontent.com/vega/vega-datasets/master/data/seattle-weather.csv", "format": { "type": "csv", "parse": {"date": "date", "temp_max": "number"}, "delimiter": "," }, "transform": [ { "field": "date", "type": "timeunit", "units": ["date"], "as": ["date_date", "date_date_end"] }, { "field": "date", "type": "timeunit", "units": ["month"], "as": ["month_date", "month_date_end"] }, { "type": "aggregate", "groupby": ["date_date", "month_date"], "ops": ["max"], "fields": ["temp_max"], "as": ["max_temp_max"] }, { "type": "filter", "expr": "isValid(datum[\"max_temp_max\"]) && isFinite(+datum[\"max_temp_max\"])" } ] } ], "signals": [ {"name": "x_step", "value": 13}, {"name": "width", "update": "bandspace(domain('x').length, 0, 0) * x_step"}, {"name": "y_step", "value": 13}, {"name": "height", "update": "bandspace(domain('y').length, 0, 0) * y_step"} ], "marks": [ { "name": "marks", "type": "rect", "style": ["rect"], "from": {"data": "source_0"}, "encode": { "update": { "fill": {"scale": "color", "field": "max_temp_max"}, "description": { "signal": "\"Day: \" + (timeFormat(datum[\"date_date\"], '%e')) + \"; Month: \" + (timeFormat(datum[\"month_date\"], timeUnitSpecifier([\"month\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; Max of temp_max: \" + (format(datum[\"max_temp_max\"], \"\"))" }, "x": {"scale": "x", "field": "date_date"}, "width": {"scale": "x", "band": 1}, "y": {"scale": "y", "field": "month_date"}, "height": {"scale": "y", "band": 1} } } } ], "scales": [ { "name": "x", "type": "band", "domain": {"data": "source_0", "field": "date_date", "sort": true}, "range": {"step": {"signal": "x_step"}}, "paddingInner": 0, "paddingOuter": 0 }, { "name": "y", "type": "band", "domain": {"data": "source_0", "field": "month_date", "sort": true}, "range": {"step": {"signal": "y_step"}}, "paddingInner": 0, "paddingOuter": 0 }, { "name": "color", "type": "linear", "domain": {"data": "source_0", "field": "max_temp_max"}, "range": "heatmap", "interpolate": "hcl", "zero": false } ], "axes": [ { "scale": "x", "orient": "bottom", "grid": false, "title": "Day", "format": "%e", "labelAngle": 0, "formatType": "time", "labelBaseline": "top", "labelOverlap": true, "zindex": 1 }, { "scale": "y", "orient": "left", "grid": false, "title": "Month", "format": { "signal": "timeUnitSpecifier([\"month\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})" }, "formatType": "time", "labelOverlap": true, "zindex": 1 } ], "legends": [ {"fill": "color", "gradientLength": {"signal": "clamp(height, 64, 200)"}} ], "config": {"axis": {"domain": false}, "style": {"cell": {"strokeWidth": 0}}} }