View unanswered posts | View active topics It is currently Sun Apr 28, 2024 10:33 pm



Reply to topic  [ 4 posts ] 
Problem with normalize to 100% 
Author Message
New pChart user
New pChart user

Joined: Thu Jan 13, 2011 5:39 pm
Posts: 2
Post Problem with normalize to 100%
Hi.

I'm using pChart 2.0.12 and love it! Thanks so much for a cool package!

Unfortunately, I have discovered an issue with normalizing a chart to 100% when several values are zero. In my example, Networks 3, 4, and 7 have all zero values, but it graphs them as multiple pieces of 100%.

My example source code is here, and this is what it looks like:

Image

Thanks.
:Michael S.


Thu Jan 13, 2011 7:57 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Problem with normalize to 100%
Nice one!

You can replace the following code from the normalize() function in the pData classe :
Code:
       if ( $Factor == 0 ) { $Factor = 1; }
       $Factor = $NormalizationFactor / $Factor;

       foreach ($SelectedSeries as $Key => $SerieName )
        {
         $Value = $this->Data["Series"][$SerieName]["Data"][$i];

         if ( $Value != VOID && $Factor != $NormalizationFactor )
          $this->Data["Series"][$SerieName]["Data"][$i] = round(abs($Value)*$Factor,$Round);
         elseif ( $Value == VOID  )
          $this->Data["Series"][$SerieName]["Data"][$i] = VOID;
         elseif ( $Factor == $NormalizationFactor )
          $this->Data["Series"][$SerieName]["Data"][$i] = $NormalizationFactor;
        }

By
Code:
       if ( $Factor != 0 )
        {
         $Factor = $NormalizationFactor / $Factor;

         foreach ($SelectedSeries as $Key => $SerieName )
          {
           $Value = $this->Data["Series"][$SerieName]["Data"][$i];

           if ( $Value != VOID && $Factor != $NormalizationFactor )
            $this->Data["Series"][$SerieName]["Data"][$i] = round(abs($Value)*$Factor,$Round);
           elseif ( $Value == VOID || $Value == 0 )
            $this->Data["Series"][$SerieName]["Data"][$i] = VOID;
           elseif ( $Factor == $NormalizationFactor )
            $this->Data["Series"][$SerieName]["Data"][$i] = $NormalizationFactor;
          }
        }


Thank you!
JD.


Thu Jan 13, 2011 8:34 pm
Profile WWW
New pChart user
New pChart user

Joined: Thu Jan 13, 2011 5:39 pm
Posts: 2
Post Re: Problem with normalize to 100%
Awesome. Thank you very much! Works like a champ.

_________________
Michael Skurka
Austin, TX


Thu Jan 13, 2011 8:44 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Problem with normalize to 100%
This has been fixed in the 2.1.0 that you can get from here : download.

Kind regards,
JD.


Wed Jan 26, 2011 3:01 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 19 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