From: Dan Vanderkam Date: Tue, 31 Jul 2012 14:43:40 +0000 (-0400) Subject: Merge branch 'master' of github.com:danvk/dygraphs X-Git-Tag: v1.0.0~209 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=85e975f9e164acfd6bdbb9a4b20d6a40f2d2a850;hp=-c;p=dygraphs.git Merge branch 'master' of github.com:danvk/dygraphs --- 85e975f9e164acfd6bdbb9a4b20d6a40f2d2a850 diff --combined dygraph.js index 90112cf,41ad05c..ba6889e --- a/dygraph.js +++ b/dygraph.js @@@ -409,7 -409,6 +409,7 @@@ Dygraph.prototype.__init__ = function(d this.datasetIndex_ = []; this.registeredEvents_ = []; + this.eventListeners_ = {}; // Create the containing DIV and other interactive elements this.createInterface_(); @@@ -437,6 -436,7 +437,6 @@@ // At this point, plugins can no longer register event handlers. // Construct a map from event -> ordered list of [callback, plugin]. - this.eventListeners_ = {}; for (var i = 0; i < this.plugins_.length; i++) { var plugin_dict = this.plugins_[i]; for (var eventName in plugin_dict.events) { @@@ -931,6 -931,7 +931,6 @@@ Dygraph.prototype.createInterface_ = fu if (this.attr_('showRangeSelector')) { // The range selector must be created here so that its canvases and contexts get created here. // For some reason, if the canvases and contexts don't get created here, things don't work in IE. - // The range selector also sets xAxisHeight in order to reserve space. this.rangeSelector_ = new DygraphRangeSelector(this); } @@@ -948,12 -949,12 +948,12 @@@ } var dygraph = this; - + this.mouseMoveHandler = function(e) { dygraph.mouseMove_(e); }; this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler); - + this.mouseOutHandler = function(e) { dygraph.mouseOut_(e); }; @@@ -982,7 -983,7 +982,7 @@@ Dygraph.prototype.destroy = function() node.removeChild(node.firstChild); } }; - + for (var idx = 0; idx < this.registeredEvents_.length; idx++) { var reg = this.registeredEvents_[idx]; Dygraph.removeEvent(reg.elem, reg.type, reg.fn); @@@ -1734,7 -1735,7 +1734,7 @@@ Dygraph.prototype.mouseMove_ = function var highlightSeriesOpts = this.attr_("highlightSeriesOpts"); var selectionChanged = false; - if (highlightSeriesOpts) { + if (highlightSeriesOpts && !this.lockedSet_) { var closest; if (this.attr_("stackedGraph")) { closest = this.findStackedPoint(canvasx, canvasy); @@@ -1905,8 -1906,11 +1905,11 @@@ Dygraph.prototype.updateSelection_ = fu * hover dots on the chart). Set to false to clear any selection. * @param { seriesName } optional series name to highlight that series with the * the highlightSeriesOpts setting. + * @param { locked } optional If true, keep seriesName selected when mousing + * over the graph, disabling closest-series highlighting. Call clearSelection() + * to unlock it. */ - Dygraph.prototype.setSelection = function(row, opt_seriesName) { + Dygraph.prototype.setSelection = function(row, opt_seriesName, opt_locked) { // Extract the points we've selected this.selPoints_ = []; @@@ -1946,6 -1950,10 +1949,10 @@@ this.highlightSet_ = opt_seriesName; } + if (opt_locked !== undefined) { + this.lockedSet_ = opt_locked; + } + if (changed) { this.updateSelection_(undefined); } @@@ -1962,7 -1970,7 +1969,7 @@@ Dygraph.prototype.mouseOut_ = function( this.attr_("unhighlightCallback")(event); } - if (this.attr_("hideOverlayOnMouseOut")) { + if (this.attr_("hideOverlayOnMouseOut") && !this.lockedSet_) { this.clearSelection(); } }; @@@ -1974,6 -1982,7 +1981,7 @@@ Dygraph.prototype.clearSelection = function() { this.cascadeEvents_('deselect', {}); + this.lockedSet_ = false; // Get rid of the overlay data if (this.fadeLevel) { this.animateSelection_(-1); @@@ -2641,7 -2650,7 +2649,7 @@@ Dygraph.prototype.computeYAxisRanges_ * This is where undesirable points (i.e. negative values on log scales and * missing values through which we wish to connect lines) are dropped. * TODO(danvk): the "missing values" bit above doesn't seem right. - * + * * @private */ Dygraph.prototype.extractSeries_ = function(rawData, i, logScale) {