X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-interaction-model.js;h=98d14110c1e14eafdf55b36713cac82a689b8a67;hb=c1f22b5a5d4ffbf25a75fc567232e65381c1938b;hp=645c2581952bd06ceacd29160c0843a927a890d9;hpb=027e9e9b363e2330191001068818089477345b75;p=dygraphs.git diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index 645c258..98d1411 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. @@ -263,7 +266,8 @@ Dygraph.Interaction.treatMouseOpAsClick = function(g, event, context) { var p = g.selPoints_[i]; var distance = Math.pow(p.canvasx - context.dragEndX, 2) + Math.pow(p.canvasy - context.dragEndY, 2); - if (closestIdx == -1 || distance < closestDistance) { + if (!isNaN(distance) && + (closestIdx == -1 || distance < closestDistance)) { closestDistance = distance; closestIdx = i; } @@ -319,7 +323,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,7 +397,7 @@ Dygraph.endPan = Dygraph.Interaction.endPan; Dygraph.movePan = Dygraph.Interaction.movePan; Dygraph.startPan = Dygraph.Interaction.startPan; -Dygraph.Interaction.nonInteractiveModel = { +Dygraph.Interaction.nonInteractiveModel_ = { mousedown: function(event, g, context) { context.initializeMouseDown(event, g, context); },