3 <title>callbacks
</title>
5 <script type=
"text/javascript" src=
"../excanvas.js"></script>
7 <script type=
"text/javascript" src=
"../strftime/strftime-min.js"></script>
8 <script type=
"text/javascript" src=
"../rgbcolor/rgbcolor.js"></script>
9 <script type=
"text/javascript" src=
"../dygraph-canvas.js"></script>
10 <script type=
"text/javascript" src=
"../dygraph.js"></script>
11 <script type=
"text/javascript" src=
"data.js"></script>
12 <style type=
"text/css">
25 <p>Hover, click and zoom to test the callbacks:
</p>
26 <div id=
"div_g" style=
"width:600px; height:300px;"></div>
28 <input type=
"button" value=
"Clear list" onclick=
"javascript:document.getElementById('status').innerHTML=''" />
29 <input type=
"checkbox" id=
"highlight" checked
><label for=
"highlight"> Show 'highlight' events
</label>
30 <input type=
"checkbox" id=
"unhighlight" checked
><label for=
"unhighlight">Show 'unhighlight' events
</label>
31 <input type=
"checkbox" id=
"showLabels" checked
32 onclick='g.updateOptions({showLabelsOnHighlight: this.checked});'
>
33 <label for=
"showLabels"> Show Labels on highlight
</label>
34 <div id=
"status" style=
"width:100%; height:200px;"></div>
36 <script type=
"text/javascript">
37 s = document.getElementById(
"status");
39 pts_info = function(e, x, pts) {
40 var str =
"(" + x +
") ";
41 for (var i =
0; i < pts.length; i++) {
44 str += p.name +
": " + p.yval;
49 var dataXY = g.toDataCoords(x, y);
50 str +=
", (" + x +
", " + y +
")";
51 str +=
" -> (" + dataXY[
0] +
", " + dataXY[
1] +
")";
57 document.getElementById(
"div_g"),
63 highlightCallback: function(e, x, pts) {
64 if (document.getElementById('highlight').checked) {
65 s.innerHTML +=
"<b>Highlight</b> " + pts_info(e,x,pts) +
"<br/>";
69 unhighlightCallback: function(e) {
70 if (document.getElementById('unhighlight').checked) {
71 s.innerHTML +=
"<b>Unhighlight</b><br/>";
75 clickCallback: function(e, x, pts) {
76 s.innerHTML +=
"<b>Click</b> " + pts_info(e,x,pts) +
"<br/>";
79 pointClickCallback: function(e, p) {
80 s.innerHTML +=
"<b>Point Click</b> " + p.name +
": " + p.x +
"<br/>";
83 zoomCallback: function(minX, maxX) {
84 s.innerHTML +=
"<b>Zoom</b> [" + minX +
", " + maxX +
"]<br/>";
87 drawCallback: function(g) {
88 s.innerHTML +=
"<b>Draw</b> [" + g.xAxisRange() +
"]<br/>";