Small bug: when selPoints_ is empty, pointClickCallback is always called
authorRobert Konigsberg <konigsberg@google.com>
Wed, 25 May 2011 18:59:10 +0000 (14:59 -0400)
committerRobert Konigsberg <konigsberg@google.com>
Wed, 25 May 2011 18:59:10 +0000 (14:59 -0400)
because closestDistance < 5*5. So make it MAX_NUM. We could probably
remove the closestIdx == 1 too.

dygraph.js

index 6adb43b..e3e8daa 100644 (file)
@@ -1333,7 +1333,7 @@ Dygraph.Interaction.treatMouseOpAsClick = function(g, event, context) {
   if (g.attr_('pointClickCallback')) {
     // check if the click was on a particular point.
     var closestIdx = -1;
-    var closestDistance = 0;
+    var closestDistance = Number.MAX_VALUE;
     for (var i = 0; i < g.selPoints_.length; i++) {
       var p = g.selPoints_[i];
       var distance = Math.pow(p.canvasx - context.dragEndX, 2) +