diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 338fc3d35..9c6f1aeba 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -221,13 +221,16 @@ module.exports = function(Chart) { this.start = this.min; this.end = this.max; } - - this.ticksAsNumbers = this.ticks.slice(); // do after we potentially reverse the ticks - this.zeroLineIndex = this.ticks.indexOf(0); }, getLabelForIndex: function(index, datasetIndex) { return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]); }, + convertTicksToLabels: function() { + this.ticksAsNumbers = this.ticks.slice(); + this.zeroLineIndex = this.ticks.indexOf(0); + + Chart.Scale.prototype.convertTicksToLabels.call(this); + }, // Utils getPixelForValue: function(value, index, datasetIndex, includeOffset) { // This must be called after fit has been run so that diff --git a/src/scales/scale.logarithmic.js b/src/scales/scale.logarithmic.js index 8f138193b..070a08d61 100644 --- a/src/scales/scale.logarithmic.js +++ b/src/scales/scale.logarithmic.js @@ -103,7 +103,7 @@ module.exports = function(Chart) { buildTicks: function() { // Reset the ticks array. Later on, we will draw a grid line at these positions // The array simply contains the numerical value of the spots where ticks will be - this.tickValues = []; + this.ticks = []; // Figure out what the max number of ticks we can support it is based on the size of // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 @@ -113,7 +113,7 @@ module.exports = function(Chart) { var tickVal = this.options.ticks.min !== undefined ? this.options.ticks.min : Math.pow(10, Math.floor(helpers.log10(this.min))); while (tickVal < this.max) { - this.tickValues.push(tickVal); + this.ticks.push(tickVal); var exp = Math.floor(helpers.log10(tickVal)); var significand = Math.floor(tickVal / Math.pow(10, exp)) + 1; @@ -127,20 +127,20 @@ module.exports = function(Chart) { } var lastTick = this.options.ticks.max !== undefined ? this.options.ticks.max : tickVal; - this.tickValues.push(lastTick); + this.ticks.push(lastTick); if (this.options.position === "left" || this.options.position === "right") { // We are in a vertical orientation. The top value is the highest. So reverse the array - this.tickValues.reverse(); + this.ticks.reverse(); } // At this point, we need to update our max and min given the tick values since we have expanded the // range of the scale - this.max = helpers.max(this.tickValues); - this.min = helpers.min(this.tickValues); + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); if (this.options.ticks.reverse) { - this.tickValues.reverse(); + this.ticks.reverse(); this.start = this.max; this.end = this.min; @@ -148,8 +148,11 @@ module.exports = function(Chart) { this.start = this.min; this.end = this.max; } + }, + convertTicksToLabels: function() { + this.tickValues = this.ticks.slice(); - this.ticks = this.tickValues.slice(); + Chart.Scale.prototype.convertTicksToLabels.call(this); }, // Get the correct tooltip label getLabelForIndex: function(index, datasetIndex) { diff --git a/test/scale.linear.tests.js b/test/scale.linear.tests.js index be6c803d2..85d076bf6 100644 --- a/test/scale.linear.tests.js +++ b/test/scale.linear.tests.js @@ -650,7 +650,6 @@ describe('Linear Scale', function() { // Reverse mode makes this count up expect(scale.ticks).toEqual([0, 10, 20, 30, 40, 50, 60, 70, 80]); - expect(scale.ticksAsNumbers).toEqual([0, 10, 20, 30, 40, 50, 60, 70, 80]); expect(scale.start).toBe(80); expect(scale.end).toBe(0); });