Closed davidruisinger closed 3 years ago
Sounds useful, I'll add it tomorrow!
So I took a bit longer but it landed in v5.4.0 π
You can add initialTooltipIndex
to <Line />
Thatβs what I call a Christmas present π
@N1ghtly Unfortunately the initialTooltipIndex
prop is not working for me. I think the reason behind this is that my Chart is re-rendered as soon as the data has been fetched from the BE.
The data
update triggers the useEffect
within the Line
component which than tries to update the index with setTooltipIndex
. Since until now the user did not touch any datapoint the newIndex
will be undefined
.
After adding an extra check for undefined
here it seems to work for me but I'm not sure wether this would have any other implications
if (newIndex !== undefined && newIndex !== tooltipIndex) {
setTooltipIndex(newIndex)
...
Hmm I see, I'll probably have to keep a boolean whether the user has touched the chart or not. Not my favorite solution but I don't see another one atm. I'll try to get it in today π
Isn't the lastTouch
from context already enough to check wether the user has touched the chart? Anyways, thanks for the effort!
Not really, because lastTouch is set to undefined when touch is released after a pan. But maybe I'll rework that system because it's not very clear this way. Was a bit busy but should have time tomorrow!
Hi @flavordaaave, it should work in v5.4.1 as long as the user doesn't manually place the tooltip somewhere between renders :)
First of all, really nice library you got there!
When my chart is shown I always want top preselect the last dataPoint in the chart so it would be really great if the library would allow me to programmatically select a dataPoint.