0
votes

In Highchats.com Dynamic update showed two ways to calculate time in her examples (http://www.highcharts.com/demo/dynamic-update) and (http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/dynamic-update/).

1: On series, the time is calculate this way:

time = (new Date()).getTime();
...
x: time + i * 1000, //Multiplying by 1000 (mileseconds)

2: But on Event load setInterval() it's calculated in the other diferente way:

x = (new Date()).getTime(), //Without multiplying by 1000.

Why this difference?

1

1 Answers

1
votes

They aren't multiplying time by 1000. They are multiplying i by 1000 and adding it to time. i goes from -19 to 0. So they get 20 points, each one second apart before the current time.

They could have also done:

for (i = -19000; i <= 0; i += 1000) {
    data.push({
       x: time + i,
       y: Math.random()
    });
}