Fix bug 415. Series must be specicied by name in the options object.
authorRobert Konigsberg <konigsberg@gmail.com>
Fri, 4 Jan 2013 04:05:42 +0000 (23:05 -0500)
committerRobert Konigsberg <konigsberg@gmail.com>
Fri, 4 Jan 2013 04:07:25 +0000 (23:07 -0500)
auto_tests/misc/local.html
dygraph-layout.js
dygraph-options.js

index 0d4fe45..bf2756f 100644 (file)
@@ -33,6 +33,7 @@
   <script type="text/javascript" src="../tests/multi_csv.js"></script>
   <script type="text/javascript" src="../tests/multiple_axes.js"></script>
   <script type="text/javascript" src="../tests/multiple_axes-old.js"></script>
+  <script type="text/javascript" src="../tests/numeric-labels.js"></script>
   <script type="text/javascript" src="../tests/no_hours.js"></script>
   <script type="text/javascript" src="../tests/parser.js"></script>
   <script type="text/javascript" src="../tests/pathological_cases.js"></script>
index 900db68..b81a12c 100644 (file)
@@ -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];
index 87632ff..907811c 100644 (file)
@@ -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;
 };
 
 /**