AJAX/PHP/MySQL trend line

Share RGraph:   Share or Like RGraph on Facebook!

« 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 JPL on 14th February 2013
Hello all.

I would like to have an dfynamic refresh on my graph (trend line) like Demos/line07.html from the pack. or www.rgraph.net/docs/updating-charts-dynamically.html

But I'd like to get the data from my SQL database.

I made a first part in php that calls the data to place them into an array $data.
I have the DrawGraph completed like I can find from this site.


         d1 = <?php print($data_string) ?>;
         if (d1.length > 250) {
             d1 = RGraph.array_shift(d1);
         }

         if (document.all && RGraph.isIE8()) {
             alert('[MSIE] Sorry, Internet Explorer 8 is not fast enough to support animated charts');
         } else {
             window.__rgraph_line__.original_data[0] = d1;
             setTimeout(drawGraph, 100);
         }



The Php $data_string is called only once. How can I refresh this?

Many thanks
J.philippe
Posted by RGraph support on 14th February 2013
Hi,

You would need to use AJAX to get new data and then updated your d1 array. Then do a redraw. More on AJAX here:

www.rgraph.net/docs/integration-with-server-side-scripting.html#ajax

There's also a HOWTO guide for updating your chart here:

www.rgraph.net/docs/howto-using-ajax.html

Richard, RGraph Support

Add a reply




« Back to message list