{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "A simple radial chart with embedded data.", "background": "white", "padding": 5, "width": 200, "height": 200, "data": [ {"name": "source_0", "values": [12, 23, 47, 6, 52, 19]}, { "name": "data_1", "source": "source_0", "transform": [ { "type": "stack", "groupby": [], "field": "data", "sort": {"field": ["data"], "order": ["ascending"]}, "as": ["data_start", "data_end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"data\"]) && isFinite(+datum[\"data\"])" } ] }, { "name": "data_2", "source": "source_0", "transform": [ { "type": "stack", "groupby": [], "field": "data", "sort": { "field": ["data", "data"], "order": ["ascending", "ascending"] }, "as": ["data_start", "data_end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"data\"]) && isFinite(+datum[\"data\"])" } ] } ], "marks": [ { "name": "layer_0_marks", "type": "arc", "style": ["arc"], "from": {"data": "data_1"}, "encode": { "update": { "stroke": {"value": "#fff"}, "innerRadius": {"value": 20}, "fill": {"scale": "color", "field": "data"}, "description": { "signal": "\"data: \" + (format(datum[\"data\"], \"\"))" }, "x": {"signal": "width", "mult": 0.5}, "y": {"signal": "height", "mult": 0.5}, "outerRadius": {"scale": "radius", "field": "data"}, "startAngle": {"scale": "theta", "field": "data_end"}, "endAngle": {"scale": "theta", "field": "data_start"} } } }, { "name": "layer_1_marks", "type": "text", "style": ["text"], "from": {"data": "data_2"}, "encode": { "update": { "fill": {"scale": "color", "field": "data"}, "description": { "signal": "\"data: \" + (format(datum[\"data\"], \"\"))" }, "x": {"signal": "width", "mult": 0.5}, "y": {"signal": "height", "mult": 0.5}, "text": {"signal": "format(datum[\"data\"], \"\")"}, "align": {"value": "center"}, "baseline": {"value": "middle"}, "radius": {"scale": "radius", "field": "data", "offset": 10}, "theta": { "signal": "scale(\"theta\", 0.5 * datum[\"data_start\"] + 0.5 * datum[\"data_end\"])" } } } } ], "scales": [ { "name": "theta", "type": "linear", "domain": { "fields": [ {"data": "data_1", "field": "data_start"}, {"data": "data_1", "field": "data_end"}, {"data": "data_2", "field": "data_start"}, {"data": "data_2", "field": "data_end"} ] }, "range": [0, 6.283185307179586], "zero": true }, { "name": "radius", "type": "sqrt", "domain": { "fields": [ {"data": "data_1", "field": "data"}, {"data": "data_2", "field": "data"} ] }, "range": [20, {"signal": "min(width,height)/2"}], "zero": true }, { "name": "color", "type": "ordinal", "domain": { "fields": [ {"data": "data_1", "field": "data"}, {"data": "data_2", "field": "data"} ], "sort": true }, "range": "category" } ] }