Module

x/vega_lite/examples/compiled/errorbar_2d_vertical_ticks.vg.json

A concise grammar of interactive graphics, built on Vega.
Latest
File
{ "$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"], "fields": [ "Miles_per_Gallon", "Miles_per_Gallon", "Miles_per_Gallon" ], "as": [ "lower_Miles_per_Gallon", "upper_Miles_per_Gallon", "center_Miles_per_Gallon" ] } ] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"lower_Miles_per_Gallon\"]) && isFinite(+datum[\"lower_Miles_per_Gallon\"]) && (isDate(datum[\"year_Year\"]) || (isValid(datum[\"year_Year\"]) && isFinite(+datum[\"year_Year\"])))" } ] }, { "name": "data_1", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"upper_Miles_per_Gallon\"]) && isFinite(+datum[\"upper_Miles_per_Gallon\"]) && (isDate(datum[\"year_Year\"]) || (isValid(datum[\"year_Year\"]) && isFinite(+datum[\"year_Year\"])))" } ] } ], "marks": [ { "name": "layer_0_marks", "type": "rect", "style": ["tick", "errorbar-ticks"], "aria": false, "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0.7}, "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')}" }, "xc": {"scale": "x", "field": "year_Year"}, "yc": [ { "test": "!isValid(datum[\"lower_Miles_per_Gallon\"]) || !isFinite(+datum[\"lower_Miles_per_Gallon\"])", "field": {"group": "height"} }, {"scale": "y", "field": "lower_Miles_per_Gallon"} ], "width": {"value": 15}, "height": {"value": 1} } } }, { "name": "layer_1_marks", "type": "rect", "style": ["tick", "errorbar-ticks"], "aria": false, "from": {"data": "data_1"}, "encode": { "update": { "opacity": {"value": 0.7}, "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')}" }, "xc": {"scale": "x", "field": "year_Year"}, "yc": [ { "test": "!isValid(datum[\"upper_Miles_per_Gallon\"]) || !isFinite(+datum[\"upper_Miles_per_Gallon\"])", "field": {"group": "height"} }, {"scale": "y", "field": "upper_Miles_per_Gallon"} ], "width": {"value": 15}, "height": {"value": 1} } } }, { "name": "layer_2_marks", "type": "rule", "style": ["rule", "errorbar-rule"], "from": {"data": "data_0"}, "encode": { "update": { "ariaRoleDescription": {"value": "errorbar"}, "stroke": {"value": "black"}, "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": "\"Miles per Gallon (95% CIs): \" + (format(datum[\"lower_Miles_per_Gallon\"], \"\")) + \"; upper_Miles_per_Gallon: \" + (format(datum[\"upper_Miles_per_Gallon\"], \"\")) + \"; Year (year): \" + (timeFormat(datum[\"year_Year\"], '%b %d, %Y')) + \"; 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": [ { "test": "!isValid(datum[\"lower_Miles_per_Gallon\"]) || !isFinite(+datum[\"lower_Miles_per_Gallon\"])", "field": {"group": "height"} }, {"scale": "y", "field": "lower_Miles_per_Gallon"} ], "y2": [ { "test": "!isValid(datum[\"upper_Miles_per_Gallon\"]) || !isFinite(+datum[\"upper_Miles_per_Gallon\"])", "field": {"group": "height"} }, {"scale": "y", "field": "upper_Miles_per_Gallon"} ] } } } ], "scales": [ { "name": "x", "type": "time", "domain": { "fields": [ {"data": "data_0", "field": "year_Year"}, {"data": "data_1", "field": "year_Year"} ] }, "range": [0, {"signal": "width"}] }, { "name": "y", "type": "linear", "domain": { "fields": [ {"data": "data_0", "field": "lower_Miles_per_Gallon"}, {"data": "data_1", "field": "upper_Miles_per_Gallon"}, {"data": "data_0", "field": "upper_Miles_per_Gallon"} ] }, "range": [{"signal": "height"}, 0], "zero": false, "nice": 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)", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Miles per Gallon (95% CIs)", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ]}