Skip to content

Commit 52e3b0b

Browse files
authored
Merge pull request #4378 from rosco54/Issue_4357
Fix for #4357
2 parents 20d03f8 + 3b8cc99 commit 52e3b0b

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/modules/Scales.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ export default class Scales {
282282
} else {
283283
let yMaxPrev = yMax
284284
yMax = stepSize * Math.ceil(yMax / stepSize)
285+
if (Math.abs(yMax - yMin) / Utils.getGCD(range, stepSize) > maxTicks) {
286+
// Use default ticks to compute yMin then shrinkwrap
287+
yMax = yMin + stepSize * ticks
288+
yMax += stepSize * Math.ceil((yMaxPrev - yMax) / stepSize)
289+
}
285290
}
286291
}
287292
range = Math.abs(yMax - yMin)
@@ -314,16 +319,6 @@ export default class Scales {
314319
stepSize = Math.round(range / tiks)
315320
}
316321

317-
// Record final tiks for use by other series that call niceScale().
318-
// Note: some don't, like logarithmicScale(), etc.
319-
if (
320-
gl.isMultipleYAxis
321-
&& gl.multiAxisTickAmount == 0
322-
&& gl.ignoreYAxisIndexes.indexOf(index) < 0
323-
) {
324-
gl.multiAxisTickAmount = tiks
325-
}
326-
327322
if (
328323
tiks > maxTicks &&
329324
(!(gotTickAmount || gotStepSize) || axisCnf.forceNiceScale)
@@ -386,6 +381,17 @@ export default class Scales {
386381
} else {
387382
stepSize = range / tt
388383
}
384+
tiks = Math.round(range / stepSize)
385+
}
386+
387+
// Record final tiks for use by other series that call niceScale().
388+
// Note: some don't, like logarithmicScale(), etc.
389+
if (
390+
gl.isMultipleYAxis
391+
&& gl.multiAxisTickAmount == 0
392+
&& gl.ignoreYAxisIndexes.indexOf(index) < 0
393+
) {
394+
gl.multiAxisTickAmount = tiks
389395
}
390396

391397
// build Y label array.

0 commit comments

Comments
 (0)