From f93af875f34cdc7ed523f2545103ef6d6f4a1891 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Sun, 24 Feb 2013 02:08:43 -0500 Subject: [PATCH] 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. --- dygraph-interaction-model.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; -- 2.7.4