score:2

Accepted answer

assuming your test.php will return a single new point on each call, i'd code it like this:

  var chart = null;
  function callajax(){
    $.getjson('test.php', function(data) {
      if (chart === null){ // first call, create the chart
        options.series = data;
        chart = new highcharts.chart(options);
      } else {
        var seriesonenewpoint = data[0].data[0]; // subsequent calls, just get the point and add it
        var seriestwonewpoint = data[1].data[0];
        chart.series[0].addpoint(seriesonenewpoint, false, false); // first false is don't redraw until both series are updated
        chart.series[1].addpoint(seriestwonewpoint, true, false); // second false is don't shift
      }
      settimeout(callajax, 20000);  // queue up next ajax call
    });
  }
  callajax();

here's an example. note, it just draws the same point over and over again.


Related Query

More Query from same tag