Merge branch 'master' of https://github.com/danvk/dygraphs
[dygraphs.git] / dygraph-options.js
index ccba4f8..0f90086 100644 (file)
@@ -36,19 +36,21 @@ var DygraphOptions = (function() {
 var DygraphOptions = function(dygraph) {
   /**
    * The dygraph.
-   * @type {Dygraph}
+   * @type {!Dygraph}
    */
   this.dygraph_ = dygraph;
 
   /**
    * Array of axis index to { series : [ series names ] , options : { axis-specific options. }
-   * @type {Array.<{series : Array.<string>, options : Object}>}
+   * @type {Array.<{series : Array.<string>, options : Object}>} @private
    */
   this.yAxes_ = [];
 
   /**
-   * { options : { axis-specific options. }
-   * @type {Object}
+   * Contains x-axis specific options, which are stored in the options key.
+   * This matches the yAxes_ object structure (by being a dictionary with an
+   * options element) allowing for shared code.
+   * @type {options: Object} @private
    */
   this.xAxis_ = {};
   this.series_ = {};
@@ -71,7 +73,7 @@ var DygraphOptions = function(dygraph) {
  * Not optimal, but does the trick when you're only using two axes.
  * If we move to more axes, this can just become a function.
  *
- * @type {Object.<string, number>}
+ * @type {Object.<number>}
  * @private
  */
 DygraphOptions.AXIS_STRING_MAPPINGS_ = {
@@ -83,6 +85,10 @@ DygraphOptions.AXIS_STRING_MAPPINGS_ = {
   'Y2' : 1
 };
 
+/**
+ * @param {string|number} axis
+ * @private
+ */
 DygraphOptions.axisToIndex_ = function(axis) {
   if (typeof(axis) == "string") {
     if (DygraphOptions.AXIS_STRING_MAPPINGS_.hasOwnProperty(axis)) {
@@ -96,10 +102,6 @@ DygraphOptions.axisToIndex_ = function(axis) {
     }
     throw "Dygraphs only supports two y-axes, indexed from 0-1.";
   }
-  if (typeof(axis) == "object") {
-    throw "Using objects for axis specification " +
-        "is not supported inside the 'series' option.";
-  }
   if (axis) {
     throw "Unknown axis : " + axis;
   }
@@ -181,9 +183,9 @@ DygraphOptions.prototype.reparseSeries = function() {
 
       if (typeof(axis) == 'string') {
         if (!this.series_.hasOwnProperty(axis)) {
-          this.dygraph_.error("Series " + seriesName + " wants to share a y-axis with " +
+          Dygraph.error("Series " + seriesName + " wants to share a y-axis with " +
                      "series " + axis + ", which does not define its own axis.");
-          return null;
+          return;
         }
         var yAxis = this.series_[axis].yAxis;
         this.series_[seriesName].yAxis = yAxis;
@@ -312,7 +314,7 @@ DygraphOptions.prototype.getForAxis = function(name, axis) {
  */
 DygraphOptions.prototype.getForSeries = function(name, series) {
   // Honors indexes as series.
-  if (series === this.dygraph_.highlightSet_) {
+  if (series === this.dygraph_.getHighlightSeries()) {
     if (this.highlightSeries_.hasOwnProperty(name)) {
       return this.highlightSeries_[name];
     }