Fix autoSkip (#8619)

* Fix autoSkip
* Add tests
This commit is contained in:
Jukka Kurkela 2021-03-11 23:25:16 +02:00 committed by GitHub
parent 7c8ee6e77f
commit bedc3f1575
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 2 deletions

View File

@ -1162,8 +1162,8 @@ export default class Scale extends Element {
*/
_autoSkip(ticks) {
const me = this;
const tickOpts = me.options.ticks;
const ticksLimit = tickOpts.maxTicksLimit || me._length / me._tickSize();
const {offset, ticks: tickOpts} = me.options;
const ticksLimit = tickOpts.maxTicksLimit || (me._length / me._tickSize() + (offset ? 0 : 1));
const majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : [];
const numMajorIndices = majorIndices.length;
const first = majorIndices[0];

View File

@ -0,0 +1,22 @@
module.exports = {
description: 'https://github.com/chartjs/Chart.js/issues/8611',
config: {
type: 'line',
data: {
labels: ['Red Red Red', 'Blue Blue Blue', 'Black Black Black', 'Pink Pink Pink'],
datasets: [
{
label: '# of Votes',
data: [12, 19, 3, 5]
},
]
},
},
options: {
spriteText: true,
canvas: {
width: 470,
height: 128
}
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -0,0 +1,22 @@
module.exports = {
description: 'https://github.com/chartjs/Chart.js/issues/8611',
config: {
type: 'bar',
data: {
labels: ['Red Red Red', 'Blue Blue Blue', 'Black Black Black', 'Pink Pink Pink'],
datasets: [
{
label: '# of Votes',
data: [12, 19, 3, 5]
},
]
},
},
options: {
spriteText: true,
canvas: {
width: 506,
height: 128
}
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB