From 7c1a1085f9f0cc32ad786faa84f64e34c9d86366 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 30 Jun 2013 23:10:04 -0400 Subject: [PATCH] hairlines hide when they go off the chart --- extras/hairlines.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extras/hairlines.js b/extras/hairlines.js index 2d72036..0a4cd40 100644 --- a/extras/hairlines.js +++ b/extras/hairlines.js @@ -155,6 +155,7 @@ hairlines.prototype.moveHairlineToTop = function(h) { hairlines.prototype.updateHairlineDivPositions = function() { var g = this.dygraph_; var layout = this.dygraph_.getArea(); + var chartLeft = layout.x, chartRight = layout.x + layout.w; var div = this.dygraph_.graphDiv; var box = [layout.x + Dygraph.findPosX(div), layout.y + Dygraph.findPosY(div)]; @@ -173,6 +174,9 @@ hairlines.prototype.updateHairlineDivPositions = function() { 'left': left + 'px', 'top': layout.y + 'px', }).draggable("option", "containment", box); + + var visible = (left >= chartLeft && left <= chartRight); + $([h.infoDiv, h.lineDiv]).toggle(visible); }); }; -- 2.7.4