Commit | Line | Data |
---|---|---|
22587203 DV |
1 | <html> |
2 | <head> | |
3 | <title>crosshairs</title> | |
4 | <!--[if IE]> | |
5 | <script type="text/javascript" src="excanvas.js"></script> | |
6 | <![endif]--> | |
d37dca40 DV |
7 | <script type="text/javascript" src="../strftime/strftime-min.js"></script> |
8 | <script type="text/javascript" src="../rgbcolor/rgbcolor.js"></script> | |
22587203 DV |
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 | </head> | |
13 | <body> | |
14 | <p>Hover, click and zoom to test the callbacks:</p> | |
d16579a0 | 15 | <div id="div_g" style="width:600px; height:300px; position:relative;"> |
22587203 DV |
16 | </div> |
17 | ||
18 | <script type="text/javascript"> | |
19 | var lines = []; | |
20 | var xline; | |
21 | g = new Dygraph( | |
d16579a0 | 22 | document.getElementById("div_g"), |
22587203 DV |
23 | NoisyData, { |
24 | rollPeriod: 7, | |
25 | showRoller: true, | |
26 | errorBars: true, | |
27 | ||
28 | highlightCallback: function(e, x, pts) { | |
29 | for (var i = 0; i < pts.length; i++) { | |
30 | var y = pts[i].canvasy; | |
a4c6a67c | 31 | lines[i].style.display = ""; |
22587203 DV |
32 | lines[i].style.top = y + "px"; |
33 | if (i == 0) xline.style.left = pts[i].canvasx + "px"; | |
34 | } | |
a4c6a67c AV |
35 | xline.style.display = ""; |
36 | }, | |
22587203 | 37 | |
a4c6a67c AV |
38 | unhighlightCallback: function(e) { |
39 | for (var i = 0; i < 2; i++) { | |
40 | lines[i].style.display = "none"; | |
41 | } | |
42 | xline.style.display = "none"; | |
d16579a0 | 43 | } |
22587203 DV |
44 | } |
45 | ); | |
46 | ||
47 | for (var i = 0; i < 2; i++) { | |
48 | var line = document.createElement("div"); | |
a4c6a67c | 49 | line.style.display = "none"; |
22587203 DV |
50 | line.style.width = "100%"; |
51 | line.style.height = "1px"; | |
52 | line.style.backgroundColor = "black"; | |
53 | line.style.position = "absolute"; | |
d16579a0 | 54 | document.getElementById("div_g").appendChild(line); |
22587203 DV |
55 | lines.push(line); |
56 | } | |
57 | ||
58 | xline = document.createElement("div"); | |
a4c6a67c | 59 | xline.style.display = "none"; |
22587203 DV |
60 | xline.style.width = "1px"; |
61 | xline.style.height = "100%"; | |
62 | xline.style.top = "0px"; | |
63 | xline.style.backgroundColor = "black"; | |
64 | xline.style.position = "absolute"; | |
d16579a0 | 65 | document.getElementById("div_g").appendChild(xline); |
22587203 DV |
66 | </script> |
67 | </body> | |
68 | </html> |