{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "A Wilkinson Dot Plot created by generating an id and stacking data points", "background": "white", "padding": 5, "height": 100, "style": "cell", "data": [ { "name": "source_0", "values": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "window", "params": [null], "as": ["id"], "ops": ["rank"], "fields": [null], "sort": {"field": [], "order": []} }, { "type": "aggregate", "groupby": ["data", "id"], "ops": ["count"], "fields": [null], "as": ["__count"] }, { "type": "stack", "groupby": ["data"], "field": "__count", "sort": {"field": ["id"], "order": ["descending"]}, "as": ["__count_start", "__count_end"], "offset": "zero" } ] } ], "signals": [ {"name": "x_step", "value": 20}, { "name": "width", "update": "bandspace(domain('x').length, 1, 0.5) * x_step" } ], "marks": [ { "name": "marks", "type": "symbol", "style": ["circle"], "from": {"data": "data_0"}, "encode": { "update": { "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "circle"}, "description": { "signal": "\"data: \" + (isValid(datum[\"data\"]) ? datum[\"data\"] : \"\"+datum[\"data\"]) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\")) + \"; id: \" + (isValid(datum[\"id\"]) ? datum[\"id\"] : \"\"+datum[\"id\"])" }, "x": {"scale": "x", "field": "data"}, "y": { "signal": "scale(\"y\", 0.5 * datum[\"__count_start\"] + 0.5 * datum[\"__count_end\"])" }, "shape": {"value": "circle"} } } } ], "scales": [ { "name": "x", "type": "point", "domain": {"data": "data_0", "field": "data", "sort": true}, "range": {"step": {"signal": "x_step"}}, "padding": 0.5 }, { "name": "y", "type": "linear", "domain": {"data": "data_0", "fields": ["__count_start", "__count_end"]}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true } ], "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": "data", "labelAlign": "right", "labelAngle": 270, "labelBaseline": "middle", "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Count of Records", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ] }