{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "Using `labelExpr` to show only initial letters of month names.", "background": "white", "padding": 5, "width": 500, "height": 200, "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"}, "delimiter": ","}, "transform": [ { "field": "date", "type": "timeunit", "units": ["year", "quarter"], "as": ["month_date", "month_date_end"] }, { "type": "aggregate", "groupby": ["month_date", "month_date_end"], "ops": ["mean"], "fields": ["precipitation"], "as": ["mean_precipitation"] }, { "type": "filter", "expr": "(isDate(datum[\"month_date\"]) || (isValid(datum[\"month_date\"]) && isFinite(+datum[\"month_date\"]))) && isValid(datum[\"mean_precipitation\"]) && isFinite(+datum[\"mean_precipitation\"])" } ] } ], "marks": [ { "name": "marks", "type": "rect", "style": ["bar"], "from": {"data": "source_0"}, "encode": { "update": { "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"date (month): \" + (timeFormat(datum[\"month_date\"], timeUnitSpecifier([\"month\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; Mean of precipitation: \" + (format(datum[\"mean_precipitation\"], \"\"))" }, "x2": [ { "test": "!isValid(datum[\"month_date\"]) || !isFinite(+datum[\"month_date\"])", "value": 0 }, {"scale": "x", "field": "month_date", "offset": 1} ], "x": [ { "test": "!isValid(datum[\"month_date\"]) || !isFinite(+datum[\"month_date\"])", "value": 0 }, {"scale": "x", "field": "month_date_end"} ], "y": {"scale": "y", "field": "mean_precipitation"}, "y2": {"scale": "y", "value": 0} } } } ], "scales": [ { "name": "x", "type": "time", "domain": { "data": "source_0", "fields": ["month_date", "month_date_end"] }, "range": [0, {"signal": "width"}] }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "mean_precipitation"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true } ], "axes": [ { "scale": "x", "orient": "bottom", "gridScale": "y", "grid": true, "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": "y", "orient": "left", "grid": false, "title": "Mean of precipitation", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ] }