From d491b7844aca531bfc3232566200315073f5d6f6 Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Mon, 7 Jun 2021 11:59:56 -0500 Subject: [PATCH] fix: prevent min/reduce calls always returning a 0 value --- assets/js/scale.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/scale.js b/assets/js/scale.js index 08f91e5..8a944b9 100644 --- a/assets/js/scale.js +++ b/assets/js/scale.js @@ -39,7 +39,7 @@ export class RelativeScale { // https://stackoverflow.com/questions/63705432/maximum-call-stack-size-exceeded-when-using-the-dots-operator/63706516#63706516 const max = nonNullData.reduce((a, b) => { return Math.max(a, b) - }, 0) + }, Number.NEGATIVE_INFINITY) return RelativeScale.scale( [0, RelativeScale.isFiniteOrZero(max)], @@ -70,10 +70,10 @@ export class RelativeScale { // https://stackoverflow.com/questions/63705432/maximum-call-stack-size-exceeded-when-using-the-dots-operator/63706516#63706516 const min = nonNullData.reduce((a, b) => { return Math.min(a, b) - }, 0) + }, Number.POSITIVE_INFINITY) const max = nonNullData.reduce((a, b) => { return Math.max(a, b) - }, 0) + }, Number.NEGATIVE_INFINITY) return { min: RelativeScale.isFiniteOrZero(min),