From: Petr Shevtsov Date: Thu, 13 Nov 2014 15:02:29 +0000 (+0300) Subject: Check for visible viewport width, not the plotter width X-Git-Tag: v1.1.0~12^2~1^2~1 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=d6eb5c59dcbc22c942a266b57e95d3111db6fcae;p=dygraphs.git Check for visible viewport width, not the plotter width --- diff --git a/plugins/legend.js b/plugins/legend.js index 90803f6..3349969 100644 --- a/plugins/legend.js +++ b/plugins/legend.js @@ -128,7 +128,7 @@ legend.prototype.select = function(e) { var xValue = e.selectedX; var points = e.selectedPoints; - if(e.dygraph.getOption("legendFollow")) { + if (e.dygraph.getOption("legendFollow")) { // create floating legend div var area = e.dygraph.plotter_.area; var labelsDivWidth = e.dygraph.getOption("labelsDivWidth"); @@ -142,8 +142,8 @@ legend.prototype.select = function(e) { // if legend floats to end of the plotting area, it flips to the other // side of the selection point - if((leftLegend + labelsDivWidth + 1) > area.w) { - leftLegend = leftLegend - 2*20 - labelsDivWidth - (yAxisLabelWidth - area.x); + if ((leftLegend + labelsDivWidth + 1) > (window.scrollX + window.innerWidth)) { + leftLegend = leftLegend - 2 * 20 - labelsDivWidth - (yAxisLabelWidth - area.x); } e.dygraph.graphDiv.appendChild(this.legend_div_);