{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "style": "cell", "data": [ { "name": "source_0", "url": "data/barley.json", "format": {"type": "json"}, "transform": [ { "type": "aggregate", "groupby": ["variety"], "ops": ["mean", "mean", "stderr"], "fields": ["yield", "yield", "yield"], "as": ["mean_yield", "center_yield", "extent_yield"] } ] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"mean_yield\"]) && isFinite(+datum[\"mean_yield\"])" } ] }, { "name": "data_1", "source": "source_0", "transform": [ { "type": "formula", "expr": "datum[\"center_yield\"] + datum[\"extent_yield\"]", "as": "upper_yield" }, { "type": "formula", "expr": "datum[\"center_yield\"] - datum[\"extent_yield\"]", "as": "lower_yield" } ] }, { "name": "data_2", "source": "data_1", "transform": [ { "type": "filter", "expr": "isValid(datum[\"lower_yield\"]) && isFinite(+datum[\"lower_yield\"])" } ] }, { "name": "data_3", "source": "data_1", "transform": [ { "type": "filter", "expr": "isValid(datum[\"upper_yield\"]) && isFinite(+datum[\"upper_yield\"])" } ] } ], "signals": [ {"name": "y_step", "value": 20}, {"name": "height", "update": "bandspace(domain('y').length, 0, 0) * y_step"} ], "marks": [ { "name": "layer_0_layer_0_marks", "type": "rect", "style": ["tick", "errorbar-ticks"], "aria": false, "from": {"data": "data_2"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "teal"}, "tooltip": { "signal": "{\"Mean of yield\": format(datum[\"center_yield\"], \"\"), \"Mean + stderr of yield\": format(datum[\"upper_yield\"], \"\"), \"Mean - stderr of yield\": format(datum[\"lower_yield\"], \"\"), \"variety\": isValid(datum[\"variety\"]) ? datum[\"variety\"] : \"\"+datum[\"variety\"]}" }, "xc": {"scale": "x", "field": "lower_yield"}, "yc": {"scale": "y", "field": "variety", "band": 0.5}, "height": {"value": 15}, "width": {"value": 1} } } }, { "name": "layer_0_layer_1_marks", "type": "rect", "style": ["tick", "errorbar-ticks"], "aria": false, "from": {"data": "data_3"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "teal"}, "tooltip": { "signal": "{\"Mean of yield\": format(datum[\"center_yield\"], \"\"), \"Mean + stderr of yield\": format(datum[\"upper_yield\"], \"\"), \"Mean - stderr of yield\": format(datum[\"lower_yield\"], \"\"), \"variety\": isValid(datum[\"variety\"]) ? datum[\"variety\"] : \"\"+datum[\"variety\"]}" }, "xc": {"scale": "x", "field": "upper_yield"}, "yc": {"scale": "y", "field": "variety", "band": 0.5}, "height": {"value": 15}, "width": {"value": 1} } } }, { "name": "layer_0_layer_2_marks", "type": "rule", "style": ["rule", "errorbar-rule"], "from": {"data": "data_2"}, "encode": { "update": { "ariaRoleDescription": {"value": "errorbar"}, "stroke": {"value": "black"}, "tooltip": { "signal": "{\"Mean of yield\": format(datum[\"center_yield\"], \"\"), \"Mean + stderr of yield\": format(datum[\"upper_yield\"], \"\"), \"Mean - stderr of yield\": format(datum[\"lower_yield\"], \"\"), \"variety\": isValid(datum[\"variety\"]) ? datum[\"variety\"] : \"\"+datum[\"variety\"]}" }, "description": { "signal": "\"yield: \" + (format(datum[\"lower_yield\"], \"\")) + \"; variety: \" + (isValid(datum[\"variety\"]) ? datum[\"variety\"] : \"\"+datum[\"variety\"]) + \"; upper_yield: \" + (format(datum[\"upper_yield\"], \"\")) + \"; Mean of yield: \" + (format(datum[\"center_yield\"], \"\")) + \"; Mean + stderr of yield: \" + (format(datum[\"upper_yield\"], \"\")) + \"; Mean - stderr of yield: \" + (format(datum[\"lower_yield\"], \"\"))" }, "x": {"scale": "x", "field": "lower_yield"}, "x2": {"scale": "x", "field": "upper_yield"}, "y": {"scale": "y", "field": "variety", "band": 0.5} } } }, { "name": "layer_1_marks", "type": "symbol", "style": ["point"], "from": {"data": "data_0"}, "encode": { "update": { "fill": {"value": "black"}, "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Mean of yield: \" + (format(datum[\"mean_yield\"], \"\")) + \"; variety: \" + (isValid(datum[\"variety\"]) ? datum[\"variety\"] : \"\"+datum[\"variety\"])" }, "x": {"scale": "x", "field": "mean_yield"}, "y": {"scale": "y", "field": "variety", "band": 0.5} } } } ], "scales": [ { "name": "x", "type": "linear", "domain": { "fields": [ {"data": "data_2", "field": "lower_yield"}, {"data": "data_3", "field": "upper_yield"}, {"data": "data_2", "field": "upper_yield"}, {"data": "data_0", "field": "mean_yield"} ] }, "range": [0, {"signal": "width"}], "zero": false, "nice": true }, { "name": "y", "type": "band", "domain": { "fields": [ {"data": "data_2", "field": "variety"}, {"data": "data_3", "field": "variety"}, {"data": "data_0", "field": "variety"} ], "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": "yield", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "variety", "zindex": 0 } ] }