From: Dan Vanderkam Date: Mon, 1 Jul 2013 03:10:04 +0000 (-0400) Subject: hairlines hide when they go off the chart X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=7c1a1085f9f0cc32ad786faa84f64e34c9d86366;p=dygraphs.git hairlines hide when they go off the chart --- 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); }); };