X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=dygraph-interaction-model.js;h=27c18b79519792c15f4ea99029bf2089edd80b13;hb=33b5c4b245bf29f3e908931bf70dde00b5fc8a51;hp=75ee78f13a59a2a18ce4cfbcf866d5cc8725ec88;hpb=806f92c1e4f78e75fae857ccfad3276fd5524ac6;p=dygraphs.git diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index 75ee78f..27c18b7 100644 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@ -38,8 +38,14 @@ Dygraph.Interaction.startPan = function(event, g, context) { var i, axis; context.isPanning = true; var xRange = g.xAxisRange(); - context.dateRange = xRange[1] - xRange[0]; - context.initialLeftmostDate = xRange[0]; + + if (g.getOptionForAxis("logscale", "x")) { + context.initialLeftmostDate = Dygraph.log10(xRange[0]); + context.dateRange = Dygraph.log10(xRange[1]) - Dygraph.log10(xRange[0]); + } else { + context.initialLeftmostDate = xRange[0]; + context.dateRange = xRange[1] - xRange[0]; + } context.xUnitsPerPixel = context.dateRange / (g.plotter_.area.w - 1); if (g.getNumericOption("panEdgeFraction")) { @@ -132,7 +138,12 @@ Dygraph.Interaction.movePan = function(event, g, context) { } } - g.dateWindow_ = [minDate, maxDate]; + if (g.getOptionForAxis("logscale", "x")) { + g.dateWindow_ = [ Math.pow(Dygraph.LOG_SCALE, minDate), + Math.pow(Dygraph.LOG_SCALE, maxDate) ]; + } else { + g.dateWindow_ = [minDate, maxDate]; + } // y-axis scaling is automatic unless this is a full 2D pan. if (context.is2DPan) { @@ -160,8 +171,7 @@ Dygraph.Interaction.movePan = function(event, g, context) { minValue = maxValue - axis_data.dragValueRange; } } - var logscale = g.attributes_.getForAxis("logscale", i); - if (logscale) { + if (g.attributes_.getForAxis("logscale", i)) { axis.valueWindow = [ Math.pow(Dygraph.LOG_SCALE, minValue), Math.pow(Dygraph.LOG_SCALE, maxValue) ]; } else { @@ -307,12 +317,12 @@ Dygraph.Interaction.treatMouseOpAsClick = function(g, event, context) { } if (selectedPoint) { - pointClickCallback(event, selectedPoint); + pointClickCallback.call(g, event, selectedPoint); } // TODO(danvk): pass along more info about the points, e.g. 'x' if (clickCallback) { - clickCallback(event, g.lastx_, g.selPoints_); + clickCallback.call(g, event, g.lastx_, g.selPoints_); } }; @@ -525,7 +535,7 @@ Dygraph.Interaction.moveTouch = function(event, g, context) { // We only call zoomCallback on zooms, not pans, to mirror desktop behavior. if (didZoom && touches.length > 1 && g.getFunctionOption('zoomCallback')) { var viewWindow = g.xAxisRange(); - g.getFunctionOption("zoomCallback")(viewWindow[0], viewWindow[1], g.yAxisRanges()); + g.getFunctionOption("zoomCallback").call(g, viewWindow[0], viewWindow[1], g.yAxisRanges()); } };