Can't seem to update variables/properties in an RGraph Line object


« 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 Lasse Dahl on 24th January 2018
I am creating "line", which is a global "copy" of RGraph.line and want to update the graph every 30sec. I try to update the data of some of the variables in the "copy" of RGraph I frequently but it does not work. On my web page "la55ed.no-ip.org:4997/varmtvann" I would expect "line.data" to be equal to 'lineData.value' but it is not updated. Why not?
Posted by Richard on 1st January 2016
Hi there,

Here's a bare-bones updating Line chart using the canvas Line chart:

www.rgraph.net/tests/canvas.line/updating.html

It basically involves pushing data on to the end of the relevant data array, popping one off the front of the array and then redrawing the chart.

It currently updates every second but you can change that by setting the delay variable.

Note: It should be noted that this page does not create a new Line chart on each refresh - it creates one array and then updates that objects data and then redraws the chart.

You'll find more dynamic examples in the demos, including examples of dynamic SVG charts. When I get around to doing the next beta release (either today or tomorrow) there will be an SVG dynamic demo here:

www.rgraph.net/demos/svg-line-dynamic2.html

It's there now but doesn't work correctly.

Richard
Posted by Lasse Dahl on 1st January 2016
Thank you very much for the quick reply and interesting input. However I need to replace all data completely including the X-axis labels for each update (not only shift the data value array). Is there any function like "line.originalData.replace([]);" and "line.properties.xaxisLabels.replace([]);" ?
Posted by Richard on 1st January 2016
Hi there,

No but if you're completely replacing the data it's easier IMO:

line.originalData[0] = RGraph.SVG.arrayClone(myNewData);
line.properties.xaxisLabels = RGraph.SVG.arrayClone(myNewLabels);

Richard
Posted by Lasse Dahl on 25th January 2018
Thanks,
Now my page works quite well on Firefox on my Linux computer, but if I use my iPad the line graph do not update. The other text on the page do update but i think it seems like the graph data stay in chach in the iPad. What do you think. This is my page: la55ed.no-ip.org:4997/varmtvann

BR
Lasse
Posted by Richard on 25th January 2018
Hi there,

I have no iPad to test your chart with I'm afraid. But it doesn't look like the chart is updating on Windows Chrome either.

So I'd suggest you try and get it working on Firefox, Chrome, IE and Opera on a Windows machine where there's a console that you can read the error messages with - and then see if it works with your iPad.

Richard

Add a reply




« Back to message list