Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ export default class Scale extends Element {
this.calculateLabelRotation(); // Preconditions: number of ticks and sizes of largest labels must be calculated beforehand
this.afterCalculateLabelRotation();

// Auto-skip
if (tickOpts.display && (tickOpts.autoSkip || tickOpts.source === 'auto')) {
// Auto-skip — disabled when stepSize is explicitly set
if (tickOpts.display && !tickOpts.stepSize && (tickOpts.autoSkip || tickOpts.source === 'auto')) {
this.ticks = autoSkip(this, this.ticks);
this._labelSizes = null;
this.afterAutoSkip();
Expand Down
31 changes: 31 additions & 0 deletions test/specs/scale.linear.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,37 @@ describe('Linear Scale', function() {
expect(getLabels(chart.scales.y)).toEqual(['1', '3', '5', '7', '9', '11']);
});

it('Should not autoSkip ticks when stepSize is set', function() {
var chart = window.acquireChart({
type: 'bar',
data: {
datasets: [{
yAxisID: 'y',
data: [10, 3, 6, 8, 3, 1]
}],
labels: ['a', 'b', 'c', 'd', 'e', 'f']
},
options: {
scales: {
y: {
type: 'linear',
min: 0,
max: 10,
ticks: {
stepSize: 1
}
}
}
}
});

var ticks = chart.scales.y.ticks;
var visibleTicks = ticks.filter(t => !t.skip);

expect(visibleTicks.length).toBe(ticks.length);
expect(getLabels(chart.scales.y)).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']);
});

it('Should not generate any ticks > max if max is specified', function() {
var chart = window.acquireChart({
type: 'line',
Expand Down