X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=plugins%2Frange-selector.js;h=717f85059442578e9e37a9aafc8cb351bc688938;hb=e8c635cc4e3c265e88f66b46b689e291531330b6;hp=fe32b1a26276bb04a24cf4bae4a5b94a23c6966e;hpb=335011fd4473f55aaaceb69726d15e0063373149;p=dygraphs.git diff --git a/plugins/range-selector.js b/plugins/range-selector.js index fe32b1a..717f850 100644 --- a/plugins/range-selector.js +++ b/plugins/range-selector.js @@ -52,8 +52,8 @@ rangeSelector.prototype.destroy = function() { // Private methods //------------------------------------------------------------------ -rangeSelector.prototype.getOption_ = function(name) { - return this.dygraph_.getOption(name); +rangeSelector.prototype.getOption_ = function(name, opt_series) { + return this.dygraph_.getOption(name, opt_series); }; rangeSelector.prototype.setDefaultOption_ = function(name, value) { @@ -74,7 +74,7 @@ rangeSelector.prototype.createInterface_ = function() { // Range selector and animatedZooms have a bad interaction. See issue 359. if (this.getOption_('animatedZooms')) { - Dygraph.warn('Animated zooms and range selector are not compatible; disabling animatedZooms.'); + console.warn('Animated zooms and range selector are not compatible; disabling animatedZooms.'); this.dygraph_.updateOptions({animatedZooms: false}, true); } @@ -544,7 +544,7 @@ rangeSelector.prototype.drawStaticLayer_ = function() { try { this.drawMiniPlot_(); } catch(ex) { - Dygraph.warn(ex); + console.warn(ex); } var margin = 0.5; @@ -594,6 +594,13 @@ rangeSelector.prototype.drawMiniPlot_ = function() { var dataPoint = combinedSeriesData.data[i]; var x = ((dataPoint[0] !== null) ? ((dataPoint[0] - xExtremes[0])*xFact) : NaN); var y = ((dataPoint[1] !== null) ? (canvasHeight - (dataPoint[1] - combinedSeriesData.yMin)*yFact) : NaN); + + // Skip points that don't change the x-value. Overly fine-grained points + // can cause major slowdowns with the ctx.fill() call below. + if (!stepPlot && prevX !== null && Math.round(x) == Math.round(prevX)) { + continue; + } + if (isFinite(x) && isFinite(y)) { if(prevX === null) { ctx.lineTo(x, canvasHeight); @@ -646,15 +653,29 @@ rangeSelector.prototype.drawMiniPlot_ = function() { rangeSelector.prototype.computeCombinedSeriesAndLimits_ = function() { var g = this.dygraph_; var logscale = this.getOption_('logscale'); - - // Create a combined series (average of all series values). var i; + // Select series to combine. By default, all series are combined. + var numColumns = g.numColumns(); + var labels = g.getLabels(); + var includeSeries = new Array(numColumns); + var anySet = false; + for (i = 1; i < numColumns; i++) { + var include = this.getOption_('showInRangeSelector', labels[i]); + includeSeries[i] = 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; + } + + // Create a combined series (average of selected series values). // TODO(danvk): short-circuit if there's only one series. var rolledSeries = []; var dataHandler = g.dataHandler_; var options = g.attributes_; for (i = 1; i < g.numColumns(); i++) { + if (!includeSeries[i]) continue; var series = dataHandler.extractSeries(g.rawData_, i, options); if (g.rollPeriod() > 1) { series = dataHandler.rollingAverage(series, g.rollPeriod(), options);