X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-range-selector.js;h=b777470e69ad656977b5ec9cf99e2e7d7a49ec65;hb=600da35ccf7fda98f16ba16037c80451ebca9cf5;hp=14048d8f227d4ad4e2eaf71d010220b1e63226c3;hpb=38ad22de8c992203819dfd12c85b373bbdf744c0;p=dygraphs.git diff --git a/dygraph-range-selector.js b/dygraph-range-selector.js index 14048d8..b777470 100644 --- a/dygraph-range-selector.js +++ b/dygraph-range-selector.js @@ -80,7 +80,7 @@ DygraphRangeSelector.prototype.resize_ = function() { } var plotArea = this.layout_.getPlotArea(); - var xAxisLabelHeight = this.attr_('axisLabelFontSize') + 2 * this.attr_('axisTickSize'); + var xAxisLabelHeight = this.attr_('xAxisHeight') || (this.attr_('axisLabelFontSize') + 2 * this.attr_('axisTickSize')); this.canvasRect_ = { x: plotArea.x, y: plotArea.y + plotArea.h + xAxisLabelHeight + 4, @@ -179,6 +179,10 @@ DygraphRangeSelector.prototype.initInteraction_ = function() { var isPanning = false; var dynamic = !this.isMobileDevice_ && !this.isUsingExcanvas_; + // 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 Dygraph.IFrameTarp(); + // functions, defined below. Defining them this way (rather than with // "function foo() {...}" makes JSHint happy. var toXDataWindow, onZoomStart, onZoom, onZoomEnd, doZoom, isMouseInPanZone, @@ -212,6 +216,7 @@ DygraphRangeSelector.prototype.initInteraction_ = function() { self.dygraph_.addEvent(topElem, 'mousemove', onZoom); self.dygraph_.addEvent(topElem, 'mouseup', onZoomEnd); self.fgcanvas_.style.cursor = 'col-resize'; + tarp.cover(); return true; }; @@ -221,7 +226,8 @@ DygraphRangeSelector.prototype.initInteraction_ = function() { } Dygraph.cancelEvent(e); var delX = e.screenX - xLast; - if (Math.abs(delX) < 4 || e.screenX == 0) { // First iPad move event seems to have screenX = 0 + if (Math.abs(delX) < 4 || e.screenX === 0) { + // First iPad move event seems to have screenX = 0 return true; } xLast = e.screenX; @@ -255,6 +261,7 @@ DygraphRangeSelector.prototype.initInteraction_ = function() { return false; } isZooming = false; + tarp.uncover(); Dygraph.removeEvent(topElem, 'mousemove', onZoom); Dygraph.removeEvent(topElem, 'mouseup', onZoomEnd); self.fgcanvas_.style.cursor = 'default'; @@ -473,6 +480,8 @@ DygraphRangeSelector.prototype.drawMiniPlot_ = function() { return; } + var stepPlot = this.attr_('stepPlot'); + var combinedSeriesData = this.computeCombinedSeriesAndLimits_(); var yRange = combinedSeriesData.yMax - combinedSeriesData.yMin; @@ -487,14 +496,36 @@ DygraphRangeSelector.prototype.drawMiniPlot_ = function() { var canvasWidth = this.canvasRect_.w - margin; var canvasHeight = this.canvasRect_.h - margin; + var prevX = null, prevY = null; + ctx.beginPath(); ctx.moveTo(margin, canvasHeight); for (var i = 0; i < combinedSeriesData.data.length; i++) { var dataPoint = combinedSeriesData.data[i]; - var x = (dataPoint[0] - xExtremes[0])*xFact; - var y = canvasHeight - (dataPoint[1] - combinedSeriesData.yMin)*yFact; + var x = ((dataPoint[0] !== null) ? ((dataPoint[0] - xExtremes[0])*xFact) : NaN); + var y = ((dataPoint[1] !== null) ? (canvasHeight - (dataPoint[1] - combinedSeriesData.yMin)*yFact) : NaN); if (isFinite(x) && isFinite(y)) { + if(prevX === null) { + ctx.lineTo(x, canvasHeight); + } + else if (stepPlot) { + ctx.lineTo(x, prevY); + } ctx.lineTo(x, y); + prevX = x; + prevY = y; + } + else { + if(prevX !== null) { + if (stepPlot) { + ctx.lineTo(x, prevY); + ctx.lineTo(x, canvasHeight); + } + else { + ctx.lineTo(prevX, canvasHeight); + } + } + prevX = prevY = null; } } ctx.lineTo(canvasWidth, canvasHeight);