X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-options.js;h=98ef35fde3825f7b59e74707717292f90df10d84;hb=99386b99835dfcc75053b4a9a4304b3d8a8546ad;hp=ccba4f89637429c6547ab48eecfd7c335d34160b;hpb=e321ff2a4d3adfb640735f26c3eda1022e9e5f14;p=dygraphs.git diff --git a/dygraph-options.js b/dygraph-options.js index ccba4f8..98ef35f 100644 --- a/dygraph-options.js +++ b/dygraph-options.js @@ -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., options : Object}>} + * @type {Array.<{series : Array., 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.} + * @type {Object.} * @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; @@ -288,11 +290,13 @@ DygraphOptions.prototype.getForAxis = function(name, axis) { } // User-specified global options second. - var result = this.getGlobalUser_(name); - if (result !== null) { - return result; + // But, hack, ignore globally-specified 'logscale' for 'x' axis declaration. + if (!(axis === 'x' && name === 'logscale')) { + var result = this.getGlobalUser_(name); + if (result !== null) { + return result; + } } - // Default axis options third. var defaultAxisOptions = Dygraph.DEFAULT_ATTRS.axes[axisString]; if (defaultAxisOptions.hasOwnProperty(name)) { @@ -312,7 +316,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]; } @@ -368,15 +372,6 @@ DygraphOptions.prototype.seriesNames = function() { return this.labels_; }; -/* Are we using this? */ -/** - * Return the index of the specified series. - * @param {string} series the series name. - */ -DygraphOptions.prototype.indexOfSeries = function(series) { - return this.series_[series].idx; -}; - return DygraphOptions; })();