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



Reply to topic  [ 3 posts ] 
Setting Color for Pie Slices? 
Author Message
Regular pChart user
Regular pChart user

Joined: Sun Dec 05, 2010 8:07 pm
Posts: 9
 Setting Color for Pie Slices?
I'm making several pie charts from a database and I would like to set the color of each slice based off the color supplied within the database.

The colors are stored in hex since I used them for coloring my tables and text on the page. I have a function that converts them to an rgb array.

The number of categories in my pie chart are dynamic, depending on what activity has taken place in the set time period.

I pull everything together in different arrays.

Here's some sample code I have been playing with, so far I have managed only to ensure that all the categories are black.

Code:
/* Create and populate the pData object */
$DataSet = new pData();   
$DataSet->addPoints($spendingArray,"Spending"); 

/* Define the absissa serie */
$DataSet->addPoints($categoryArray,"Labels");
$DataSet->setAbscissa("Labels");

foreach($categoryArray as $cat){
  //eventually this will have a different color for each category, but I can't even change one right now.
  $DataSet->setPalette($cat, array("R"=>20,"G"=>200,"B"=>20,"Alpha"=>100));

  }


Wed Dec 08, 2010 7:32 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Setting Color for Pie Slices?
There was a bug with the setPalette() function that has been fixed in the 2.0.5.

As the pie chart isn't based on the same data structure than the other charts (only one data serie to provide the values), the implementation of the palette as it is today isn't relevant for it (today we assign one color to one data serie)

I'll create some additional methods to cover this inside the pPie extension.

--Will be implemented in the 2.0.6 ;o)

JD.


Thu Dec 09, 2010 12:27 pm
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Setting Color for Pie Slices?
I've added the setSliceColor method in the pPie class.

This would be available in the next minor.


Fri Dec 10, 2010 8:49 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

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