Periodically update graph

56 views
Skip to first unread message

Sunny Shah

unread,
Jun 11, 2012, 6:03:22 AM6/11/12
to Google Visualization API
have a page where i keep getting data from a database periodically.
That data is depicted as a graph. At each period, i want to update the
graph with new data. Meaning that i dont want to replace the old
graph, but extend it. For example,im using a line chart which is
currently displaying. When new data comes in, i want the lines in the
chart to extend to represent the new data, but the previous lines
should remain as-is. Any idea on how to do this using the Charts API ?

asgallant

unread,
Jun 11, 2012, 11:51:46 AM6/11/12
to google-visua...@googlegroups.com
How you do this depends on what you get from the new incoming data.  If your new data contains all of the old data, then you can replace the DataTable used to draw the chart and redraw.  If the incoming data is entirely new, then you need to add it to the existing DataTable and redraw the chart.  If you have some overlap (say, you fetch the past 5 minutes of data once per minute), then you'll have to parse the incoming data to get only the new stuff, append it to the DataTable, and redraw the chart.

You can search this forum for examples of updating chart data.
Reply all
Reply to author
Forward
0 new messages