I'm working on a map where when a user clicks on a State, they get a chart of congressional district breakdown for that state. So far it's been easy, but I can't customize the colors of my pie chart colors. I would like to have red and blue slices for the district breakdown, but can't figure out how. Any ideas?
Furthermore, anyone know how to have tooltips on the chart without hovering over a slice?
var clicked = $feature.STATE_ABBR;
var districts = FeatureSetByName($map, "USA 118th Congressional Districts (All Territories)")
var f = Filter(districts, "STATE_ABBR = @clicked")
var party = GroupBy(f, "PARTY", {name: "count", expression: 'PARTY', statistic: "COUNT"});
var chartValues = {};
var chartTitles = [];
for (var blah in party){
chartValues[blah.PARTY]=blah.count
Push(chartTitles, blah.PARTY)
}
return {
type: "media",
title: "Congressional district breakdown by state",
altText: "Congressional district breakdown by state",
attributes: chartValues,
style:{
colors:[
"#f6eff7",
"#dbc9e1",
]
},
mediaInfos:[{
type: 'piechart',
value:{
fields:chartTitles,
tooltipField: "PARTY"
}
}]
}