X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=plugins%2Flegend.js;h=3349969b843b9b8430ba00eb200e6e1e99074e8e;hb=d6eb5c59dcbc22c942a266b57e95d3111db6fcae;hp=90803f66a5658919d02b7996fcfdb8b30499210c;hpb=11ce506e365f0dfb3a2b489847b5a24d27fe1f9d;p=dygraphs.git 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_);