From: Robert Konigsberg Date: Thu, 3 Jan 2013 20:29:20 +0000 (-0500) Subject: Merge branch 'master' of git://github.com/danvk/dygraphs into axis-label-font-size X-Git-Tag: v1.0.0~132^2~1 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=e4a06d92cb5cb671a668ecc7b2c9c8f5155b16ea;p=dygraphs.git Merge branch 'master' of git://github.com/danvk/dygraphs into axis-label-font-size Conflicts: dygraph-options.js --- e4a06d92cb5cb671a668ecc7b2c9c8f5155b16ea diff --cc dygraph-options.js index dc779b1,4e859de..87632ff --- a/dygraph-options.js +++ b/dygraph-options.js @@@ -224,37 -221,21 +224,37 @@@ DygraphOptions.prototype.getGlobalDefau * Get a value for a specific axis. If there is no specific value for the axis, * the global value is returned. * - * @param {String} name the name of the option. - * @param {String|number} axis the axis to search. Can be the string representation - * ("x", "y", "y2") or the y-axis number (0, 1). (x-axis can't be specified by number.) + * @param {string} name the name of the option. + * @param {string|number} axis the axis to search. Can be the string representation + * ("y", "y2") or the axis number (0, 1). */ DygraphOptions.prototype.getForAxis = function(name, axis) { - var axisIdx = 0; + var axisIdx; + var axisString; + + // Since axis can be a number or a string, straighten everything out here. if (typeof(axis) == 'number') { axisIdx = axis; + axisString = axisIdx == 0 ? "y" : "y2"; } else { - // TODO(konigsberg): Accept only valid axis strings? - axisIdx = (axis == "y2") ? 1 : 0; + if (axis == "y1") { axis = "y"; } // Standardize on 'y'. Is this bad? I think so. + if (axis == "y") { + axisIdx = 0; + } else if (axis == "y2") { + axisIdx = 1; + } else if (axis == "x") { + axisIdx = -1; // simply a placeholder for below. + } else { + throw "Unknown axis " + axis; + } + axisString = axis; } + + var userAxis = (axisIdx == -1) ? this.xAxis_ : this.yAxes_[axisIdx]; + // Search the user-specified axis option first. - if (this.axes_[axisIdx]) { - var axisOptions = this.axes_[axisIdx].options; + if (userAxis) { // This condition could be removed if we always set up this.yAxes_ for y2. + var axisOptions = userAxis.options; if (axisOptions.hasOwnProperty(name)) { return axisOptions[name]; }