Skip to content

Commit

Permalink
feat(scales): exclude null and undefined values in log scale validati…
Browse files Browse the repository at this point in the history
…on (#1099)

* Exclude null and undefined in log scale validation

* Fixed formatting

Co-authored-by: Thomas Flanitzer <thomas.flanitzer@zuehlke.com>
  • Loading branch information
tflanitzer and Thomas Flanitzer committed Nov 11, 2020
1 parent 8451c27 commit c87eba7
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/scales/src/logScale.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c87eba7

Please sign in to comment.