{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "title": { "text": "Figure & Title < ' >", "frame": "group" }, "style": "cell", "data": [ { "name": "source_0", "url": "https://raw.githubusercontent.com/vega/vega-datasets/next/data/barley.json", "format": { "type": "json" }, "transform": [ { "type": "aggregate", "groupby": [ "variety", "site" ], "ops": [ "sum" ], "fields": [ "yield" ], "as": [ "sum_yield" ] }, { "type": "stack", "groupby": [ "variety" ], "field": "sum_yield", "sort": { "field": [ "site" ], "order": [ "ascending" ] }, "as": [ "sum_yield_start", "sum_yield_end" ], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"sum_yield\"]) && isFinite(+datum[\"sum_yield\"])" } ] } ], "signals": [ { "name": "y_step", "value": 20 }, { "name": "height", "update": "bandspace(domain('y').length, 0.1, 0.05) * y_step" } ], "marks": [ { "name": "marks", "type": "rect", "style": [ "bar" ], "from": { "data": "source_0" }, "encode": { "update": { "fill": { "scale": "color", "field": "site" }, "ariaRoleDescription": { "value": "bar" }, "description": { "signal": "\"Sum of yield: \" + (format(datum[\"sum_yield\"], \"\")) + \"; variety: \" + (isValid(datum[\"variety\"]) ? datum[\"variety\"] : \"\"+datum[\"variety\"]) + \"; site: \" + (isValid(datum[\"site\"]) ? datum[\"site\"] : \"\"+datum[\"site\"])" }, "x": { "scale": "x", "field": "sum_yield_end" }, "x2": { "scale": "x", "field": "sum_yield_start" }, "y": { "scale": "y", "field": "variety" }, "height": { "signal": "max(0.25, bandwidth('y'))" } } } } ], "scales": [ { "name": "x", "type": "linear", "domain": { "data": "source_0", "fields": [ "sum_yield_start", "sum_yield_end" ] }, "range": [ 0, { "signal": "width" } ], "nice": true, "zero": true }, { "name": "y", "type": "band", "domain": { "data": "source_0", "field": "variety", "sort": true }, "range": { "step": { "signal": "y_step" } }, "paddingInner": 0.1, "paddingOuter": 0.05 }, { "name": "color", "type": "ordinal", "domain": { "data": "source_0", "field": "site", "sort": true }, "range": "category" } ], "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": "Sum of yield", "labelFlush": true, "labelOverlap": true, "tickCount": { "signal": "ceil(width/40)" }, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "variety", "zindex": 0 } ], "legends": [ { "fill": "color", "symbolType": "square", "title": "site" } ], "config": { "axis": { "labelFont": "monospace", "titleFont": "serif" }, "legend": { "labelFont": "sans-serif", "titleFont": "serif" }, "style": { "group-title": { "font": "Caveat" } } } }