1 /*global Gallery,Dygraph,data */
7 title
: "Hover, click and zoom to test the callbacks.",
8 setup
: function(parent
) {
10 "<div id='div_g' style='width:600px; height:300px;'></div>" +
11 "<button id='clear'>Clear list<Button>" +
12 "<input type='checkbox' id='highlight' checked><label for='highlight'> Show 'highlight' events</label>" +
13 "<input type='checkbox' id='unhighlight' checked><label for='unhighlight'>Show 'unhighlight' events</label>" +
14 "<input type='checkbox' id='showLabels' checked>" +
15 "<label for='showLabels'> Show Labels on highlight</label>" +
16 "<div id='status' style='width:100%; height:200px;'></div>";
20 var showLabels
= document
.getElementById('showLabels');
21 showLabels
.onclick
= function() {
22 g
.updateOptions({showLabelsOnHighlight
: showLabels
.checked
});
25 var s
= document
.getElementById("status");
26 var clearStatus
= function() {
29 document
.getElementById('clear').onclick
= clearStatus
;
31 var pts_info
= function(e
, x
, pts
, row
) {
32 var str
= "(" + x
+ ") ";
33 for (var i
= 0; i
< pts
.length
; i
++) {
36 str
+= p
.name
+ ": " + p
.yval
;
41 var dataXY
= g
.toDataCoords(x
, y
);
42 str
+= ", (" + x
+ ", " + y
+ ")";
43 str
+= " -> (" + dataXY
[0] + ", " + dataXY
[1] + ")";
50 document
.getElementById("div_g"),
56 highlightCallback
: function(e
, x
, pts
, row
) {
57 if (document
.getElementById('highlight').checked
) {
58 s
.innerHTML
+= "<b>Highlight</b> " + pts_info(e,x,pts,row) + "<br/>";
62 unhighlightCallback
: function(e
) {
63 if (document
.getElementById('unhighlight').checked
) {
64 s
.innerHTML
+= "<b>Unhighlight</b><br/>";
68 clickCallback
: function(e
, x
, pts
) {
69 s
.innerHTML
+= "<b>Click</b> " + pts_info(e,x,pts) + "<br/>";
72 pointClickCallback
: function(e
, p
) {
73 s
.innerHTML
+= "<b>Point Click</b> " + p.name + ": " + p.x + "<br/>";
76 zoomCallback
: function(minX
, maxX
, yRanges
) {
77 s
.innerHTML
+= "<b>Zoom</b> [" + minX + ", " + maxX + ", [" + yRanges + "]]<br/>";
80 drawCallback
: function(g
) {
81 s
.innerHTML
+= "<b>Draw</b> [" + g.xAxisRange() + "]<br/>";