fix color-visibility test
[dygraphs.git] / tests / crosshair.html
1 <html>
2 <head>
3 <title>crosshairs</title>
4 <!--[if IE]>
5 <script type="text/javascript" src="../excanvas.js"></script>
6 <![endif]-->
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 </head>
13 <body>
14 <p>Hover, click and zoom to test the callbacks:</p>
15 <div id="div_g" style="width:600px; height:300px; position:relative;">
16 </div>
17
18 <script type="text/javascript">
19 var lines = [];
20 var xline;
21 g = new Dygraph(
22 document.getElementById("div_g"),
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;
31 lines[i].style.display = "";
32 lines[i].style.top = y + "px";
33 if (i == 0) xline.style.left = pts[i].canvasx + "px";
34 }
35 xline.style.display = "";
36 },
37
38 unhighlightCallback: function(e) {
39 for (var i = 0; i < 2; i++) {
40 lines[i].style.display = "none";
41 }
42 xline.style.display = "none";
43 }
44 }
45 );
46
47 for (var i = 0; i < 2; i++) {
48 var line = document.createElement("div");
49 line.style.display = "none";
50 line.style.width = "100%";
51 line.style.height = "1px";
52 line.style.backgroundColor = "black";
53 line.style.position = "absolute";
54 document.getElementById("div_g").appendChild(line);
55 lines.push(line);
56 }
57
58 xline = document.createElement("div");
59 xline.style.display = "none";
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";
65 document.getElementById("div_g").appendChild(xline);
66 </script>
67 </body>
68 </html>