Module

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

A concise grammar of interactive graphics, built on Vega.
Latest
File
{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "A bar chart showing the US population distribution of age groups in 2000.", "background": "white", "padding": 5, "width": 200, "style": "cell", "data": [ { "name": "source_0", "url": "data/population.json", "format": {"type": "json", "parse": {"people": "number"}}, "transform": [ {"type": "filter", "expr": "datum.year == 2000"}, { "type": "aggregate", "groupby": ["age"], "ops": ["mean", "min", "max"], "fields": ["people", "people", "people"], "as": ["mean_people", "min_people", "max_people"] } ] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"mean_people\"]) && isFinite(+datum[\"mean_people\"])" } ] }, { "name": "data_1", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"min_people\"]) && isFinite(+datum[\"min_people\"])" } ] }, { "name": "data_2", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"max_people\"]) && isFinite(+datum[\"max_people\"])" } ] } ], "signals": [ {"name": "y_step", "value": 20}, {"name": "height", "update": "bandspace(domain('y').length, 0, 0) * y_step"} ], "marks": [ { "name": "layer_0_marks", "type": "rule", "style": ["rule"], "from": {"data": "data_1"}, "encode": { "update": { "stroke": {"value": "black"}, "description": { "signal": "\"age: \" + (isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"]) + \"; population: \" + (format(datum[\"min_people\"], \"\")) + \"; Max of people: \" + (format(datum[\"max_people\"], \"\"))" }, "x": {"scale": "x", "field": "min_people"}, "x2": {"scale": "x", "field": "max_people"}, "y": {"scale": "y", "field": "age", "band": 0.5} } } }, { "name": "layer_1_marks", "type": "rect", "style": ["tick"], "from": {"data": "data_1"}, "encode": { "update": { "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "tick"}, "description": { "signal": "\"age: \" + (isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"]) + \"; population: \" + (format(datum[\"min_people\"], \"\"))" }, "xc": {"scale": "x", "field": "min_people"}, "yc": {"scale": "y", "field": "age", "band": 0.5}, "height": {"value": 5}, "width": {"value": 1} } } }, { "name": "layer_2_marks", "type": "rect", "style": ["tick"], "from": {"data": "data_2"}, "encode": { "update": { "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "tick"}, "description": { "signal": "\"age: \" + (isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"]) + \"; population: \" + (format(datum[\"max_people\"], \"\"))" }, "xc": {"scale": "x", "field": "max_people"}, "yc": {"scale": "y", "field": "age", "band": 0.5}, "height": {"value": 5}, "width": {"value": 1} } } }, { "name": "layer_3_marks", "type": "symbol", "style": ["point"], "from": {"data": "data_0"}, "encode": { "update": { "fill": {"value": "transparent"}, "stroke": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"age: \" + (isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"]) + \"; population: \" + (format(datum[\"mean_people\"], \"\"))" }, "x": {"scale": "x", "field": "mean_people"}, "y": {"scale": "y", "field": "age", "band": 0.5}, "size": {"value": 2} } } } ], "scales": [ { "name": "x", "type": "linear", "domain": { "fields": [ {"data": "data_1", "field": "min_people"}, {"data": "data_1", "field": "max_people"}, {"data": "data_2", "field": "max_people"}, {"data": "data_0", "field": "mean_people"} ] }, "range": [0, {"signal": "width"}], "nice": true, "zero": true }, { "name": "y", "type": "band", "domain": { "fields": [ {"data": "data_1", "field": "age"}, {"data": "data_2", "field": "age"}, {"data": "data_0", "field": "age"} ], "sort": true }, "range": {"step": {"signal": "y_step"}}, "paddingInner": 0, "paddingOuter": 0 } ], "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": "x", "orient": "bottom", "grid": false, "title": "population", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, {"scale": "y", "orient": "left", "grid": false, "title": "age", "zindex": 0} ]}