{ "$schema": "https://vega.github.io/schema/vega/v5.json", "autosize": {"type": "fit-x", "contains": "padding"}, "background": "white", "padding": 5, "height": 200, "style": "cell", "data": [ { "name": "source_0", "url": "https://raw.githubusercontent.com/vega/vega-datasets/next/data/github.csv", "format": {"type": "csv", "parse": {"time": "date"}}, "transform": [ { "field": "time", "type": "timeunit", "units": ["hours"], "as": ["hours_time", "hours_time_end"] }, { "type": "aggregate", "groupby": ["hours_time", "hours_time_end"], "ops": ["sum"], "fields": ["count"], "as": ["sum_count"] }, { "type": "filter", "expr": "(isDate(datum[\"hours_time\"]) || (isValid(datum[\"hours_time\"]) && isFinite(+datum[\"hours_time\"]))) && isValid(datum[\"sum_count\"]) && isFinite(+datum[\"sum_count\"])" } ] } ], "signals": [ { "name": "width", "init": "isFinite(containerSize()[0]) ? containerSize()[0] : 200", "on": [ { "update": "isFinite(containerSize()[0]) ? containerSize()[0] : 200", "events": "window:resize" } ] } ], "marks": [ { "name": "marks", "type": "rect", "style": ["bar"], "from": {"data": "source_0"}, "encode": { "update": { "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"time (hours): \" + (timeFormat(datum[\"hours_time\"], timeUnitSpecifier([\"hours\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; Sum of count: \" + (format(datum[\"sum_count\"], \"\"))" }, "x2": {"scale": "x", "field": "hours_time", "offset": 1}, "x": {"scale": "x", "field": "hours_time_end"}, "y": {"scale": "y", "field": "sum_count"}, "y2": {"scale": "y", "value": 0} } } } ], "scales": [ { "name": "x", "type": "time", "domain": { "data": "source_0", "fields": ["hours_time", "hours_time_end"] }, "range": [0, {"signal": "width"}] }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "sum_count"}, "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": "x", "orient": "bottom", "grid": false, "title": "time (hours)", "format": { "signal": "timeUnitSpecifier([\"hours\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})" }, "labelFlush": true, "labelOverlap": true, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Sum of count", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ] }