diff --git a/examples/compiled/tick_timeunit.png b/examples/compiled/tick_timeunit.png new file mode 100644 index 0000000000..827505fbf0 Binary files /dev/null and b/examples/compiled/tick_timeunit.png differ diff --git a/examples/compiled/tick_timeunit.svg b/examples/compiled/tick_timeunit.svg new file mode 100644 index 0000000000..9338b1e40a --- /dev/null +++ b/examples/compiled/tick_timeunit.svg @@ -0,0 +1 @@ +2004200520062007200820092010date (year)01,0002,0003,0004,0005,0006,0007,000Sum of price \ No newline at end of file diff --git a/examples/compiled/tick_timeunit.vg.json b/examples/compiled/tick_timeunit.vg.json new file mode 100644 index 0000000000..e5b840c35b --- /dev/null +++ b/examples/compiled/tick_timeunit.vg.json @@ -0,0 +1,131 @@ +{ + "$schema": "https://vega.github.io/schema/vega/v5.json", + "description": "Google's stock price over time.", + "background": "white", + "padding": 5, + "width": 200, + "height": 200, + "style": "cell", + "data": [ + { + "name": "source_0", + "url": "data/stocks.csv", + "format": {"type": "csv", "parse": {"date": "date"}}, + "transform": [ + {"type": "filter", "expr": "datum.symbol==='GOOG'"}, + { + "field": "date", + "type": "timeunit", + "units": ["year"], + "as": ["year_date", "year_date_end"] + }, + { + "type": "aggregate", + "groupby": ["year_date"], + "ops": ["sum"], + "fields": ["price"], + "as": ["sum_price"] + }, + { + "type": "filter", + "expr": "(isDate(datum[\"year_date\"]) || (isValid(datum[\"year_date\"]) && isFinite(+datum[\"year_date\"]))) && isValid(datum[\"sum_price\"]) && isFinite(+datum[\"sum_price\"])" + } + ] + } + ], + "marks": [ + { + "name": "marks", + "type": "rect", + "style": ["tick"], + "from": {"data": "source_0"}, + "encode": { + "update": { + "fill": {"value": "#4c78a8"}, + "ariaRoleDescription": {"value": "tick"}, + "description": { + "signal": "\"date (year): \" + (timeFormat(datum[\"year_date\"], timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; Sum of price: \" + (format(datum[\"sum_price\"], \"\"))" + }, + "xc": {"scale": "x", "field": "year_date"}, + "yc": {"scale": "y", "field": "sum_price"}, + "width": {"signal": "(1 - 0.25) * width"}, + "height": {"value": 1} + } + } + } + ], + "scales": [ + { + "name": "x", + "type": "time", + "domain": {"data": "source_0", "field": "year_date"}, + "range": [0, {"signal": "width"}] + }, + { + "name": "y", + "type": "linear", + "domain": {"data": "source_0", "field": "sum_price"}, + "range": [{"signal": "height"}, 0], + "nice": true, + "zero": true + } + ], + "axes": [ + { + "scale": "x", + "orient": "bottom", + "gridScale": "y", + "grid": true, + "tickCount": {"signal": "ceil(width/40)"}, + "tickMinStep": { + "signal": "datetime(2002, 0, 1, 0, 0, 0, 0) - datetime(2001, 0, 1, 0, 0, 0, 0)" + }, + "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)", + "format": { + "signal": "timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})" + }, + "labelFlush": true, + "labelOverlap": true, + "tickCount": {"signal": "ceil(width/40)"}, + "tickMinStep": { + "signal": "datetime(2002, 0, 1, 0, 0, 0, 0) - datetime(2001, 0, 1, 0, 0, 0, 0)" + }, + "zindex": 0 + }, + { + "scale": "y", + "orient": "left", + "grid": false, + "title": "Sum of price", + "labelOverlap": true, + "tickCount": {"signal": "ceil(height/40)"}, + "zindex": 0 + } + ] +}