From d6eb5c59dcbc22c942a266b57e95d3111db6fcae Mon Sep 17 00:00:00 2001 From: Petr Shevtsov Date: Thu, 13 Nov 2014 18:02:29 +0300 Subject: [PATCH] Check for visible viewport width, not the plotter width --- plugins/legend.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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_); -- 2.7.4