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