while doing aggregation on count of string I am getting error as nan%.
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "A simple pie chart with labels.",
"height": 500,
"width": 500,
"data": {
"values": [
{"date": "4/15/2020", "brand": "open", "mentions": "inc1"},
{"date": "4/7/2020", "brand": "close", "mentions": "inc2"},
{"date": "6/29/2020", "brand": "open", "mentions": "inc3"},
{"date": "11/7/2020", "brand": "close", "mentions": "inc4"},
{"date": "10/10/2020", "brand": "resolved", "mentions": "inc5"},
{"date": "10/25/2020", "brand": "pending", "mentions": "inc6"},
{"date": "11/7/2020", "brand": "pending", "mentions": "inc7"}
]
},
"encoding": {
"theta": {
"field": "mentions",
"stack": true,
"aggregate": "count",
"as":"tmen"
}
},
"transform": [{
"window": [{
"op": "count",
"field": "mentions",
"as": "TotalTime"
}],
"frame": [null, null]
},
{
"calculate": "datum.tmen/datum.TotalTime * 100",
"as": "PercentOfTotal"
}],
"layer": [
{
"mark": {"type": "arc", "outerRadius": 200},
"encoding": {
"color": {
"field": "brand",
"type": "nominal",
"legend": "true",
"scale": {"range": "category"}
}
}
},
{
"mark": {"type": "text", "radius": 250, "fontSize": 16},
"encoding": {"text": {"field": "brand", "type": "nominal"}}
},
{
"mark": {"type": "text", "radius": 90},
"encoding": {
"text": {"field": "PercentOfTotal", "type": "quantitative","aggregate":"mean","format":".2%"}
}
}
],
"view": {"stroke": null}
}
Thanks in advance