pChart 2.x forum http://wiki.pchart.net/forum/ |
|
2.0.13 pie chart not enough colours http://wiki.pchart.net/forum/viewtopic.php?f=5&t=123 |
Page 1 of 1 |
Author: | matthucke [ Fri Jan 21, 2011 12:47 am ] |
Post subject: | 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"]); } |
Author: | GeorgeB [ Mon Jan 31, 2011 6:16 pm ] |
Post subject: | 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. |
Author: | mice32 [ Tue Feb 01, 2011 12:22 am ] |
Post subject: | 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 |
Author: | jean-damien [ Tue Feb 01, 2011 10:45 am ] |
Post subject: | 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. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |