4 name
: 'Dynamic Update',
5 title
: 'Live random data',
6 setup
: function(parent
) {
7 parent
.innerHTML
= "<div id='div_g' style='width:800px; height:400px;'></div>" +
8 "<p>This test is modeled after a " +
9 "<a href='http://www.highcharts.com/demo/?example=dynamic-update&theme=default'>highcharts" +
10 "test</a>. New points should appear once per second. Try zooming and " +
11 "panning over to the right edge to watch them show up.</p>";
16 for (var i
= 10; i
>= 0; i
--) {
17 var x
= new Date(t
.getTime() - i
* 1000);
18 data
.push([x
, Math
.random()]);
21 var g
= new Dygraph(document
.getElementById("div_g"), data
,
25 valueRange
: [0.0, 1.2],
26 labels
: ['Time', 'Random']
28 // It sucks that these things aren't objects, and we need to store state in window.
29 window
.intervalId
= setInterval(function() {
30 var x
= new Date(); // current time
31 var y
= Math
.random();
33 g
.updateOptions( { 'file': data
} );
37 clearInterval(window
.intervalId
);