Abort intermediate hover events

I have a bar chart plot that represents a timeline, and it may contain a lot of bars. Then I have a plotly_hover event that highlights the hovered event (which may consist of a few bars) using Plotly.update to change the marker.line.width of the hovered bar.

What bothers me is that when I move the mouse in the plot, it triggers many hover events “on the way” while I’m moving the mouse - even after the mouse reached one bar that I want to highlight, it still highlights 1 on the way, taking a second or so to change to the intermediate one and another second to the target one. That does not give a very “fluid” feel on the graph. Is there a way to “abort” these intermediate hover events to happen, i.e., when I change the hovered bar, it cancels previous triggers of hover events? (Or maybe abort the Plotly.update that is done on that intermediate trigger)

(Here is a video showing what I mean.)

Check this

https://codepen.io/saratoga01/pen/NPWzWNz?editors=0011

Yes! That’s a very good idea! Thank you once again @Saratoga! Now it’s much better - it still takes a second or so to highlight, but this is because I have a heavy bar chart.

1 Like