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
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
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;
}
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;
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) {
// 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);
});