Skip to content

Commit bedc3f1

Browse files
authored
Fix autoSkip (#8619)
* Fix autoSkip * Add tests
1 parent 7c8ee6e commit bedc3f1

File tree

5 files changed

+46
-2
lines changed

5 files changed

+46
-2
lines changed

src/core/core.scale.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,8 +1162,8 @@ export default class Scale extends Element {
11621162
*/
11631163
_autoSkip(ticks) {
11641164
const me = this;
1165-
const tickOpts = me.options.ticks;
1166-
const ticksLimit = tickOpts.maxTicksLimit || me._length / me._tickSize();
1165+
const {offset, ticks: tickOpts} = me.options;
1166+
const ticksLimit = tickOpts.maxTicksLimit || (me._length / me._tickSize() + (offset ? 0 : 1));
11671167
const majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : [];
11681168
const numMajorIndices = majorIndices.length;
11691169
const first = majorIndices[0];
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
description: 'https://github.com/chartjs/Chart.js/issues/8611',
3+
config: {
4+
type: 'line',
5+
data: {
6+
labels: ['Red Red Red', 'Blue Blue Blue', 'Black Black Black', 'Pink Pink Pink'],
7+
datasets: [
8+
{
9+
label: '# of Votes',
10+
data: [12, 19, 3, 5]
11+
},
12+
]
13+
},
14+
},
15+
options: {
16+
spriteText: true,
17+
canvas: {
18+
width: 470,
19+
height: 128
20+
}
21+
}
22+
};
8.68 KB
Loading
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
description: 'https://github.com/chartjs/Chart.js/issues/8611',
3+
config: {
4+
type: 'bar',
5+
data: {
6+
labels: ['Red Red Red', 'Blue Blue Blue', 'Black Black Black', 'Pink Pink Pink'],
7+
datasets: [
8+
{
9+
label: '# of Votes',
10+
data: [12, 19, 3, 5]
11+
},
12+
]
13+
},
14+
},
15+
options: {
16+
spriteText: true,
17+
canvas: {
18+
width: 506,
19+
height: 128
20+
}
21+
}
22+
};
8.01 KB
Loading

0 commit comments

Comments
 (0)