Additional context
I spotted where the issue is coming from : basically the findNode method in Mesh hooks relies on d3-delaunay and specifically on delaunay.find method. With no data points given, the .find returns NaN and it isn't a case checked in the code so we try to access the node related to the index and it crashes because it's undefined.https://github.com/plouc/nivo/blob/da6d6b751cff5570fb7378d57b52e3e4bdbcf872/packages/voronoi/src/hooks.ts#L172-L179
I've already opened an issue on d3-delaunay side because I don't think NaN is really an expected behavior π You can find the issue opened here : https://github.com/d3/d3-delaunay/issues/144
On our side, I've patched Nivo to return null when nodes.length === 0. So I have a fix ready if you want me to handle it, but I'm not sure that's how you want to handle it π
Describe/explain the bug When hovering a Line Chart with empty data, the chart crashes.
To Reproduce Here is the link to a Codesandbox showing the issue : https://codesandbox.io/p/sandbox/charming-mendel-3wsx4v?file=%2Fsrc%2Fcomponents%2FLineChart.js%3A110%2C25
Steps to reproduce the behavior:
Expected behavior No crash π
Additional context I spotted where the issue is coming from : basically the
findNode
method in Mesh hooks relies ond3-delaunay
and specifically ondelaunay.find
method. With no data points given, the.find
returns NaN and it isn't a case checked in the code so we try to access thenode
related to theindex
and it crashes because it'sundefined
.https://github.com/plouc/nivo/blob/da6d6b751cff5570fb7378d57b52e3e4bdbcf872/packages/voronoi/src/hooks.ts#L172-L179I've already opened an issue on
d3-delaunay
side because I don't thinkNaN
is really an expected behavior π You can find the issue opened here : https://github.com/d3/d3-delaunay/issues/144On our side, I've patched Nivo to return
null
whennodes.length === 0
. So I have a fix ready if you want me to handle it, but I'm not sure that's how you want to handle it π