From: Robert Konigsberg Date: Sun, 24 Feb 2013 07:08:43 +0000 (-0500) Subject: Use the correct access when computing bounded y-values for constrained panning. X-Git-Tag: v1.0.0~50^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=f93af875f34cdc7ed523f2545103ef6d6f4a1891;p=dygraphs.git Use the correct access when computing bounded y-values for constrained panning. Dygraphs was computing the second y-axis using extreme range of the first y-axis. This fixes bug 294, setting panEdgeFraction to non-zero breaks secondary y-axis label computation. Also add a minor optimization by moving a computation outside the axis loop. --- diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index 38e63d9..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;