I am looking for ideas on some PHP for the following -
I have an array of numerical values that feed a pie chart (created with High Charts). These values vary in size depending what the chart is showing and the array might be up to 100 values long.
The problem is that if I send these values to the pie and a lot of the values are low, it ends up with the smaller values creating lots of pie 'slices' that are too small to read and so ineffective. What I want to do is group all the values under a threshold % into a group called Other.
From research I can't seem to do this natively in High Charts but I think I should be able to do it with PHP. So the PHP would have to -
- Take an array (100, 96, 72, 25, 3, 2, 1, 1, 1) etc
- Work out the total of the values and thus % of each - (33%, 32%, 23%, 8%, 1%, 0.6%, 0.3%, 0.3%, 0.3%) etc
- Remove any values below a certain % ie 1% so that the array becomes - (100, 96, 72)
- Add back into the array a value representing the total of those removed (100, 96, 72, 33)
- The array can now be sent to the pie
Any ideas please?