crosshairs demo
authorDan Vanderkam <danvdk@gmail.com>
Tue, 1 Dec 2009 20:25:57 +0000 (12:25 -0800)
committerDan Vanderkam <danvdk@gmail.com>
Tue, 1 Dec 2009 20:25:57 +0000 (12:25 -0800)
tests/crosshair.html [new file with mode: 0644]

diff --git a/tests/crosshair.html b/tests/crosshair.html
new file mode 100644 (file)
index 0000000..4dbadc8
--- /dev/null
@@ -0,0 +1,65 @@
+<html>
+  <head>
+    <title>crosshairs</title>
+    <!--[if IE]>
+    <script type="text/javascript" src="excanvas.js"></script>
+    <![endif]-->
+    <script type="text/javascript" src="../dygraph-combined.js"></script>
+    <script type="text/javascript" src="../dygraph-canvas.js"></script>
+    <script type="text/javascript" src="../dygraph.js"></script>
+    <script type="text/javascript" src="data.js"></script>
+  </head>
+  <body>
+    <p>Hover, click and zoom to test the callbacks:</p>
+    <div id="g" style="width:600px; height:300px; position:relative;">
+    </div>
+
+    <script type="text/javascript">
+      var lines = [];
+      var xline;
+      g = new Dygraph(
+            document.getElementById("g"),
+            NoisyData, {
+              rollPeriod: 7,
+              showRoller: true,
+              errorBars: true,
+
+              highlightCallback: function(e, x, pts) {
+                for (var i = 0; i < pts.length; i++) {
+                  var y = pts[i].canvasy;
+                  lines[i].style.top = y + "px";
+                  if (i == 0) xline.style.left = pts[i].canvasx + "px";
+                }
+
+              },
+
+              // clickCallback: function(e, x, pts) {
+              //   s.innerHTML += "<b>Click</b> " + pts_info(x,pts) + "<br/>";
+              // },
+
+              // zoomCallback: function(minX, maxX) {
+              //   s.innerHTML += "<b>Zoom</b> [" + minX + ", " + maxX + "]<br/>";
+              // }
+            }
+          );
+
+      for (var i = 0; i < 2; i++) {
+        var line = document.createElement("div");
+        line.style.width = "100%";
+        line.style.height = "1px";
+        line.style.backgroundColor = "black";
+        line.style.position = "absolute";
+        document.getElementById("g").appendChild(line);
+        lines.push(line);
+      }
+
+      xline = document.createElement("div");
+      xline.style.width = "1px";
+      xline.style.height = "100%";
+      xline.style.top = "0px";
+      xline.style.backgroundColor = "black";
+      xline.style.position = "absolute";
+      document.getElementById("g").appendChild(xline);
+    </script>
+  </body>
+</html>