Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Is there a way to tell when a hovertext/tooltip is flipped?

On a plotly_hover event, I would like to call getBoundingClientRect() to get the position of the hovertext/tooltip. The thing is that when hovering on data point close to the edge of a chart/window, the hovertext/tooltip gets flipped to the other side of the data point so it doesn’t get cut off.

Is there any indication from plotly that could tell me that the hovertext has been flipped?

I also saw another thread about using the hover event to find the location of the hover in px, but I assume that depending on the type of the value, you would use different methods to convert, e.g. d2p(), l2p(), etc?

Is there any indication from plotly that could tell me that the hovertext has been flipped?

Not at the moment.

Can you share an example of your getBoundingClientRect() call?

Maybe there’s a hacky way to get this done.

Thanks @etienne. Figured out a workaround by checking for mouse position on plotly_beforehover event to make the best guesstimate for that.

1 Like