crosshairs demo
[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="../dygraph-combined.js"></script>
8 <script type="text/javascript" src="../dygraph-canvas.js"></script>
9 <script type="text/javascript" src="../dygraph.js"></script>
10 <script type="text/javascript" src="data.js"></script>
11 </head>
12 <body>
13 <p>Hover, click and zoom to test the callbacks:</p>
14 <div id="g" style="width:600px; height:300px; position:relative;">
15 </div>
16
17 <script type="text/javascript">
18 var lines = [];
19 var xline;
20 g = new Dygraph(
21 document.getElementById("g"),
22 NoisyData, {
23 rollPeriod: 7,
24 showRoller: true,
25 errorBars: true,
26
27 highlightCallback: function(e, x, pts) {
28 for (var i = 0; i < pts.length; i++) {
29 var y = pts[i].canvasy;
30 lines[i].style.top = y + "px";
31 if (i == 0) xline.style.left = pts[i].canvasx + "px";
32 }
33
34 },
35
36 // clickCallback: function(e, x, pts) {
37 // s.innerHTML += "<b>Click</b> " + pts_info(x,pts) + "<br/>";
38 // },
39
40 // zoomCallback: function(minX, maxX) {
41 // s.innerHTML += "<b>Zoom</b> [" + minX + ", " + maxX + "]<br/>";
42 // }
43 }
44 );
45
46 for (var i = 0; i < 2; i++) {
47 var line = document.createElement("div");
48 line.style.width = "100%";
49 line.style.height = "1px";
50 line.style.backgroundColor = "black";
51 line.style.position = "absolute";
52 document.getElementById("g").appendChild(line);
53 lines.push(line);
54 }
55
56 xline = document.createElement("div");
57 xline.style.width = "1px";
58 xline.style.height = "100%";
59 xline.style.top = "0px";
60 xline.style.backgroundColor = "black";
61 xline.style.position = "absolute";
62 document.getElementById("g").appendChild(xline);
63 </script>
64 </body>
65 </html>