React state change doesn't always trigger a chart redraw #2221
Labels
Issue: Accepted
The submitted issue has been confirmed by the Victory core team
Type: Enhancement ✏️
An enhancement or feature proposal that will be addressed after the next release
I am trying to create a line chart where hovering over an activate data point will also show a vertical line at that point - as per gif below.
The intention is for the green line to only appear when a point on the chart is active, meaning it should hide once the user moves the mouse away from the chart and no scatter point is selected.
I have some code that achieves this outcome but it uses react state, and changes to the state don't always re-render the chart. The code checks if there is an active object, and only renders the line if there is. However due to the state being one step behind (usually), the line doesn't disappear when you roll off the chart.
Is there a better approach to what I'm trying to achieve here or a way I can force the chart to update when
active
becomes null?Another issue here is that when using
voronoiDimension="x"
it makes the tooltip move with the mouse on the y-axis. Is there a way to prevent that? It looks like the only way is to remove §voronoiDimension="x"
, but then you no longer get the desired mouse/point detection.As well as this issue, there seems to be a bug when rolling over the first scatter data point -
Unhandled Runtime Error TypeError: Cannot read properties of undefined (reading 'name')
Any help would be appreciated.
Thanks,
Matt
The text was updated successfully, but these errors were encountered: