4 <meta http-equiv=
"X-UA-Compatible" content=
"IE=EmulateIE7; IE=EmulateIE9">
5 <title>callbacks
</title>
7 <script type=
"text/javascript" src=
"../excanvas.js"></script>
10 For production (minified) code, use:
11 <script type=
"text/javascript" src=
"dygraph-combined.js"></script>
13 <script type=
"text/javascript" src=
"../dygraph-dev.js"></script>
15 <script type=
"text/javascript" src=
"data.js"></script>
16 <style type=
"text/css">
29 <p>Hover, click and zoom to test the callbacks:
</p>
30 <div id=
"div_g" style=
"width:600px; height:300px;"></div>
32 <input type=
"button" value=
"Clear list" onclick=
"javascript:document.getElementById('status').innerHTML=''" />
33 <input type=
"checkbox" id=
"highlight" checked
><label for=
"highlight"> Show 'highlight' events
</label>
34 <input type=
"checkbox" id=
"unhighlight" checked
><label for=
"unhighlight">Show 'unhighlight' events
</label>
35 <input type=
"checkbox" id=
"showLabels" checked
36 onclick='g.updateOptions({showLabelsOnHighlight: this.checked});'
>
37 <label for=
"showLabels"> Show Labels on highlight
</label>
38 <div id=
"status" style=
"width:100%; height:200px;"></div>
40 <script type=
"text/javascript">
41 s = document.getElementById(
"status");
43 pts_info = function(e, x, pts, row) {
44 var str =
"(" + x +
") ";
45 for (var i =
0; i < pts.length; i++) {
48 str += p.name +
": " + p.yval;
53 var dataXY = g.toDataCoords(x, y);
54 str +=
", (" + x +
", " + y +
")";
55 str +=
" -> (" + dataXY[
0] +
", " + dataXY[
1] +
")";
62 document.getElementById(
"div_g"),
68 highlightCallback: function(e, x, pts, row) {
69 if (document.getElementById('highlight').checked) {
70 s.innerHTML +=
"<b>Highlight</b> " + pts_info(e,x,pts,row) +
"<br/>";
74 unhighlightCallback: function(e) {
75 if (document.getElementById('unhighlight').checked) {
76 s.innerHTML +=
"<b>Unhighlight</b><br/>";
80 clickCallback: function(e, x, pts) {
81 s.innerHTML +=
"<b>Click</b> " + pts_info(e,x,pts) +
"<br/>";
84 pointClickCallback: function(e, p) {
85 s.innerHTML +=
"<b>Point Click</b> " + p.name +
": " + p.x +
"<br/>";
88 zoomCallback: function(minX, maxX, yRanges) {
89 s.innerHTML +=
"<b>Zoom</b> [" + minX +
", " + maxX +
", [" + yRanges +
"]]<br/>";
92 drawCallback: function(g) {
93 s.innerHTML +=
"<b>Draw</b> [" + g.xAxisRange() +
"]<br/>";