View unanswered posts | View active topics It is currently Sat Apr 27, 2024 10:30 pm



Reply to topic  [ 1 post ] 
Labels of Piechartplus solution 
Author Message
New pChart user
New pChart user

Joined: Thu May 05, 2011 3:21 pm
Posts: 1
Post 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


Thu May 05, 2011 3:27 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron