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