jQWidgets Forums

jQuery UI Widgets Forums Chart chart refresh

This topic contains 0 replies, has 1 voice, and was last updated by  jb 12 years, 1 month ago.

Viewing 1 post (of 1 total)
  • Author
  • chart refresh #19558

    jb
    Participant

    Hi! Let’s use the “javascript_chart_line_series.htm” example.  What I’m trying to do is refresh the graph automatically every 5 seconds. From a server perspective, the content of the csv file (in this instance “../sampledata/nasdaq_vs_sp500.txt”) changes frequently.  I’m trying to use the “resfresh” method, but it seems like the csv binding doesn’t kick in, even if the file content changes.  I added 2 things to the “javascript_chart_line_series.htm” example . In the <head> portion:

    <script type=”text/javascript”>

    refreshChart = function() { $(‘#jqxChart’).jqxChart(‘refresh’); }

    </script>

     and this in the “body”

    <body class=’default’ onload=”window.setInterval(refreshChart, 5000);”>

      The graph is refreshed indeed, but the data within isn’t…  Any suggestions?

    <EDITED>

    I found a way to make this work.. writing it here for benefits of other users..

    I changed the content of the “head” portion javascript for this:

    <script type=”text/javascript”>
     refreshChart = function () {
      var source =
                {
                    datatype: “csv”,
                    datafields: [
                        { name: ‘Date’ },
                        { name: ‘S&P 500’ },
                        { name: ‘NASDAQ’ }
                    ],
                    url: ‘../sampledata/nasdaq_vs_sp500.txt’
                };

      var dataAdapter = new $.jqx.dataAdapter(source, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert(‘Error loading “‘ + source.url + ‘” : ‘ + error); } });
      $(‘#jqxChart’).jqxChart({source: dataAdapter});
      $(‘#jqxChart’).jqxChart(‘refresh’);
     }
    </script>

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.