Fix and regression test for fast proxy artifacts.
[dygraphs.git] / tests / crosshair.html
CommitLineData
f18fd545
DV
1<!DOCTYPE html>
2<html>
3 <head>
f18fd545 4 <title>crosshairs</title>
f18fd545
DV
5 <!--
6 For production (minified) code, use:
7 <script type="text/javascript" src="dygraph-combined.js"></script>
8 -->
9 <script type="text/javascript" src="../dygraph-dev.js"></script>
10
11 <script type="text/javascript" src="data.js"></script>
2eac5b0e
DV
12 <style type="text/css">
13 .line {
14 visibility: hidden;
15 background-color: black;
16 position: absolute;
17 pointer-events: none; /* let mouse events fall through to the chart */
18 }
19 .yline {
20 width: 100%;
21 height: 1px;
22 }
23 .xline {
24 height: 100%;
25 width: 1px;
26 }
27 </style>
f18fd545
DV
28 </head>
29 <body>
30 <p>Hover, click and zoom to test the callbacks:</p>
31 <div id="div_g" style="width:600px; height:300px; position:relative;">
32 </div>
33
34 <script type="text/javascript">
35 var lines = [];
36 var xline;
37 g = new Dygraph(
38 document.getElementById("div_g"),
39 NoisyData, {
40 rollPeriod: 7,
41 showRoller: true,
42 errorBars: true,
43
44 highlightCallback: function(e, x, pts) {
45 for (var i = 0; i < pts.length; i++) {
46 var y = pts[i].canvasy;
2eac5b0e 47 lines[i].style.visibility = "visible";
f18fd545
DV
48 lines[i].style.top = y + "px";
49 if (i == 0) xline.style.left = pts[i].canvasx + "px";
50 }
2eac5b0e 51 xline.style.visibility = "visible";
f18fd545
DV
52 },
53
54 unhighlightCallback: function(e) {
55 for (var i = 0; i < 2; i++) {
2eac5b0e 56 lines[i].style.visibility = "hidden";
f18fd545 57 }
2eac5b0e 58 xline.style.visibility = "hidden";
f18fd545
DV
59 }
60 }
61 );
62
63 for (var i = 0; i < 2; i++) {
64 var line = document.createElement("div");
2eac5b0e 65 line.className = "line yline";
f18fd545
DV
66 document.getElementById("div_g").appendChild(line);
67 lines.push(line);
68 }
69
70 xline = document.createElement("div");
2eac5b0e 71 xline.className = "line xline";
f18fd545 72 xline.style.top = "0px";
f18fd545
DV
73 document.getElementById("div_g").appendChild(xline);
74 </script>
75 </body>
76</html>