actually draw the graph
[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="div_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("div_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 );
37
38 for (var i = 0; i < 2; i++) {
39 var line = document.createElement("div");
40 line.style.width = "100%";
41 line.style.height = "1px";
42 line.style.backgroundColor = "black";
43 line.style.position = "absolute";
44 document.getElementById("div_g").appendChild(line);
45 lines.push(line);
46 }
47
48 xline = document.createElement("div");
49 xline.style.width = "1px";
50 xline.style.height = "100%";
51 xline.style.top = "0px";
52 xline.style.backgroundColor = "black";
53 xline.style.position = "absolute";
54 document.getElementById("div_g").appendChild(xline);
55 </script>
56 </body>
57 </html>