How do I change the values on a Line chart?

« 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 Marco on 1st January 2016
Hi! First of all thank you so much for your charts and graphs, they are really amazing! I want to know if it's possible to change this values:

var line1 = new RGraph.Line('line1', [56,45,43,52,56,65,21,23,34,15,21,12], [35,43,41,41,42,46,42,39,46,41,45,65,54]);

I want to be able to change dynamically this values after create the chart, is that possible?

Thank you so much!
Posted by RGraph support on 16th November 2012

Yes - with a line chart you can set the .original data variable - like this:

myLine.original_data[0] = [1,5,3,4]; // First line
myLine.original_data[1] = [5,8,6,3]; // Second line

And then redraw the canvas:

Posted by Marco on 16th November 2012
Thank you! That was really helpful!
Posted by RGraph support on 16th November 2012

Great - if you could take the time to add feedback or a testimonial for RGraph that would be great Thanks!
Posted by Marco on 19th November 2012
I just send you feedback :) I'd like to know just one more thing. I want to create my graph dynamically. For example, when i create the graph i call a function that change the values like you explained me, but that changes only the current values. I want that every time i call that function the graph increase the size adding one new value, to see how it's increasing or decreasing the variable i'm sending every time i call the function.

I don't know if i explain myself right, i hope you can understand me, thank you so much!
Posted by Marco on 19th November 2012
I solved the problem! It was really easy using the push() function!

Posted by RGraph support on 19th November 2012

In that case you could do something like this to add to the values already present:

// Add one to the first value
myLine.original_data[0][0] += 1;

// Add five to the second value
myLine.original_data[0][1] += 5;

// Add three to the third value
myLine.original_data[0][2] += 3;

// Add nine to the fourth value
myLine.original_data[0][3] += 9;

...and so on. This only affects the first dataset. You'd need to add more to change other datasets.

Add a reply

« Back to message list