Auto refresh line chart by getting the data from database.

1,828 views
Skip to first unread message

shub

unread,
Mar 28, 2012, 9:07:54 AM3/28/12
to google-visua...@googlegroups.com
 Hi,

I am working on a line chart which needs to fetch the data from database , and as I am refreshing the chart div after every "n seconds" , I want the chart to be drawn with new data values.

Is this possible.... ??

Please reply, if anyone knows how to resolve this issue....  ?


Thanks in advance.





asgallant

unread,
Mar 28, 2012, 1:40:33 PM3/28/12
to google-visua...@googlegroups.com
You can do this.  Are you using the Visualization Query class to fetch your data, or are you using some other method?  If you are using the Queries, you can use the setRefreshInterval method to set the number of seconds between refreshing the data.  If you use another method (like fetching data from your server using AJAX), you can use the basic javascript setTimeout function to set the refresh interval, or (better, in my humble opinion) use something like jQuery's queue and delay functions to handle the refresh and timing.

shub

unread,
Mar 29, 2012, 3:01:22 AM3/29/12
to google-visua...@googlegroups.com
Hi,

       Thanks for your reply.
       I went through the google visualization query class, but in the documentation it is mentioned to provide an speadsheet UR, that means we have to store/keep updating the spreadshee as our table is updated. Is there any other option to fetch the data from live database and then plotting the graph. I want the graph to load with the new data content from the database if there an update in the database....?

And even, I am using PHP and MYSQL to draw the graph. If you could provide me an example code for doing the same would be really helpful.

Thanks in advance.

asgallant

unread,
Mar 29, 2012, 9:46:20 AM3/29/12
to google-visua...@googlegroups.com
The data source doesn't have to be a Google spreadsheet - they are just one of the options.  There are Java and Python data source libraries available from the Viz API (see http://code.google.com/apis/chart/interactive/docs/dev/implementing_data_source.html) if you want to use those.  If you're more comfortable working in PHP, you can build your own Query-compatible data source, or use standard AJAX to fetch data in JSON format from a script like this: https://groups.google.com/d/msg/google-visualization-api/Gy18YdVSSfQ/tKdtzSfqKlcJ, which you can then feed to a DataTable constructor.
Reply all
Reply to author
Forward
0 new messages