The vega aggregation is great, but it is not compatible with user selections.
From the documentation (link in my first message).
Vega does not support selection over fields aggregated by Vega
I also add the vega config for completeness.
I think this is an aggregation because “x” applies a count of clients.
I mentioned that the documentation suggests pre aggregating the data before using vega, however, I am not sure what to use to bin values.
A function could work. I did not know that vega is compatible with FoO. Is there an example?
Thanks
{
"data": {
"values": $C
},
"mark": {
"type": "bar",
"clip": true,
"color": "#62D4A8"
},
"encoding": {
"x": {
"aggregate": "count",
"field": $C.client_name,
"type": "quantitative",
"axis": {
"title": "Count of Clients",
"format": "d",
"labelExpr": "datum.value % 1 === 0 ? datum.value : ''",
"grid": false,
"ticks": false,
"domain": true,
"domainColor": "#ccc",
"domainWidth": 2,
"labelPadding": 10,
"zindex": 1
}
},
"y": {
"bin": { "maxbins": 5 },
"field": $C.kpi_2024,
"type": "quantitative",
"axis": {
"title": "Total KPI (Binned)",
"format": "$,.0s",
"grid": false,
"ticks": false,
"domain": true,
"domainColor": "#ccc",
"domainWidth": 2,
"labelPadding": 10,
"zindex": 1
}
}
}
}