X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=plugins%2Frange-selector.js;h=399ed3929d31d5d2ba588a686d9a4c4cf14b869d;hb=4731ec3a0b60f81e8ef26fc95a69b9751069686b;hp=88425461a59a41fc6ade35b2631bd37cc3b71d1c;hpb=8a68db7d96431554122d0ffc0356cc6aa2e6b822;p=dygraphs.git diff --git a/plugins/range-selector.js b/plugins/range-selector.js index 8842546..399ed39 100644 --- a/plugins/range-selector.js +++ b/plugins/range-selector.js @@ -12,7 +12,6 @@ Dygraph.Plugins.RangeSelector = (function() { -/*jshint globalstrict: true */ /*global Dygraph:false */ "use strict"; @@ -57,7 +56,7 @@ rangeSelector.prototype.getOption_ = function(name, opt_series) { }; rangeSelector.prototype.setDefaultOption_ = function(name, value) { - return this.dygraph_.attrs_[name] = value; + this.dygraph_.attrs_[name] = value; }; /** @@ -166,13 +165,19 @@ rangeSelector.prototype.updateVisibility_ = function() { * Resizes the range selector. */ rangeSelector.prototype.resize_ = function() { - function setElementRect(canvas, rect) { + function setElementRect(canvas, context, rect) { + var canvasScale = Dygraph.getContextPixelRatio(context); + canvas.style.top = rect.y + 'px'; canvas.style.left = rect.x + 'px'; - canvas.width = rect.w; - canvas.height = rect.h; - canvas.style.width = canvas.width + 'px'; // for IE - canvas.style.height = canvas.height + 'px'; // for IE + canvas.width = rect.w * canvasScale; + canvas.height = rect.h * canvasScale; + canvas.style.width = rect.w + 'px'; + canvas.style.height = rect.h + 'px'; + + if(canvasScale != 1) { + context.scale(canvasScale, canvasScale); + } } var plotArea = this.dygraph_.layout_.getPlotArea(); @@ -188,8 +193,8 @@ rangeSelector.prototype.resize_ = function() { h: this.getOption_('rangeSelectorHeight') }; - setElementRect(this.bgcanvas_, this.canvasRect_); - setElementRect(this.fgcanvas_, this.canvasRect_); + setElementRect(this.bgcanvas_, this.bgcanvas_ctx_, this.canvasRect_); + setElementRect(this.fgcanvas_, this.fgcanvas_ctx_, this.canvasRect_); }; /** @@ -594,6 +599,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);