Reputation: 133
I have a pie chart with so many slices that is very hard to read it. Is it possible to reduce the number of slices, by grouping the smallest in just one named "others", or hiding them?
Upvotes: 10
Views: 2803
Reputation: 451
Pasting some info in here as a pointer for people that would like to do the above with javascript outside of Highcharts, like i did myself.
for(i=0; i<dataJSON.finished.length; i++) {
//console.info(i);
if(dataJSON.finished[i].name !== '_all_' && dataJSON.finished[i].name !== 'Anders') {
tempValue=0;
for(j=0; j<dataJSON.finished[i].data.length; j++) { tempValue += dataJSON.finished[i].data[j]; }
if(tempValue / totalValue > 0.02) {
pieData.push({ name:dataJSON.finished[i].name, y:tempValue });
} else andersValue += tempValue;
}
}
//console.info(pieData);
pieData.sort(function(a,b) {return (a.y > b.y) ? -1 : ((b.y > a.y) ? 1 : 0);});
pieData.push({ name: "Overig", y: andersValue });
Upvotes: 0
Reputation: 3812
No. This behaviour is not built into highcharts.
The easiest way to achieve this is by manually changing the data you pass to the chart. Ie if you do the grouping into a category 'Others' before you pass the data and render the chart
Upvotes: 6