Module

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

A concise grammar of interactive graphics, built on Vega.
Latest
File
{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "Slope graph showing the change in yield for different barley sites. It shows the error in the year labels for the Morris site.", "background": "white", "padding": 5, "height": 200, "style": "cell", "data": [ { "name": "source_0", "url": "data/barley.json", "format": {"type": "json"}, "transform": [ { "type": "aggregate", "groupby": ["year", "site"], "ops": ["median"], "fields": ["yield"], "as": ["median_yield"] } ] } ], "signals": [ {"name": "x_step", "value": 50}, { "name": "width", "update": "bandspace(domain('x').length, 1, 0.5) * x_step" } ], "marks": [ { "name": "pathgroup", "type": "group", "from": { "facet": { "name": "faceted_path_main", "data": "source_0", "groupby": ["site"] } }, "encode": { "update": { "width": {"field": {"group": "width"}}, "height": {"field": {"group": "height"}} } }, "marks": [ { "name": "marks", "type": "line", "style": ["line"], "sort": {"field": "datum[\"year\"]"}, "from": {"data": "faceted_path_main"}, "encode": { "update": { "stroke": {"scale": "color", "field": "site"}, "description": { "signal": "\"year: \" + (isValid(datum[\"year\"]) ? datum[\"year\"] : \"\"+datum[\"year\"]) + \"; Median of yield: \" + (format(datum[\"median_yield\"], \"\")) + \"; site: \" + (isValid(datum[\"site\"]) ? datum[\"site\"] : \"\"+datum[\"site\"])" }, "x": {"scale": "x", "field": "year"}, "y": {"scale": "y", "field": "median_yield"}, "defined": { "signal": "isValid(datum[\"median_yield\"]) && isFinite(+datum[\"median_yield\"])" } } } } ] } ], "scales": [ { "name": "x", "type": "point", "domain": {"data": "source_0", "field": "year", "sort": true}, "range": {"step": {"signal": "x_step"}}, "padding": 0.5 }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "median_yield"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true }, { "name": "color", "type": "ordinal", "domain": {"data": "source_0", "field": "site", "sort": true}, "range": "category" } ], "axes": [ { "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", "labelAlign": "right", "labelAngle": 270, "labelBaseline": "middle", "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Median of yield", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ], "legends": [{"stroke": "color", "symbolType": "stroke", "title": "site"}]}