Additional functionality to the adjustable 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 Andy on 25th August 2016
Hi Richard,

I'm really interested in the Adjusting Bar Chart for a project I'm working on.
I wanted to know whether you had already built any additional functionality to the chart?
We were looking at being able to set a number in which the values of the individual bars would always aggregate up to.

For example, if I have a top line number of 300 units and I wanted to move bar 1 from 50 to 90 units. The script would auto adjust (decrease in this scenario) the remaining 5 bars so that the sum of all the bars still reconciled back to 300.
We've managed to recreate the reconciliation in Excel, but the visuals are nowhere near as good.
I am very new to JavaScript (I've only coded SQL and little bit of R before), but I'm assuming it's possible to edit your function to incorporate this reconciliation.

My question is: is this something you have already explored and built a working prototype for?

Thanks,
Andy
Posted by Richard on 25th August 2016
Hi there,

I'd imagine that you could do this with the onadjustend event. So in that event you'd get the value - 90 in your example - subtract it from 300, which leaves 210, and then set each of the other bars to 42. (And then redraw the chart with RGraph.redraw() ).

I can make an example for you but not until later today. Here's a link in the mean time to the custom RGraph events docs page:

www.rgraph.net/docs/custom-rgraph-events.html

Richard
Posted by Richard on 25th August 2016
Hi there,

Something like this maybe:

www.rgraph.net/tests/bar-onadjustend.html


Richard
Posted by Andy on 25th August 2016
Thanks Richard, looks great - very much appreciated. We'll try and customise it some more and will post anything we do on here.

Thanks again,
Andy

Add a reply




« Back to message list