From: Robert Konigsberg Date: Thu, 27 Dec 2012 00:23:34 +0000 (-0500) Subject: Remove labelsKMB and labelsKMG2 from Dygraph.axes_. X-Git-Tag: v1.0.0~138^2~7 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=a716aff2f83602d77caec236eaa9826ecf1b12c8;p=dygraphs.git Remove labelsKMB and labelsKMG2 from Dygraph.axes_. --- diff --git a/auto_tests/tests/axis_labels.js b/auto_tests/tests/axis_labels.js index ddb7a0f..d4812ea 100644 --- a/auto_tests/tests/axis_labels.js +++ b/auto_tests/tests/axis_labels.js @@ -525,6 +525,28 @@ AxisLabelsTestCase.prototype.testLabelKMG2 = function() { Util.getYLabels()); }; +// Same sa testLabelKMG2 but specifies the option at the +// top of the option dictionary. +AxisLabelsTestCase.prototype.testLabelKMG2_top = function() { + var data = []; + data.push([0,0]); + data.push([1,2000]); + data.push([2,1000]); + + var g = new Dygraph( + document.getElementById("graph"), + data, + { + labels: [ 'X', 'bar' ], + labelsKMG2: true + } + ); + + assertEquals( + ["0","256","512","768","1k","1.25k","1.5k","1.75k","2k"], + Util.getYLabels()); +}; + /** * Verify that log scale axis range is properly specified. */ diff --git a/dygraph.js b/dygraph.js index 001e236..4cee311 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2458,8 +2458,6 @@ Dygraph.prototype.computeYAxes_ = function() { // all options which could be applied per-axis: var axisOptions = [ 'valueRange', - 'labelsKMB', - 'labelsKMG2', 'pixelsPerYLabel', 'yAxisLabelWidth', 'axisLabelFontSize', @@ -2820,6 +2818,10 @@ Dygraph.prototype.detectTypeFromString_ = function(str) { isDate = true; } + this.setXAxisOptions_(isDate); +}; + +Dygraph.prototype.setXAxisOptions_ = function(isDate) { if (isDate) { this.attrs_.xValueParser = Dygraph.dateParser; this.attrs_.axes.x.valueFormatter = Dygraph.dateString_; @@ -2834,7 +2836,7 @@ Dygraph.prototype.detectTypeFromString_ = function(str) { this.attrs_.axes.x.ticker = Dygraph.numericLinearTicks; this.attrs_.axes.x.axisLabelFormatter = this.attrs_.axes.x.valueFormatter; } -}; +} /** * Parses the value as a floating point number. This is like the parseFloat() @@ -3056,8 +3058,8 @@ Dygraph.prototype.parseArray_ = function(data) { if (Dygraph.isDateLike(data[0][0])) { // Some intelligent defaults for a date x-axis. this.attrs_.axes.x.valueFormatter = Dygraph.dateString_; - this.attrs_.axes.x.axisLabelFormatter = Dygraph.dateAxisFormatter; this.attrs_.axes.x.ticker = Dygraph.dateTicker; + this.attrs_.axes.x.axisLabelFormatter = Dygraph.dateAxisFormatter; // Assume they're all dates. var parsedData = Dygraph.clone(data); @@ -3079,8 +3081,8 @@ Dygraph.prototype.parseArray_ = function(data) { // Some intelligent defaults for a numeric x-axis. /** @private (shut up, jsdoc!) */ this.attrs_.axes.x.valueFormatter = function(x) { return x; }; - this.attrs_.axes.x.axisLabelFormatter = Dygraph.numberAxisLabelFormatter; this.attrs_.axes.x.ticker = Dygraph.numericLinearTicks; + this.attrs_.axes.x.axisLabelFormatter = Dygraph.numberAxisLabelFormatter; return data; } };