X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=dygraph.js;h=001e23634306de4ef95ac23070181c9c906497b8;hb=1761e6ed4ef884d80c7c9c083323e76414e83de6;hp=0d4f82c30d8fc5beacbc2b3f7276f79e532b18cb;hpb=d4fea721dc42397d0f57aab005df74d8fad6b5ce;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 0d4f82c..001e236 100644 --- a/dygraph.js +++ b/dygraph.js @@ -831,7 +831,8 @@ Dygraph.prototype.toPercentYCoord = function(y, axis) { var yRange = this.yAxisRange(axis); var pct; - if (!this.axes_[axis].logscale) { + var logscale = this.attributes_.getForAxis("logscale", axis); + if (!logscale) { // yRange[1] - y is unit distance from the bottom. // yRange[1] - yRange[0] is the scale of the range. // (yRange[1] - y) / (yRange[1] - yRange[0]) is the % from the bottom. @@ -2428,6 +2429,7 @@ Dygraph.prototype.renderGraph_ = function(is_initial_draw) { * indices are into the axes_ array. */ Dygraph.prototype.computeYAxes_ = function() { + // Preserve valueWindow settings if they exist, and if the user hasn't // specified a new valueRange. var i, valueWindows, seriesName, axis, index, opts, v; @@ -2450,6 +2452,28 @@ Dygraph.prototype.computeYAxes_ = function() { this.axes_[axis] = opts; } + // TODO(konigsberg): REMOVE THIS SILLINESS this should just come from DygraphOptions. + // TODO(konigsberg): Add tests for all of these. + + // all options which could be applied per-axis: + var axisOptions = [ + 'valueRange', + 'labelsKMB', + 'labelsKMG2', + 'pixelsPerYLabel', + 'yAxisLabelWidth', + 'axisLabelFontSize', + 'axisTickSize' + ]; + + // Copy global axis options over to the first axis. + for (i = 0; i < axisOptions.length; i++) { + var k = axisOptions[i]; + v = this.attr_(k); + if (v) this.axes_[0][k] = v; + } + // TODO(konigsberg): end of REMOVE THIS SILLINESS + if (valueWindows !== undefined) { // Restore valueWindow settings. for (index = 0; index < valueWindows.length; index++) { @@ -2505,7 +2529,8 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) { // Compute extreme values, a span and tick marks for each axis. for (var i = 0; i < numAxes; i++) { var axis = this.axes_[i]; - + var logscale = this.attributes_.getForAxis("logscale", i); + var includeZero = this.attributes_.getForAxis("includeZero", i); series = this.attributes_.seriesForAxis(i); if (series.length == 0) { @@ -2531,7 +2556,7 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) { maxY = Math.max(extremeMaxY, maxY); } } - if (axis.includeZero && minY > 0) minY = 0; + if (includeZero && minY > 0) minY = 0; // Ensure we have a valid scale, otherwise default to [0, 1] for safety. if (minY == Infinity) minY = 0; @@ -2543,7 +2568,7 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) { if (span === 0) { span = maxY; } var maxAxisY, minAxisY; - if (axis.logscale) { + if (logscale) { maxAxisY = maxY + 0.1 * span; minAxisY = minY; } else { @@ -3198,6 +3223,7 @@ Dygraph.prototype.parseDataTable_ = function(data) { if (annotations.length > 0) { this.setAnnotations(annotations, true); } + this.attributes_.reparseSeries(); }; /**