View unanswered posts | View active topics It is currently Thu May 16, 2024 3:52 pm



Reply to topic  [ 7 posts ] 
Assign colors to series 
Author Message
Regular pChart user
Regular pChart user

Joined: Sun Mar 06, 2011 3:07 pm
Posts: 15
Post Assign colors to series
Hi,

I am a bit confused on how to define a specific color for to a series.

Objective 1: I have a line chart with 20 series. I would like to give half the series a specific color.
Objective 2: If a color is auto assigned (as it is currently), I would like to obtain the colour value and assign it to a second series. For example something like: setSerieColor( "Serie2", getSerieColor("Serie1") ); Is there something like that or is there a workaround?

Thanks for your help,

Stefan


Thu Mar 10, 2011 7:12 am
Profile
pChart user
pChart user

Joined: Sat Feb 26, 2011 12:10 am
Posts: 5
Post Re: Assign colors to series
The colors aren't random. They are actually defaults. The way you associate colors with series is to either use one of the existing pallette's or to create your own pallete file, and then use that pallette. The Pallete files are very simple -- just a list of RGB colors, so setting up your own pallette is probably what you want, given your intention to have particular series be specific colors. The series will get the colors you define in your pallette file in the order in which you defined them.


Wed Mar 16, 2011 10:39 am
Profile
Regular pChart user
Regular pChart user

Joined: Sun Mar 06, 2011 3:07 pm
Posts: 15
Post Re: Assign colors to series
Hi gizmola,

thank you for your reply. So the palette is the only way to assign colours? I guess if I would like to dynamically assign colours and also maybe two data series with the same colour, I would have to automatically generate a new palatte and assign the series in a specific order to do this?

Best wishes,

stefan


Wed Mar 16, 2011 12:59 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Assign colors to series
Hi Stefan,

You can use the setPalette() function to assign colors to a specified data serie.

Kind regards,
JD.


Wed Mar 23, 2011 10:51 am
Profile WWW
Regular pChart user
Regular pChart user

Joined: Sun Mar 06, 2011 3:07 pm
Posts: 15
Post Re: Assign colors to series
Hi Jean-Damien,

thank you for your replies!

Is it possible to include a function like getPalette to get the colour of a specific series? That wayI can use the built in function of assigning default colours but also see what colour has been assigned to a specific series so I can reassign it as well. So I leave all colour management up to the original settings.

Best wishes,

Stefan


Thu Mar 24, 2011 6:44 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Assign colors to series
I will do it ;o)


Sun Mar 27, 2011 10:05 am
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Assign colors to series
Hi,

Just added the getSeriePalette() method to the pData class. (getPalette was already defined for internal use). Using it you can now copy the palette of one serie and replace it to another one :

Code:
$MyData->setPalette("Probe 2",$MyData->getSeriePalette("Probe 1"));


I've also modified the setPalette() method so it can accept an array of series as 1st argument :

Code:
$MyData->setPalette(array("Probe 2","Probe 3"),$MyData->getSeriePalette("Probe 1"));


This change will be published in the 2.1.1 subversion.

--Thanks for your suggestion ;o)

Kind regards,
JD.


Mon Mar 28, 2011 8:34 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

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