From: Robert Konigsberg Date: Fri, 4 Jan 2013 04:05:42 +0000 (-0500) Subject: Fix bug 415. Series must be specicied by name in the options object. X-Git-Tag: v1.0.0~131^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=8e19509a9e0a607dcd2e5b0c3bcbe0e39e3170c2;p=dygraphs.git Fix bug 415. Series must be specicied by name in the options object. --- diff --git a/auto_tests/misc/local.html b/auto_tests/misc/local.html index 0d4fe45..bf2756f 100644 --- a/auto_tests/misc/local.html +++ b/auto_tests/misc/local.html @@ -33,6 +33,7 @@ + diff --git a/dygraph-layout.js b/dygraph-layout.js index 900db68..b81a12c 100644 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@ -233,7 +233,7 @@ DygraphLayout.prototype._evaluateLineCharts = function() { var setName = this.setNames[setIdx]; var axis = this.dygraph_.axisPropertiesForSeries(setName); // TODO (konigsberg): use optionsForAxis instead. - var logscale = this.dygraph_.attributes_.getForSeries("logscale", setIdx); + var logscale = this.dygraph_.attributes_.getForSeries("logscale", setName); // Preallocating the size of points reduces reallocations, and therefore, // calls to collect garbage. @@ -325,7 +325,7 @@ DygraphLayout.prototype.evaluateWithError = function() { var setName = this.setNames[setIdx]; var axis = this.dygraph_.axisPropertiesForSeries(setName); // TODO (konigsberg): use optionsForAxis instead. - var logscale = this.dygraph_.attributes_.getForSeries("logscale", setIdx); + var logscale = this.dygraph_.attributes_.getForSeries("logscale", setName); for (j = 0; j < dataset.length; j++, i++) { var item = dataset[j]; diff --git a/dygraph-options.js b/dygraph-options.js index 87632ff..907811c 100644 --- a/dygraph-options.js +++ b/dygraph-options.js @@ -281,24 +281,21 @@ DygraphOptions.prototype.getForAxis = function(name, axis) { * the value for the axis is returned (and afterwards, the global value.) * * @param {string} name the name of the option. - * @param {string|number} series the series to search. Can be the string representation - * or 0-offset series number. + * @param {string} series the series to search. */ DygraphOptions.prototype.getForSeries = function(name, series) { // Honors indexes as series. - var seriesName = (typeof(series) == "number") ? this.labels[series] : series; - - if (seriesName === this.dygraph_.highlightSet_) { + if (series === this.dygraph_.highlightSet_) { if (this.highlightSeries_.hasOwnProperty(name)) { return this.highlightSeries_[name]; } } - if (!this.series_.hasOwnProperty(seriesName)) { + if (!this.series_.hasOwnProperty(series)) { throw "Unknown series: " + series; } - var seriesObj = this.series_[seriesName]; + var seriesObj = this.series_[series]; var seriesOptions = seriesObj["options"]; if (seriesOptions.hasOwnProperty(name)) { return seriesOptions[name]; @@ -318,8 +315,8 @@ DygraphOptions.prototype.numAxes = function() { /** * Return the y-axis for a given series, specified by name. */ -DygraphOptions.prototype.axisForSeries = function(seriesName) { - return this.series_[seriesName].yAxis; +DygraphOptions.prototype.axisForSeries = function(series) { + return this.series_[series].yAxis; }; /**