X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=42e87c83e6aecc651635fa9eaba1a3428c4196cf;hb=45a8c16f0f004c4513d2127553d1a2cb2502f282;hp=fa8823e3117ac684afd263738d79041fe7ffa731;hpb=77812e0eaac96feb43c1df07a62469b0ced75e60;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index fa8823e..42e87c8 100644 --- a/dygraph.js +++ b/dygraph.js @@ -355,6 +355,10 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { attrs = Dygraph.mapLegacyOptions_(attrs); + if (typeof(div) == 'string') { + div = document.getElementById(div); + } + if (!div) { Dygraph.error("Constructing dygraph with a non-existent div!"); return; @@ -603,13 +607,12 @@ Dygraph.prototype.attr_ = function(name, seriesName) { } var computedValue = seriesName ? this.attributes_.findForSeries(name, seriesName) : this.attributes_.find(name); - if (ret !== computedValue) { console.log("Mismatch", name, seriesName, ret, computedValue); - } else { - console.log("Match", name, seriesName, ret, computedValue); } - return computedValue; + + var USE_NEW_VALUE = true; + return USE_NEW_VALUE ? computedValue : ret; }; /** @@ -1688,7 +1691,7 @@ Dygraph.prototype.findClosestPoint = function(domX, domY) { var minDist = Infinity; var idx = -1; var dist, dx, dy, point, closestPoint, closestSeries; - for (var setIdx = 0; setIdx < this.layout_.datasets.length; ++setIdx) { + for ( var setIdx = this.layout_.datasets.length - 1 ; setIdx >= 0 ; --setIdx ) { var points = this.layout_.points[setIdx]; for (var i = 0; i < points.length; ++i) { var point = points[i]; @@ -1789,7 +1792,7 @@ Dygraph.prototype.mouseMove_ = function(event) { var highlightSeriesOpts = this.attr_("highlightSeriesOpts"); var selectionChanged = false; - if (highlightSeriesOpts && !this.lockedSet_) { + if (highlightSeriesOpts && !this.isSeriesLocked()) { var closest; if (this.attr_("stackedGraph")) { closest = this.findStackedPoint(canvasx, canvasy); @@ -2082,6 +2085,14 @@ Dygraph.prototype.getHighlightSeries = function() { }; /** + * Returns true if the currently-highlighted series was locked + * via setSelection(..., seriesName, true). + */ +Dygraph.prototype.isSeriesLocked = function() { + return this.lockedSet_; +}; + +/** * Fires when there's data available to be graphed. * @param {String} data Raw CSV data to be plotted * @private