Update data using an AJAX call in the line-pink-and-blue.html demo

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 hardeep on 22nd September 2015
want to do same code for line-pink-and-blue.html as done in this example www.rgraph.net/docs/howto-using-ajax.html

i try to implement this code but its not showing anything on the webpage.

can u please tell me the modified code for the ajax update on this graph.
Posted by Richard Heyes on 22nd September 2015
Hi there,

Put your code to create your chart in a function (eg called myFunction() ) and then use this as your window.onload function:



     function myCallback (data)
     {
         // Reset the canvas
         RGraph.reset(document.getElementById('cvs'));


         /**
         * Create the chart
         */
         var myChart = new RGraph.Line({
             id: 'cvs',
             data: data,
             options: {
             }
         }).draw();
     }



window.onload = function ()
{
     RGraph.AJAX.getCSV('/getdata.html', myCallback);

     // 2000 milliseconds = 2 seconds
     setTimeout(window.onload, 2000);
}



Richard
If RGraph has helped you - please share the website and give your feedback - thanks!
Posted by hardeep on 23rd September 2015
code written in the function is not working

  function myCallback (data)
      {
          alert(data);
          // Reset the canvas
          RGraph.reset(document.getElementById('cvs'));


          /**
          * Create the chart
          */
          var myChart = new RGraph.Line({
              id: 'cvs',
              data: data,
              options: {
              }
          }).draw();
      }

i used alerts even that is not working
Posted by Richard on 23rd September 2015
Hi,

Can you send me a link to the page please.


Richard

Add a reply




« Back to message list