Closed calin-stan closed 2 years ago
This effect is caused by function Points
, which reverses an array before rendering points. The problem should be fixed by #1963 by @benurb.
(Curiously, launching an app with React 18's createRoot syntax also makes the tooltips appear at the correct positions, even without the fix.)
The fix has been merged.
Describe/explain the bug The tooltip rendered when hovering a point is for the "inverse" element of the hovered one. It makes more sense when you try and reproduce it in the code sandbox examples.
If I have
n
elements on my chart and hover over the first element, the tooltip of the last element is rendered, if I hover over the second one, the tooltip for the second to last is shown, and so on...To Reproduce I have created two examples in codesandbox. The code is exactly the same with the exception being the order of the
points
andmesh
elements in thelayers
array. If thelayers
array is something like this['points', 'mesh']
then everything is good and tooltips work as expected. If thelayers
array is something like this['mesh', 'points']
then the tooltips are rendered incorrectly.Disclaimer: I'm not sure if this issue also affects other types of charts. I have only noticed it occurring for the
ResponsiveLine
component from @nivo/lineExamples:
Steps to reproduce the behavior:
Expected behavior I'd expect that either the order of the elements of the
layers
array doesn't matter and everything works as expected no matter how you specify the elements, or the documentation is updated to reflect that the order in which you specify the elements is important.Desktop (please complete the following information):