3 <title>callbacks
</title>
5 <script type=
"text/javascript" src=
"excanvas.js"></script>
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 <style type=
"text/css">
24 <p>Hover, click and zoom to test the callbacks:
</p>
25 <div id=
"div_g" style=
"width:600px; height:300px;"></div>
27 <input type=
"button" value=
"Clear list" onclick=
"javascript:document.getElementById('status').innerHTML=''" />
28 <input type=
"checkbox" id=
"highlight" checked
><label for=
"highlight"> Show 'highlight' events
</label>
29 <div id=
"status" style=
"width:100%; height:200px;"></div>
31 <script type=
"text/javascript">
32 s = document.getElementById(
"status");
34 pts_info = function(e, x, pts) {
35 var str =
"(" + x +
") ";
36 for (var i =
0; i < pts.length; i++) {
39 str += p.name +
": " + p.yval;
44 var dataXY = g.toDataCoords(x, y);
45 str +=
", (" + x +
", " + y +
")";
46 str +=
" -> (" + dataXY[
0] +
", " + dataXY[
1] +
")";
52 document.getElementById(
"div_g"),
58 highlightCallback: function(e, x, pts) {
59 if (document.getElementById('highlight').checked) {
60 s.innerHTML +=
"<b>Highlight</b> " + pts_info(e,x,pts) +
"<br/>";
64 clickCallback: function(e, x, pts) {
65 s.innerHTML +=
"<b>Click</b> " + pts_info(e,x,pts) +
"<br/>";
68 zoomCallback: function(minX, maxX) {
69 s.innerHTML +=
"<b>Zoom</b> [" + minX +
", " + maxX +
"]<br/>";
72 drawCallback: function(g) {
73 s.innerHTML +=
"<b>Draw</b> [" + g.xAxisRange() +
"]<br/>";