100% stacked Bar charts

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 Krishna on 9th June 2013
I do not see any document of how to build 100% Stacked Bar.
Can some one point me to the way to do it?

Thanks
Krishna
Posted by RGraph support on 10th June 2013
Hi there,

There's no option for it - but it's quite simple to do. For example:

Say you have this as your original data: [[5,1,3],[8,5,6],[4,3,5],[8,4,9]]
You can convert each stacked segment to percentages by doing a small calculation.

1. Get the total for each "stack"
2. Divide each segment into that total
3. Multiply the result by 100.

So your data becomes:

[
  [(5/9) * 100], (1/9) * 100, (3/9) * 100],
  [(8/19) * 100, (5/19) * 100, (6/19) * 100],
  [(4/12) * 100, (3/12) * 100, (5/12) * 100],
  [(8/23) * 100, (4/23) * 100, (9/23) * 100]
]

There's a demo of this here:

dev.rgraph.net/fiddle/view/6a9f4bb2192d60c87b7bd1f428c12dde





Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer

Add a reply




« Back to message list