Commit | Line | Data |
---|---|---|
b258a3da DV |
1 | <html> |
2 | <head> | |
3 | <title>callbacks</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 | <script type="text/javascript" src="data.js"></script> | |
11 | </head> | |
12 | <body> | |
13 | <p>Hover, click and zoom to test the callbacks:</p> | |
d16579a0 | 14 | <div id="div_g" style="width:600px; height:300px;"></div> |
b258a3da DV |
15 | |
16 | <div id="status" style="width:100%; height:200px;"></div> | |
17 | ||
18 | <script type="text/javascript"> | |
19 | s = document.getElementById("status"); | |
20 | pts_info = function(x, pts) { | |
21 | var str = "(" + x + ") "; | |
22 | for (var i = 0; i < pts.length; i++) { | |
23 | var p = pts[i]; | |
24 | if (i) str += ", "; | |
25 | str += p.name + ": " + p.xval + ", " + p.yval; | |
26 | } | |
27 | return str; | |
28 | }; | |
29 | ||
30 | g = new Dygraph( | |
d16579a0 | 31 | document.getElementById("div_g"), |
b258a3da DV |
32 | NoisyData, { |
33 | rollPeriod: 7, | |
34 | showRoller: true, | |
35 | errorBars: true, | |
36 | ||
37 | highlightCallback: function(e, x, pts) { | |
38 | s.innerHTML += "<b>Highlight</b> " + pts_info(x,pts) + "<br/>"; | |
39 | }, | |
40 | ||
41 | clickCallback: function(e, x, pts) { | |
42 | s.innerHTML += "<b>Click</b> " + pts_info(x,pts) + "<br/>"; | |
43 | }, | |
44 | ||
45 | zoomCallback: function(minX, maxX) { | |
46 | s.innerHTML += "<b>Zoom</b> [" + minX + ", " + maxX + "]<br/>"; | |
47 | } | |
48 | } | |
49 | ); | |
50 | </script> | |
51 | </body> | |
52 | </html> |