{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "height": 200, "style": "cell", "data": [ { "name": "source_0", "url": "data/cars.json", "format": {"type": "json", "parse": {"Year": "date"}}, "transform": [ { "field": "Year", "type": "timeunit", "units": ["year"], "as": ["year_Year", "year_Year_end"] }, { "type": "aggregate", "groupby": ["year_Year"], "ops": ["ci0", "ci1", "mean", "mean"], "fields": [ "Miles_per_Gallon", "Miles_per_Gallon", "Miles_per_Gallon", "Miles_per_Gallon" ], "as": [ "lower_Miles_per_Gallon", "upper_Miles_per_Gallon", "center_Miles_per_Gallon", "mean_Miles_per_Gallon" ] } ] } ], "marks": [ { "name": "layer_0_layer_0_marks", "type": "area", "style": ["area", "errorband-band"], "sort": {"field": "datum[\"year_Year\"]"}, "from": {"data": "source_0"}, "encode": { "update": { "ariaRoleDescription": {"value": "errorband"}, "opacity": {"value": 0.3}, "orient": {"value": "vertical"}, "fill": {"value": "#4c78a8"}, "tooltip": { "signal": "{\"Ci1 of Miles_per_Gallon\": format(datum[\"upper_Miles_per_Gallon\"], \"\"), \"Ci0 of Miles_per_Gallon\": format(datum[\"lower_Miles_per_Gallon\"], \"\"), \"Mean of Miles_per_Gallon\": format(datum[\"center_Miles_per_Gallon\"], \"\"), \"Year (year)\": timeFormat(datum[\"year_Year\"], '%b %d, %Y')}" }, "description": { "signal": "\"Year (year): \" + (timeFormat(datum[\"year_Year\"], '%b %d, %Y')) + \"; Mean of Miles per Gallon (95% CIs): \" + (format(datum[\"lower_Miles_per_Gallon\"], \"\")) + \"; upper_Miles_per_Gallon: \" + (format(datum[\"upper_Miles_per_Gallon\"], \"\")) + \"; Ci1 of Miles_per_Gallon: \" + (format(datum[\"upper_Miles_per_Gallon\"], \"\")) + \"; Ci0 of Miles_per_Gallon: \" + (format(datum[\"lower_Miles_per_Gallon\"], \"\")) + \"; Mean of Miles_per_Gallon: \" + (format(datum[\"center_Miles_per_Gallon\"], \"\"))" }, "x": {"scale": "x", "field": "year_Year"}, "y": {"scale": "y", "field": "lower_Miles_per_Gallon"}, "y2": {"scale": "y", "field": "upper_Miles_per_Gallon"}, "defined": { "signal": "isValid(datum[\"year_Year\"]) && isFinite(+datum[\"year_Year\"]) && isValid(datum[\"lower_Miles_per_Gallon\"]) && isFinite(+datum[\"lower_Miles_per_Gallon\"])" } } } }, { "name": "layer_1_marks", "type": "line", "style": ["line"], "sort": {"field": "datum[\"year_Year\"]"}, "from": {"data": "source_0"}, "encode": { "update": { "stroke": {"value": "#4c78a8"}, "description": { "signal": "\"Year (year): \" + (timeFormat(datum[\"year_Year\"], timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; Mean of Miles_per_Gallon: \" + (format(datum[\"mean_Miles_per_Gallon\"], \"\"))" }, "x": {"scale": "x", "field": "year_Year"}, "y": {"scale": "y", "field": "mean_Miles_per_Gallon"}, "defined": { "signal": "isValid(datum[\"year_Year\"]) && isFinite(+datum[\"year_Year\"]) && isValid(datum[\"mean_Miles_per_Gallon\"]) && isFinite(+datum[\"mean_Miles_per_Gallon\"])" } } } } ], "scales": [ { "name": "x", "type": "time", "domain": {"data": "source_0", "field": "year_Year"}, "range": [0, {"signal": "width"}] }, { "name": "y", "type": "linear", "domain": { "data": "source_0", "fields": [ "lower_Miles_per_Gallon", "upper_Miles_per_Gallon", "mean_Miles_per_Gallon" ] }, "range": [{"signal": "height"}, 0], "nice": true, "zero": true } ], "axes": [ { "scale": "x", "orient": "bottom", "gridScale": "y", "grid": true, "tickCount": {"signal": "ceil(width/40)"}, "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": "Year (year)", "format": { "signal": "timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})" }, "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Mean of Miles per Gallon (95% CIs)", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ] }