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

Share RGraph:   Share or Like RGraph on Facebook!

« 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
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

Add a reply




« Back to message list