Reputation: 2314
I am developing php pie chats with pChart, it looks nice. Now I want to change color of each slices. Is it possible to change the color?
Upvotes: 2
Views: 2926
Reputation: 5919
For pChart (almost all versions), you will just use this :
...
$PieChart = new pPie($myPicture,$MyData);
$PieChart->setSliceColor(0,array("R"=>255,"G"=>128,"B"=>0));
$PieChart->setSliceColor(1,array("R"=>255,"G"=>255,"B"=>255));
$PieChart->setSliceColor(2,array("R"=>25,"G"=>128,"B"=>0));
$PieChart->setSliceColor(3,array("R"=>55,"G"=>255,"B"=>25));
...
Just add more setSliceColor for more slice on your chart
Upvotes: 1
Reputation: 1
I solved this question just doing this:
/*
Example 10 - A 3D exploded pie graph
Version 1.27d pChart*/
$Test->loadColorPalette('ColorsDirectory/tones-9.txt',',');
$Test->drawPieGraph(
$DataSet->GetData(),
$DataSet->GetDataDescription(),
350,130,110,PIE_PERCENTAGE_LABEL,FALSE,50,20,5);
...
Call loadColorPalette just before calling drawPieGraph. It works this way.Good luck!
Upvotes: 0
Reputation: 688
The function you are looking for is setSliceColor() - http://wiki.pchart.net/doc.pie.setslicecolor.html
Assuming you have created a new pie chart from some data:
$PieChart = new pPie($myPicture,$MyData);
You can then use it like this:
$PieChart->setSliceColor(0, array("R" => 255, "G" => 0, "B" => 0));
$PieChart->setSliceColor(1, array("R" => 0, "G" => 255, "B" => 0));
etc...
Upvotes: 2