X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=bc830b2b9b81793c18fd430dd411d964cd46fa4a;hb=470d42e152bd816333bb9879731c77340daaf7c1;hp=99795874e77b2ffc846d86fbcc97fde7acbe5e1c;hpb=afdb20d88ecfd0d3464adf2ca7a8f87d7935409b;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 9979587..bc830b2 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1021,7 +1021,11 @@ Dygraph.prototype.createStatusMessage_ = function() { div.className = "dygraph-legend"; for (var name in messagestyle) { if (messagestyle.hasOwnProperty(name)) { - div.style[name] = messagestyle[name]; + try { + div.style[name] = messagestyle[name]; + } catch (e) { + this.warn("You are using unsupported css properties for your browser in labelsDivStyles"); + } } } this.graphDiv.appendChild(div); @@ -1513,9 +1517,10 @@ Dygraph.prototype.findClosestRow = function(domX) { var point = points[i]; if (point === null) continue; var dist = Math.abs(point.canvasx - domX); - if (minDistX !== null && dist >= minDistX) continue; - minDistX = dist; - idx = i; + if (minDistX === null || dist < minDistX) { + minDistX = dist; + idx = i; + } } return this.idxToRow_(idx); }; @@ -1546,11 +1551,12 @@ Dygraph.prototype.findClosestPoint = function(domX, domY) { dx = point.canvasx - domX; dy = point.canvasy - domY; dist = dx * dx + dy * dy; - if (minDist !== null && dist >= minDist) continue; - minDist = dist; - closestPoint = point; - closestSeries = setIdx; - idx = i; + if (minDist === null || dist < minDist) { + minDist = dist; + closestPoint = point; + closestSeries = setIdx; + idx = i; + } } } var name = this.layout_.setNames[closestSeries]; @@ -1601,9 +1607,10 @@ Dygraph.prototype.findStackedPoint = function(domX, domY) { } } // Stop if the point (domX, py) is above this series' upper edge - if (setIdx > 0 && py >= domY) break; - closestPoint = p1; - closestSeries = setIdx; + if (setIdx == 0 || py < domY) { + closestPoint = p1; + closestSeries = setIdx; + } } var name = this.layout_.setNames[closestSeries]; return { @@ -1936,11 +1943,15 @@ Dygraph.prototype.updateSelection_ = function(opt_animFraction) { var circleSize = this.attr_('highlightCircleSize', pt.name); var callback = this.attr_("drawHighlightPointCallback", pt.name); + var color = this.plotter_.colors[pt.name]; if (!callback) { callback = Dygraph.Circles.DEFAULT; } + ctx.lineWidth = this.attr_('strokeWidth', pt.name); + ctx.strokeStyle = color; + ctx.fillStyle = color; callback(this.g, pt.name, ctx, canvasx, pt.canvasy, - this.plotter_.colors[pt.name], circleSize); + color, circleSize); } ctx.restore();