Merge branch 'master' of http://github.com/nealie/dygraphs
[dygraphs.git] / tests / dynamic-update.html
CommitLineData
5e50289f
DV
1<html>
2 <head>
3 <title>Live random data</title>
4 <!--[if IE]>
a2b2c3a1 5 <script type="text/javascript" src="../excanvas.js"></script>
5e50289f 6 <![endif]-->
67b65269
DV
7 <script type="text/javascript" src="../strftime/strftime-min.js"></script>
8 <script type="text/javascript" src="../rgbcolor/rgbcolor.js"></script>
5e50289f
DV
9 <script type="text/javascript" src="../dygraph-canvas.js"></script>
10 <script type="text/javascript" src="../dygraph.js"></script>
11 </head>
12 <body>
970d5441
DV
13 <h3 style="width:800px; text-align: center;">Live random data</h3>
14 <div id="div_g" style="width:800px; height:400px;"></div>
5e50289f
DV
15
16 <script type="text/javascript">
17 var data = [];
18 var t = new Date();
19 for (var i = 10; i >= 0; i--) {
20 var x = new Date(t.getTime() - i * 1000);
21 data.push([x, Math.random()]);
22 }
23
24 var g = new Dygraph(document.getElementById("div_g"), data,
25 {
26 drawPoints: true,
27 showRoller: true,
28 valueRange: [0.0, 1.2],
29 labels: ['Time', 'Random']
30 });
31 setInterval(function() {
32 var x = new Date(); // current time
33 var y = Math.random();
34 data.push([x, y]);
35 g.updateOptions( { 'file': data } );
36 }, 1000);
37
38 </script>
970d5441
DV
39
40 <p>This test is modeled after a <a
41 href="http://www.highcharts.com/demo/?example=dynamic-update&theme=default">highcharts
42 test</a>. New points should appear once per second. Try zooming and
43 panning over to the right edge to watch them show up.</p>
5e50289f
DV
44 </body>
45</html>