X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=41ad05ccc5f1e6f12bf6fdacfd6e048bd8c9ba52;hb=f978433f1679216e312114af7d2a9ea3e3b5b36b;hp=3a6018018f7fbc0921bd1e36423238ebb98547d5;hpb=debdb88d1ccca3648f45d6cc5d49896f3014cfdd;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 3a60180..41ad05c 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1735,7 +1735,7 @@ Dygraph.prototype.mouseMove_ = function(event) { 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); @@ -1906,8 +1906,11 @@ Dygraph.prototype.updateSelection_ = function(opt_animFraction) { * 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_ = []; @@ -1947,6 +1950,10 @@ Dygraph.prototype.setSelection = function(row, opt_seriesName) { this.highlightSet_ = opt_seriesName; } + if (opt_locked !== undefined) { + this.lockedSet_ = opt_locked; + } + if (changed) { this.updateSelection_(undefined); } @@ -1963,7 +1970,7 @@ Dygraph.prototype.mouseOut_ = function(event) { this.attr_("unhighlightCallback")(event); } - if (this.attr_("hideOverlayOnMouseOut")) { + if (this.attr_("hideOverlayOnMouseOut") && !this.lockedSet_) { this.clearSelection(); } }; @@ -1975,6 +1982,7 @@ Dygraph.prototype.mouseOut_ = function(event) { Dygraph.prototype.clearSelection = function() { this.cascadeEvents_('deselect', {}); + this.lockedSet_ = false; // Get rid of the overlay data if (this.fadeLevel) { this.animateSelection_(-1); @@ -2172,11 +2180,13 @@ Dygraph.prototype.gatherDatasets_ = function(rolledSeries, dateWindow) { for (i = num_series; i >= 1; i--) { if (!this.visibility()[i - 1]) continue; - // TODO(danvk): is this copy really necessary? - var series = rolledSeries[i]; // []; - // for (j = 0; j < rolledSeries[i].length; j++) { - // series.push(rolledSeries[i][j]); - // } + // Note: this copy _is_ necessary at the moment. + // If you remove it, it breaks zooming with error bars on. + // TODO(danvk): investigate further & write a test for this. + var series = []; + for (j = 0; j < rolledSeries[i].length; j++) { + series.push(rolledSeries[i][j]); + } // Prune down to the desired range, if necessary (for zooming) // Because there can be lines going to points outside of the visible area,