{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "A simple pie chart with labels.",
"data": {
"values": [
{"category": "a", "value": 4},
{"category": "a", "value": 4},
{"category": "c", "value": 4},
{"category": "d", "value": 0},
{"category": "e", "value": 4},
{"category": "f", "value": 4}
]
},
"transform": [
{
"joinaggregate": [{
"op": "count",
"field": "category",
"as": "a_count"
}],
"groupby": ["category"]
},
{
"joinaggregate": [{
"op": "sum",
"field": "value",
"as": "a_c"
}],
"groupby": ["category"]
},
{
"calculate": "datum.a_count*datum.a_c",
"as": "PercentOfTotal"
}
],
"encoding": {
"theta": {"field": "PercentOfTotal", "type": "quantitative", "stack": true},
"color": {"field": "category", "type": "nominal", "legend": null}
},
"layer": [{
"mark": {"type": "arc", "outerRadius": 80}
}, {
"mark": {"type": "text", "radius": 90},
"encoding": {
"text": {"field": "category", "type": "nominal"}
}
}],
"view": {"stroke": null}
}
Output :
Here I wanted to get composition*value of each alphabet in category filed, as I a grouping by category I should get only one a, why am I getting 2 a's in Pie chart and how can I resolve it ?