Bar chart question: Animate data change and adjust y-axis

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 thomas on 14th July 2016
Hello,
I'm trying to build a bar chart with 3 buttons, changing the data accordingly. It works fine using

bar.data("newData");
RGraph.redraw();

But since my data changes quite drastically, I need to adjust the y-axis. How can I do this? Also, is there a way to animate the bars going from one data set to the other?

Thanks,
thomas

Posted by thomas on 14th July 2016
Okay, I found a way to adjust the y-axis by manually setting ymax.

Now is there a way to animate the bars going from on dataset to the other?


Thanks,
thomas
Posted by Richard on 14th July 2016
Hi there,

Not at the moment - looking at the code, the grow() method always grows from 0 (because the frame starts at zero and the frame is used in the calculation.

I'll look at making something like an option to the grow() method so that instead of starting at zero it starts by using the charts current data.






Richard
Posted by Richard on 14th July 2016
Hi there,

I'm implementing an option to the grow() function that will allow you to specify a new dataset to it - you do realise that in the case that a new dataset is provided for an existing dataset to "grow to", that if the resulting scale is different then there will be a little jump at the start of the animation as the new dataset is set?

I'm looking at something like this:

// No new data provided
.grow();

// New data provided - must contain the same number of elements as the starting dataset
.grow({data: [4,8,6,3,5]});

// Possible addition. Not absolute numbers but additionals/subtractions to the current
// dataset. Could be mixed with absolute numbers.
.grow({data: ['+2','+1','-1',6,5]});






Richard
Posted by Richard on 15th July 2016
Hi,

OK there's an example here:

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

If the scale changes (eg 0-10 changing to 0-50) there will be a jump though.


Richard

Add a reply




« Back to message list