From abb55425656f13149e0d262550250eb58f723443 Mon Sep 17 00:00:00 2001 From: Ross Johnson <159597299+rosco54@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:45:12 +1000 Subject: [PATCH] In niceScale() when passed yMin and yMax indicate no data, cannot simply use w.globals.min and w.globals.max because the user may have configured one or both as a function, which can cause those global values to be poor substitutes causing undefined behaviour. Substitute sane default values in that case. --- src/modules/Scales.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/modules/Scales.js b/src/modules/Scales.js index a95b2ae55..dca8a1fe3 100644 --- a/src/modules/Scales.js +++ b/src/modules/Scales.js @@ -69,19 +69,8 @@ export default class Scales { (yMin === Number.MIN_VALUE && yMax === -Number.MAX_VALUE) ) { // when all values are 0 - if (gotMin && gotMax) { - yMin = gl.minY - yMax = gl.maxY - } else if (gotMin) { - yMin = gl.minY - yMax = yMin + ticks - } else if (gotMax) { - yMax = gl.maxY - yMin = yMax - ticks - } else { - yMin = 0 - yMax = ticks - } + yMin = Utils.isNumber(axisCnf.min) ? axisCnf.min : 0 + yMax = Utils.isNumber(axisCnf.max) ? axisCnf.max : yMin + ticks gl.allSeriesCollapsed = false }