mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-06 16:26:52 +01:00
Use ticks consistently (#6873)
This commit is contained in:
committed by
Evert Timberg
parent
1cda96946b
commit
dbd835f4f3
@@ -53,7 +53,7 @@ function computeMinSampleSize(scale, pixels) {
|
||||
min = Math.min(min, Math.abs(pixels[i] - pixels[i - 1]));
|
||||
}
|
||||
|
||||
for (i = 0, ilen = scale.getTicks().length; i < ilen; ++i) {
|
||||
for (i = 0, ilen = scale.ticks.length; i < ilen; ++i) {
|
||||
curr = scale.getPixelForTick(i);
|
||||
min = i > 0 ? Math.min(min, Math.abs(curr - prev)) : min;
|
||||
prev = curr;
|
||||
|
||||
@@ -78,7 +78,7 @@ class CategoryScale extends Scale {
|
||||
if (index < 0 || index > ticks.length - 1) {
|
||||
return null;
|
||||
}
|
||||
return this.getPixelForValue(index * me._numLabels / ticks.length + this.min);
|
||||
return me.getPixelForValue(index * me._numLabels / ticks.length + me.min);
|
||||
}
|
||||
|
||||
getValueForPixel(pixel) {
|
||||
|
||||
@@ -63,11 +63,11 @@ class LinearScale extends LinearScaleBase {
|
||||
}
|
||||
|
||||
getPixelForTick(index) {
|
||||
var ticks = this._tickValues;
|
||||
const ticks = this.ticks;
|
||||
if (index < 0 || index > ticks.length - 1) {
|
||||
return null;
|
||||
}
|
||||
return this.getPixelForValue(ticks[index]);
|
||||
return this.getPixelForValue(ticks[index].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -231,15 +231,9 @@ class LinearScaleBase extends Scale {
|
||||
return ticks;
|
||||
}
|
||||
|
||||
generateTickLabels(ticks) {
|
||||
var me = this;
|
||||
me._tickValues = ticks.map(t => t.value);
|
||||
Scale.prototype.generateTickLabels.call(me, ticks);
|
||||
}
|
||||
|
||||
_configure() {
|
||||
var me = this;
|
||||
var ticks = me.getTicks();
|
||||
var ticks = me.ticks;
|
||||
var start = me.min;
|
||||
var end = me.max;
|
||||
var offset;
|
||||
|
||||
@@ -450,7 +450,7 @@ class RadialLinearScale extends LinearScaleBase {
|
||||
if (gridLineOpts.display) {
|
||||
me.ticks.forEach(function(tick, index) {
|
||||
if (index !== 0) {
|
||||
offset = me.getDistanceFromCenterForValue(me._tickValues[index]);
|
||||
offset = me.getDistanceFromCenterForValue(me.ticks[index].value);
|
||||
drawRadiusLine(me, gridLineOpts, offset, index);
|
||||
}
|
||||
});
|
||||
@@ -508,7 +508,7 @@ class RadialLinearScale extends LinearScaleBase {
|
||||
return;
|
||||
}
|
||||
|
||||
offset = me.getDistanceFromCenterForValue(me._tickValues[index]);
|
||||
offset = me.getDistanceFromCenterForValue(me.ticks[index].value);
|
||||
|
||||
if (tickOpts.showLabelBackdrop) {
|
||||
width = ctx.measureText(tick.label).width;
|
||||
|
||||
@@ -703,10 +703,11 @@ class TimeScale extends Scale {
|
||||
}
|
||||
|
||||
getPixelForTick(index) {
|
||||
const ticks = this.getTicks();
|
||||
return index >= 0 && index < ticks.length ?
|
||||
this.getPixelForValue(ticks[index].value) :
|
||||
null;
|
||||
const ticks = this.ticks;
|
||||
if (index < 0 || index > ticks.length - 1) {
|
||||
return null;
|
||||
}
|
||||
return this.getPixelForValue(ticks[index].value);
|
||||
}
|
||||
|
||||
getValueForPixel(pixel) {
|
||||
|
||||
Reference in New Issue
Block a user