{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 50, "style": "cell", "data": [ { "name": "source_0", "url": "data/cars.json", "format": {"type": "json"}, "transform": [ { "type": "aggregate", "groupby": ["Origin"], "ops": ["mean"], "fields": ["Horsepower"], "as": ["mean_Horsepower"] } ] } ], "signals": [ {"name": "y_step", "value": 20}, { "name": "height", "update": "bandspace(domain('y').length, 1, 0.5) * y_step" } ], "marks": [ { "name": "marks", "type": "text", "style": ["text"], "from": {"data": "source_0"}, "encode": { "update": { "fill": {"value": "black"}, "description": { "signal": "\"Origin: \" + (isValid(datum[\"Origin\"]) ? datum[\"Origin\"] : \"\"+datum[\"Origin\"]) + \"; Mean of Horsepower: \" + (format(datum[\"mean_Horsepower\"], \".2f\"))" }, "x": {"signal": "width", "mult": 0.5}, "y": {"scale": "y", "field": "Origin"}, "text": {"signal": "format(datum[\"mean_Horsepower\"], \".2f\")"}, "align": {"value": "center"}, "baseline": {"value": "middle"} } } } ], "scales": [ { "name": "y", "type": "point", "domain": {"data": "source_0", "field": "Origin", "sort": true}, "range": {"step": {"signal": "y_step"}}, "padding": 0.5 } ], "axes": [ { "scale": "y", "orient": "left", "grid": false, "title": "Origin", "zindex": 0 } ] }