X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=plugins%2Frange-selector.js;h=399ed3929d31d5d2ba588a686d9a4c4cf14b869d;hb=4a401b38137b4c4bd09dff59dafb4665874274f4;hp=d8a3c7aa83b4fd9acfb1a39f88afc0693a9ecca3;hpb=5575fa3660cca92dd0564ac3647e3440fb0a0c07;p=dygraphs.git diff --git a/plugins/range-selector.js b/plugins/range-selector.js index d8a3c7a..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; }; /** @@ -74,7 +73,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); } @@ -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_); }; /** @@ -544,7 +549,7 @@ rangeSelector.prototype.drawStaticLayer_ = function() { try { this.drawMiniPlot_(); } catch(ex) { - Dygraph.warn(ex); + console.warn(ex); } var margin = 0.5; @@ -597,7 +602,7 @@ rangeSelector.prototype.drawMiniPlot_ = function() { // Skip points that don't change the x-value. Overly fine-grained points // can cause major slowdowns with the ctx.fill() call below. - if (prevX !== null && Math.round(x) == Math.round(prevX)) { + if (!stepPlot && prevX !== null && Math.round(x) == Math.round(prevX)) { continue; }