X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=src%2Fplugins%2Frange-selector.js;h=c1f70f9656baeb77f6da75c86cfa6b00954960f2;hb=64f1c4dfd7425931fcd1bd9949157c0ba6958656;hp=2090fae42facc32021cd5c9f55e3ac74722448b0;hpb=6ecc073934b76e5076f917112a24ff7094857730;p=dygraphs.git diff --git a/src/plugins/range-selector.js b/src/plugins/range-selector.js index 2090fae..c1f70f9 100644 --- a/src/plugins/range-selector.js +++ b/src/plugins/range-selector.js @@ -15,6 +15,7 @@ import * as utils from '../dygraph-utils'; import DygraphInteraction from '../dygraph-interaction-model'; +import IFrameTarp from '../iframe-tarp'; var rangeSelector = function() { this.hasTouchInterface_ = typeof(TouchEvent) != 'undefined'; @@ -160,8 +161,8 @@ rangeSelector.prototype.updateVisibility_ = function() { * Resizes the range selector. */ rangeSelector.prototype.resize_ = function() { - function setElementRect(canvas, context, rect) { - var canvasScale = utils.getContextPixelRatio(context); + function setElementRect(canvas, context, rect, pixelRatioOption) { + var canvasScale = pixelRatioOption || utils.getContextPixelRatio(context); canvas.style.top = rect.y + 'px'; canvas.style.left = rect.x + 'px'; @@ -188,8 +189,9 @@ rangeSelector.prototype.resize_ = function() { h: this.getOption_('rangeSelectorHeight') }; - setElementRect(this.bgcanvas_, this.bgcanvas_ctx_, this.canvasRect_); - setElementRect(this.fgcanvas_, this.fgcanvas_ctx_, this.canvasRect_); + var pixelRatioOption = this.dygraph_.getNumericOption('pixelRatio'); + setElementRect(this.bgcanvas_, this.bgcanvas_ctx_, this.canvasRect_, pixelRatioOption); + setElementRect(this.fgcanvas_, this.fgcanvas_ctx_, this.canvasRect_, pixelRatioOption); }; /** @@ -256,7 +258,7 @@ rangeSelector.prototype.initInteraction_ = function() { // We cover iframes during mouse interactions. See comments in // dygraph-utils.js for more info on why this is a good idea. - var tarp = new utils.IFrameTarp(); + var tarp = new IFrameTarp(); // functions, defined below. Defining them this way (rather than with // "function foo() {...}" makes JSHint happy. @@ -634,13 +636,23 @@ rangeSelector.prototype.computeCombinedSeriesAndLimits_ = function() { var labels = g.getLabels(); var includeSeries = new Array(numColumns); var anySet = false; + var visibility = g.visibility(); + var inclusion = []; + for (i = 1; i < numColumns; i++) { var include = this.getOption_('showInRangeSelector', labels[i]); - includeSeries[i] = include; + inclusion.push(include); if (include !== null) anySet = true; // it's set explicitly for this series } - if (!anySet) { - for (i = 0; i < includeSeries.length; i++) includeSeries[i] = true; + + if (anySet) { + for (i = 1; i < numColumns; i++) { + includeSeries[i] = inclusion[i - 1]; + } + } else { + for (i = 1; i < numColumns; i++) { + includeSeries[i] = visibility[i - 1]; + } } // Create a combined series (average of selected series values).