embed({
"width": 400,
"height": 400,
"data": [
{
"name": "table",
"values": [
{"g": 1, "c": 0, "r": 12},
{"g": 1, "c": 1, "r": 20},
{"g": 1, "c": 2, "r": 10},
{"g": 2, "c": 0, "r": 23},
{"g": 2, "c": 1, "r": 38},
{"g": 2, "c": 2, "r": 32},
{"g": 3, "c": 0, "r": 47},
{"g": 3, "c": 1, "r": 64},
{"g": 3, "c": 2, "r": 27},
{"g": 4, "c": 0, "r": 6},
{"g": 4, "c": 1, "r": 27},
{"g": 4, "c": 2, "r": 16},
{"g": 5, "c": 0, "r": 52},
{"g": 5, "c": 1, "r": 79},
{"g": 5, "c": 2, "r": 38},
{"g": 6, "c": 0, "r": 19},
{"g": 6, "c": 1, "r": 83},
{"g": 6, "c": 2, "r": 5}
]
},
{
"name": "angles",
"source": "table",
"transform": [
{"type": "aggregate", "groupby": ["g"]},
{"type": "pie"}
]
},{
"name": "stack",
"source": "table",
"transform": [
{"type": "stack", "groupby": ["g"], "sortby": ["c"], "field": "r"},
{"type": "lookup", "from": "angles", "key": "g", "fields": ["g"], "as": ["obj"]}
]
}
],
"scales": [
{
"name": "color",
"type": "linear",
"domain": {"data": "stack", "field": "c"},
"range": {"scheme": "reds"}
},
{
"name": "r",
"type": "sqrt",
"domain": {"data": "table", "field": "y"},
"range": [20, 200]
}
],
"marks": [
{
"type": "arc",
"from": {"data": "stack"},
"encode": {
"enter": {
"x": {"field": {"group": "width"}, "mult": 0.5},
"y": {"field": {"group": "height"}, "mult": 0.5},
"startAngle": {"data": "table", "field": "obj.startAngle"},
"endAngle": {"data": "table", "field": "obj.endAngle"},
"innerRadius": {"field": "y0"},
"outerRadius": {"field": "y1"},
"stroke": {"value": "black"}
},
"update": {"fill": {"scale": "color", "field": "c"}},
"hover": {"fill": {"value": "red"}}
}
}
],
"config": {}
})