Labels of Piechartplus solution
Problem:
If one of the data values in a pie chart is zero, the data point gets removed from the array because it is not needed to be plotted.
However the label arrays stays intact which leads to wrong labels attached to wrong pieces of the pie.
I modified the code to come up with correct labels, another adjustment I made was that the colors stays the same. (so two pie charts could be compared)
Line 97 of the pieChart class.
Code:
/* Dump the real number of data to draw */
$Values = "";
$Labels = "";
$LabelTeller = 0;
foreach ($Data["Series"][$DataSerie]["Data"] as $Key => $Value)
{
if ($Value != 0)
{
$Values[] = $Value;
}
else {
unset($Data["Series"][$Data["Abscissa"]]["Data"][$LabelTeller]);
$Data["Series"][$Data["Abscissa"]]["Data"] = array_values($Data["Series"][$Data["Abscissa"]]["Data"]);
unset($Palette[$LabelTeller]);
$Palette = array_values($Palette);
$LabelTeller--;
}
$LabelTeller++;
}
I hope it helps someone