How to use a different color for each section on a stacked Bar chart

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

« 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 Anthony on 27th June 2016
Hi,

I want to make a stacked bar chart. In this chart, there is one stacked bar for each day of a week(7 stacked bar on the graph).

Is it possible to use different color for each day(on the specific stacked bar)?

Thank you for your help,

Best regards,

Anthony
Posted by Richard on 27th June 2016
Hi there,

You could use the colorsSequential option (assuming each bar has three sections):

...
colors: ['red','red','red','blue','blue','blue'],
colorsSequential: true,
...








Richard

PLEASE READ:

If RGraph has helped you please give your feedback - thanks! You can give your feedback or leave a testimonial by adding a forum post or clicking on the speech bubble icon at the very top right.

But most of all: Please link to the RGraph website (get information on how to do it by clicking on the chain icon at the top right of the page)
Posted by Anthony on 28th June 2016
Hi Richard,

Thank you for your answer and for your help.

However I don't think i can use the colorsSequential option to do what i want. It's explain in the documentation that the colorsSequentiel is only work with regular bar charts.

What the documentation says :
"colorsSequential
If true, for regular bar charts, (not stacked or grouped), the colors that you specify will be used in a sequential fashion.
Default: false"

My purpose is to have a stacked bar chart with different color for each stacked bar on the graph.

Best regards,

Anthony.
Posted by Richard on 28th June 2016
Hi there,

You can still use the colorsSequential option. If you have three sections to your stack then you specify red three times. Like this

...
colors: ['red','red','red','blue','blue','blue'],
colorsSequential: true,
...





Richard

PLEASE READ:

If RGraph has helped you please give your feedback - thanks! You can give your feedback or leave a testimonial by adding a forum post or clicking on the speech bubble icon at the very top right.

But most of all: Please link to the RGraph website (get information on how to do it by clicking on the chain icon at the top right of the page)

Add a reply




« Back to message list