How to update the chart including its labels

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 Andrew on 12th August 2016
I have a php script that returns a JSON array of data with 3 sets of numbers for 3 different lines it also returns the current timestamp. I want to have the actual time plotted along the x-axis that will contine to update as time passes so the data points are plotted in real time.

Basically I want to recreate this chart that uses Flot charts in Rgraph www.jqueryflottutorial.com/tester-11.html

Can it be done?

Here is an example of the output of my php script that will be returned every second via ajax

{"cpu":89,"mem":80.52,"rx":6.5,"timestamp":1471008279074}
Posted by Andrew on 12th August 2016
This looks like it will be very hard to do in Rgraph and I will need to use a scatter chart as x scale is in mins but the points can be anywhere between those mins so its not just a case of updating the labels.
Posted by Richard on 12th August 2016
Hi there,

By the sounds of it this demo does almost exactly what you want:

www.rgraph.net/demos/line-dynamic-last-10-minutes.html

(keep watching it for 5 minutes)

I vaguely remember it occasionally missing out values - I'm pretty sure this is something to do with inaccurate timers. If you're only updating the chart every minute or so then it might not be such an issue.

PS. Not 'very' hard either. Especially as the code is right there.

 

Richard

Posted by Andrew on 12th August 2016
Hi, Thanks I cant believe I missed that one. It does look like it does almost exactly what I want. Should be easy enough to add in the other two lines and have a different scale on the right hand y-axis correct?
Posted by Richard on 12th August 2016
Hi there,

Yes I'd imagine so. The extra lines are simple enough to do and the extra axis can be done by adding a drawing API Y axis to the page.



Richard

Posted by Andrew on 15th August 2016
yeah I still think It will need to be a scatter chart as I want the x-axsis to have an actual scale in minuets.
Posted by Richard on 15th August 2016
Hi there,

Yes - if you want the X axis to have a scale - it will need to be a Scatter chart.


Richard

Add a reply




« Back to message list