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 <input type=
"checkbox" id=
"showLabels" checked
30 onclick='g.updateOptions({showLabelsOnHighlight: this.checked});'
>
31 <label for=
"showLabels"> Show Labels on highlight
</label>
32 <div id=
"status" style=
"width:100%; height:200px;"></div>
34 <script type=
"text/javascript">
35 s = document.getElementById(
"status");
37 pts_info = function(e, x, pts) {
38 var str =
"(" + x +
") ";
39 for (var i =
0; i < pts.length; i++) {
42 str += p.name +
": " + p.yval;
47 var dataXY = g.toDataCoords(x, y);
48 str +=
", (" + x +
", " + y +
")";
49 str +=
" -> (" + dataXY[
0] +
", " + dataXY[
1] +
")";
55 document.getElementById(
"div_g"),
61 highlightCallback: function(e, x, pts) {
62 if (document.getElementById('highlight').checked) {
63 s.innerHTML +=
"<b>Highlight</b> " + pts_info(e,x,pts) +
"<br/>";
67 clickCallback: function(e, x, pts) {
68 s.innerHTML +=
"<b>Click</b> " + pts_info(e,x,pts) +
"<br/>";
71 zoomCallback: function(minX, maxX) {
72 s.innerHTML +=
"<b>Zoom</b> [" + minX +
", " + maxX +
"]<br/>";
75 drawCallback: function(g) {
76 s.innerHTML +=
"<b>Draw</b> [" + g.xAxisRange() +
"]<br/>";