Skip to content

Commit

Permalink
fix(calendar): fix crash when no data is empty
Browse files Browse the repository at this point in the history
* Fix error when no data is available

* Check for data array length

* Run formatter and linter
  • Loading branch information
mdorr authored and Raphaël Benitte committed Jul 19, 2018
1 parent ec971b3 commit 5ac4214
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/nivo-calendar/src/enhance.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export default Component =>
withPropsOnChange(['data', 'domain', 'colors'], ({ data, domain, colors }) => {
let colorDomain
if (domain === 'auto') {
colorDomain = [minBy(data, 'value').value, maxBy(data, 'value').value]
if (data.length === 0) {
colorDomain = [0, 0]
} else {
colorDomain = [minBy(data, 'value').value, maxBy(data, 'value').value]
}
} else {
colorDomain = [...domain]
}
Expand Down

0 comments on commit 5ac4214

Please sign in to comment.