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