X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=dygraph-interaction-model.js;h=06655f1e88c9a6cdb5619ccd348c3ae23a4bd2bf;hb=920208fbb3565a1f9075d49a7be486819bdd1174;hp=42f0eaf67e11b11c935e117aff370618d93cd422;hpb=bbfb84f2a5e0fbb5259fab16f0785a5806c5bf8d;p=dygraphs.git diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index 42f0eaf..06655f1 100644 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@ -1,7 +1,10 @@ -// Copyright 2011 Robert Konigsberg (konigsberg@google.com) -// All Rights Reserved. +/** + * @license + * Copyright 2011 Robert Konigsberg (konigsberg@google.com) + * MIT-licensed (http://opensource.org/licenses/MIT) + */ -/** +/** * @fileoverview The default interaction model for Dygraphs. This is kept out * of dygraph.js for better navigability. * @author Robert Konigsberg (konigsberg@google.com) @@ -126,7 +129,7 @@ Dygraph.Interaction.movePan = function(event, g, context) { var pixelsDragged = context.dragEndY - context.dragStartY; var unitsDragged = pixelsDragged * axis.unitsPerPixel; - + var boundedValue = context.boundedValues ? context.boundedValues[i] : null; // In log scale, maxValue and minValue are the logs of those values. @@ -319,7 +322,7 @@ Dygraph.Interaction.endZoom = function(event, g, context) { g.doZoomY_(Math.min(context.dragStartY, context.dragEndY), Math.max(context.dragStartY, context.dragEndY)); } else { - g.canvas_ctx_.clearRect(0, 0, g.canvas_.width, g.canvas_.height); + g.clearZoomRect_(); } context.dragStartX = null; context.dragStartY = null; @@ -393,3 +396,20 @@ Dygraph.endPan = Dygraph.Interaction.endPan; Dygraph.movePan = Dygraph.Interaction.movePan; Dygraph.startPan = Dygraph.Interaction.startPan; +Dygraph.Interaction.nonInteractiveModel_ = { + mousedown: function(event, g, context) { + context.initializeMouseDown(event, g, context); + }, + mouseup: function(event, g, context) { + // TODO(danvk): this logic is repeated in Dygraph.Interaction.endZoom + context.dragEndX = g.dragGetX_(event, context); + context.dragEndY = g.dragGetY_(event, context); + var regionWidth = Math.abs(context.dragEndX - context.dragStartX); + var regionHeight = Math.abs(context.dragEndY - context.dragStartY); + + if (regionWidth < 2 && regionHeight < 2 && + g.lastx_ != undefined && g.lastx_ != -1) { + Dygraph.Interaction.treatMouseOpAsClick(g, event, context); + } + } +};