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 | 15 | |
599fb4ad DV |
16 | <input type="button" value="Clear list" onclick="javascript:document.getElementById('status').innerHTML=''" /> |
17 | <input type="checkbox" id="highlight" checked><label for="highlight"> Show 'highlight' events</label> | |
b258a3da DV |
18 | <div id="status" style="width:100%; height:200px;"></div> |
19 | ||
20 | <script type="text/javascript"> | |
21 | s = document.getElementById("status"); | |
22 | pts_info = function(x, pts) { | |
23 | var str = "(" + x + ") "; | |
24 | for (var i = 0; i < pts.length; i++) { | |
25 | var p = pts[i]; | |
26 | if (i) str += ", "; | |
27 | str += p.name + ": " + p.xval + ", " + p.yval; | |
28 | } | |
29 | return str; | |
30 | }; | |
31 | ||
32 | g = new Dygraph( | |
d16579a0 | 33 | document.getElementById("div_g"), |
b258a3da DV |
34 | NoisyData, { |
35 | rollPeriod: 7, | |
36 | showRoller: true, | |
37 | errorBars: true, | |
38 | ||
39 | highlightCallback: function(e, x, pts) { | |
599fb4ad DV |
40 | if (document.getElementById('highlight').checked) { |
41 | s.innerHTML += "<b>Highlight</b> " + pts_info(x,pts) + "<br/>"; | |
42 | } | |
b258a3da DV |
43 | }, |
44 | ||
45 | clickCallback: function(e, x, pts) { | |
46 | s.innerHTML += "<b>Click</b> " + pts_info(x,pts) + "<br/>"; | |
47 | }, | |
48 | ||
49 | zoomCallback: function(minX, maxX) { | |
50 | s.innerHTML += "<b>Zoom</b> [" + minX + ", " + maxX + "]<br/>"; | |
599fb4ad DV |
51 | }, |
52 | ||
53 | drawCallback: function(g) { | |
54 | s.innerHTML += "<b>Draw</b> [" + g.xAxisRange() + "]<br/>"; | |
b258a3da DV |
55 | } |
56 | } | |
57 | ); | |
58 | </script> | |
59 | </body> | |
60 | </html> |