real-time graphing using flotr?

27 views
Skip to first unread message

Stephen Bannasch

unread,
Dec 17, 2009, 11:54:19 AM12/17/09
to fl...@googlegroups.com
I'd like to see if I can use flotr to graph real-time data -- for example from a temperature sensor. I'd like the plot to
smoothly extend across the graph canvas as data arrive from the sensor.

I was going to start by looking at the click-event hook example as something somewhat similar.

Al Caughey

unread,
Dec 17, 2009, 1:56:42 PM12/17/09
to fl...@googlegroups.com
I'd suggest
1. put the graph into it's own div (which it probably is already), and
2. use something like prototype's Ajax.PeriodicalUpdater (http://www.prototypejs.org/api/ajax/periodicalUpdater) to redraw the graph within the div

e.g.,
new Ajax.PeriodicalUpdater('graph_div', 'refresh_graph.php', {method: 'get', frequency: 3, decay: 2, evalScripts: true });
graph_div is the id of the div that contains the graph
refresh_graph.php is the URL which aggregates the data for the graph and generates the Javascript to draw the graph
method is the method by which the URL above is called... either 'get' or 'post'
frequency is the frequency with which the URL is called (in the above example, every 3 seconds)
decay is optional... increases the delay (in seconds) between HTTP requests if the data is not changing
evalScripts tells the function to execute the javascript within the HTTP response from the URL

NB - this is a near realtime solution... not actually realtime
I bet with some intelligent use of parameters you could probably extend the graph each call rather than regenerating it entirely.

Hope this helps,

Al

--

You received this message because you are subscribed to the Google Groups "Flotr Javascript Plotting Library" group.
To post to this group, send email to fl...@googlegroups.com.
To unsubscribe from this group, send email to flotr+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flotr?hl=en.



Reply all
Reply to author
Forward
0 new messages