+<!DOCTYPE html>
<html>
<head>
+ <link rel="stylesheet" href="../dist/dygraph.css">
<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="../dist/dygraph.js"></script>
+
+ <script type="text/javascript" src="../src/extras/crosshair.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;">
+ <p>Vertical crosshair:</p>
+ <div id="div_g_v" 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";
- }
+ <p>Horizontal crosshairs:</p>
+ <div id="div_g_h" style="width:600px; height:300px; position:relative;">
+ </div>
- },
+ <p>Both crosshairs:</p>
+ <div id="div_g_b" style="width:600px; height:300px; position:relative;">
+ </div>
- // clickCallback: function(e, x, pts) {
- // s.innerHTML += "<b>Click</b> " + pts_info(x,pts) + "<br/>";
- // },
+ <script type="text/javascript">
+ gv = new Dygraph(
+ document.getElementById("div_g_v"),
+ NoisyData,
+ {
+ rollPeriod: 7,
+ showRoller: true,
+ errorBars: true,
- // zoomCallback: function(minX, maxX) {
- // s.innerHTML += "<b>Zoom</b> [" + minX + ", " + maxX + "]<br/>";
- // }
- }
- );
+ plugins: [
+ new Dygraph.Plugins.Crosshair({
+ direction: "vertical"
+ })
+ ]
+ }
+ );
+ gh = new Dygraph(
+ document.getElementById("div_g_h"),
+ NoisyData, {
+ rollPeriod: 7,
+ showRoller: true,
+ errorBars: true,
- 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);
- }
+ plugins: [
+ new Dygraph.Plugins.Crosshair({
+ direction: "horizontal"
+ })
+ ]
+ }
+ );
+ gb = new Dygraph(
+ document.getElementById("div_g_b"),
+ NoisyData, {
+ rollPeriod: 7,
+ showRoller: true,
+ errorBars: true,
- 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);
+ plugins: [
+ new Dygraph.Plugins.Crosshair({
+ direction: "both"
+ })
+ ]
+ }
+ );
</script>
</body>
</html>