From c87eba7d6e7539bc5de1a864d116191f852b9471 Mon Sep 17 00:00:00 2001 From: Thomas Flanitzer Date: Wed, 11 Nov 2020 08:47:22 +0100 Subject: [PATCH] feat(scales): exclude null and undefined values in log scale validation (#1099) * Exclude null and undefined in log scale validation * Fixed formatting Co-authored-by: Thomas Flanitzer --- packages/scales/src/logScale.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/scales/src/logScale.js b/packages/scales/src/logScale.js index c30536ee43..19eee22083 100644 --- a/packages/scales/src/logScale.js +++ b/packages/scales/src/logScale.js @@ -16,14 +16,16 @@ export const logScale = ({ axis, base = 10, min = 'auto', max = 'auto' }, xy, wi const hasZero = values.all.some(v => v === 0) let sign let hasMixedSign = false - values.all.forEach(v => { - if (hasMixedSign === true) return - if (sign === undefined) { - sign = Math.sign(v) - } else if (Math.sign(v) !== sign) { - hasMixedSign = true - } - }) + values.all + .filter(v => v != null) + .forEach(v => { + if (hasMixedSign === true) return + if (sign === undefined) { + sign = Math.sign(v) + } else if (Math.sign(v) !== sign) { + hasMixedSign = true + } + }) if (hasZero || hasMixedSign) { throw new Error(