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



Reply to topic  [ 4 posts ] 
2.0.13 pie chart not enough colours 
Author Message
New pChart user
New pChart user

Joined: Fri Jan 21, 2011 12:43 am
Posts: 1
Post 2.0.13 pie chart not enough colours
I'm using the default colours for the slices in a pie chart; however, with more than 8 data points, it runs out of colours, issues warning messages to the screen, and renders subsequent slices in black.

The fix: when fetching colours into the palette, take the current data point id and modulo it by the palette size - the colours will thus cycle.

It needs changing in two places, lines 314 and 523. Diff appears below:

< : denotes lines in 2.0.13
> : denotes my version

314c314,315
< $Settings = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);
---
> $colourid = $ID % count($Palette);
> $Settings = array("R"=>$Palette[$colourid]["R"],"G"=>$Palette[$colourid]["G"],"B"=>$Palette[$colourid]["B"],"Alpha"=>$Palette[$colourid]["Alpha"]);
523c524,526
< { $Settings = array("R"=>$Palette[$ID]["R"]+30,"G"=>$Palette[$ID]["G"]+30,"B"=>$Palette[$ID]["B"]+30,"Alpha"=>$Palette[$ID]["Alpha"]); }
---
> {
> $colourid = $ID % count($Palette);
> $Settings = array("R"=>$Palette[$colourid]["R"]+30,"G"=>$Palette[$colourid]["G"]+30,"B"=>$Palette[$colourid]["B"]+30,"Alpha"=>$Palette[$colourid]["Alpha"]); }


Fri Jan 21, 2011 12:47 am
Profile
New pChart user
New pChart user

Joined: Mon Jan 31, 2011 5:46 pm
Posts: 2
Post Re: 2.0.13 pie chart not enough colours
Hello,

I've hit this as well (with 9 data points). The error message is:
---
Notice: Undefined offset: 8 in /var/www/george/lib/pChart2.1.0/class/pPie.class.php on line 314
---

The patch above seems to have resolved the issue. :)


Thanks,

George.


Mon Jan 31, 2011 6:16 pm
Profile
Experienced pChart user
Experienced pChart user

Joined: Thu Dec 02, 2010 3:03 pm
Posts: 36
Location: Somerville, MA, USA
Post Re: 2.0.13 pie chart not enough colours
From pChart 1.27 FAQ, but it is still actual:

Q: Series are drawn black?
A: No, this is not a bug! Series are drawn as black because you do not have enough colors in your palette. Remember, basically pChart embed only colors for 8 series. If you have more than 8 series, you'll need to add colors to you palette. The setPalette() is here to help you!

http://pchart.sourceforge.net/documentation.php?topic=faq.sblack

_________________
Image


Tue Feb 01, 2011 12:22 am
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: 2.0.13 pie chart not enough colours
I believe that it would be good to add a test entry that will create random uggly colors ;o)

JD.


Tue Feb 01, 2011 10:45 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

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