X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-interaction-model.js;h=2af345c7dcf7f4f7fe18d9871dc1db4900bc76af;hb=94647da23ed251ba0f1da8d155d2552680a4e9cf;hp=b1981d77ce9ed2460f063f73e660e4115a97371a;hpb=b04888ccae2e78f4b1113e3904e2828d8dcaed08;p=dygraphs.git diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index b1981d7..2af345c 100644 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@ -63,8 +63,8 @@ Dygraph.Interaction.startPan = function(event, g, context) { var boundedTopY = g.toDomYCoord(yExtremes[0], i) + maxYPixelsToDraw; var boundedBottomY = g.toDomYCoord(yExtremes[1], i) - maxYPixelsToDraw; - var boundedTopValue = g.toDataYCoord(boundedTopY); - var boundedBottomValue = g.toDataYCoord(boundedBottomY); + var boundedTopValue = g.toDataYCoord(boundedTopY, i); + var boundedBottomValue = g.toDataYCoord(boundedBottomY, i); boundedValues[i] = [boundedTopValue, boundedBottomValue]; } @@ -136,12 +136,13 @@ Dygraph.Interaction.movePan = function(event, g, context) { // y-axis scaling is automatic unless this is a full 2D pan. if (context.is2DPan) { + + var pixelsDragged = context.dragEndY - context.dragStartY; + // Adjust each axis appropriately. for (var i = 0; i < g.axes_.length; i++) { var axis = g.axes_[i]; var axis_data = context.axes[i]; - - var pixelsDragged = context.dragEndY - context.dragStartY; var unitsDragged = pixelsDragged * axis_data.unitsPerPixel; var boundedValue = context.boundedValues ? context.boundedValues[i] : null; @@ -349,14 +350,20 @@ Dygraph.Interaction.endZoom = function(event, g, context) { if (regionWidth >= 10 && context.dragDirection == Dygraph.HORIZONTAL) { var left = Math.min(context.dragStartX, context.dragEndX), right = Math.max(context.dragStartX, context.dragEndX); - g.doZoomX_(Math.max(left, plotArea.x), - Math.min(right, plotArea.x + plotArea.w)); + left = Math.max(left, plotArea.x); + right = Math.min(right, plotArea.x + plotArea.w); + if (left < right) { + g.doZoomX_(left, right); + } context.cancelNextDblclick = true; } else if (regionHeight >= 10 && context.dragDirection == Dygraph.VERTICAL) { var top = Math.min(context.dragStartY, context.dragEndY), bottom = Math.max(context.dragStartY, context.dragEndY); - g.doZoomY_(Math.max(top, plotArea.y), - Math.min(bottom, plotArea.y + plotArea.h)); + top = Math.max(top, plotArea.y); + bottom = Math.min(bottom, plotArea.y + plotArea.h); + if (top < bottom) { + g.doZoomY_(top, bottom); + } context.cancelNextDblclick = true; } else { if (context.zoomMoved) g.clearZoomRect_();