With the Bipolar chart I want to colour the right and left sides seperately

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by JustJen on 30th October 2012

I'm working with Bi-Polar charts. Here is the bi Polar example page for reference www.rgraph.net/demos/index.html#bipolar

I need to style the left hand data to be a different colour to the right hand data.
chart.colors just affects everything.

I could use chart.colors.sequential and set chart.colors to an array like this;
['red', 'red', 'red', 'green', 'green', 'green'])
...and in a table with 3 rows of data this would be fine. It would colour all of the lefts as red then the rights as green. However my charts are dynamic and the amount of rows within them is constantly changing so this wouldn't work here.

Does anyone have any advice on how to do this?

Jen :)
Posted by RGraph support on 30th October 2012

You simply need to populate the colors array according to how many data points that you have. So if there are 6 items, add 6 red and six green. The API function RGraph.array_pad(array, length[, value]) will make it easier to fill the colors array, then you just set it like this:

// Fill the myColors array according to how much data that you have

bipolar.Set('chart.colors.sequential', true);
bipolar.Set('chart.colors', myColors);

Add a reply

« Back to message list