Track code size on PRs
[dygraphs.git] / tests / dynamic-update.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Live random data</title>
5 <!--
6 For production (minified) code, use:
7 <script type="text/javascript" src="dygraph-combined.js"></script>
8 -->
9 <script type="text/javascript" src="../dygraph-dev.js"></script>
10
11 </head>
12 <body>
13 <h3 style="width:800px; text-align: center;">Live random data</h3>
14 <div id="div_g" style="width:800px; height:400px;"></div>
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>
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>
44 </body>
45 </html>