* @return {number}
*/
getPixelForTick(index) {
- const me = this;
- const offset = me.options.offset;
- const numTicks = me.ticks.length;
- const tickWidth = 1 / Math.max(numTicks - (offset ? 0 : 1), 1);
-
- return index < 0 || index > numTicks - 1
- ? null
- : me.getPixelForDecimal(index * tickWidth + (offset ? tickWidth / 2 : 0));
+ const ticks = this.ticks;
+ if (index < 0 || index > ticks.length - 1) {
+ return null;
+ }
+ return this.getPixelForValue(ticks[index].value);
}
/**
return me.getPixelForDecimal((value - me._startValue) / me._valueRange);
}
+ // Must override base implementation becuase it calls getPixelForValue
+ // and category scale can have duplicate values
getPixelForTick(index) {
const me = this;
const ticks = me.ticks;
getValueForPixel(pixel) {
return this._startValue + this.getDecimalForPixel(pixel) * this._valueRange;
}
-
- getPixelForTick(index) {
- const ticks = this.ticks;
- if (index < 0 || index > ticks.length - 1) {
- return null;
- }
- return this.getPixelForValue(ticks[index].value);
- }
}
return value === undefined ? '0' : new Intl.NumberFormat(this.options.locale).format(value);
}
- getPixelForTick(index) {
- const ticks = this.ticks;
- if (index < 0 || index > ticks.length - 1) {
- return null;
- }
- return this.getPixelForValue(ticks[index].value);
- }
-
/**
* @protected
*/
return me.getPixelForDecimal((offsets.start + pos) * offsets.factor);
}
- /**
- * @param {number} index
- * @return {number}
- */
- getPixelForTick(index) {
- const ticks = this.ticks;
- if (index < 0 || index > ticks.length - 1) {
- return null;
- }
- return this.getPixelForValue(ticks[index].value);
- }
-
/**
* @param {number} pixel
* @return {number}