plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

Ploty.js in Shadow DOM hover flicker

Open dbluhm opened this issue 6 years ago • 14 comments

When Plotly.js is rendered inside of a ShadowDOM, the hover elements rapidly draw, clear, and redraw causing a flickering effect on mousemove events under specific conditions.

Demonstration in codepen

And a GIF hover-flicker

For comparision, here is the same example as above using the Light DOM: Demonstration in codepen

And a GIF expected-hover

When it comes to support for Plotly.js in Shadow DOM, there are other issues in addition to this one but, as demonstrated in the first code pen, there are workable fixes I can make as a user in most cases (i.e. the styling inside of the template...) but this particular issue is not so easily worked around as a user.

dbluhm avatar Nov 14 '20 21:11 dbluhm

I am having the same issue. After some digging the problem could be tracked down to all plots which are using a rect with class="nsewdrag drag" for the tooltips. This includes all plots using a cartesian coordinate system.

Other plots like Sankey diagrams are not affected.

The difference we found was that for the plot where the problems exist the tooltips are not triggered by hovering over the visible objects directly (underlined in blue) but by the extra layer mentioned above (underlined in red). image

In other types of plots where the tooltip does not rely on that additional layer there is no problem.

As far as I understand the mouseposition within the rect is compared to that of the graphical elements in the plot. If there is a match the tooltip is shown.

I would like to help fixing that issue. Is there any idea what could be causing it?

alexandergerber avatar Jan 03 '21 12:01 alexandergerber

@alexandergerber to clarify, this is occurring within a ShadowDOM element and the behavior is not exhibited in normal "LightDOM" elements?

dbluhm avatar Jan 04 '21 18:01 dbluhm

@dbluhm Yes. I am trying to use plotly within a Web Component. Outside ShadowDOM elements it works correctly.

alexandergerber avatar Jan 04 '21 19:01 alexandergerber

@alexandergerber does the codepen I shared also encapsulate your findings? If not, would you be able to provide one that does? I think that would help ensure we're looking at the same issue. It might also be interesting to try out changes from the (incomplete) PR I have open addressing this issue and seeing if that fixes the behavior you're seeing on the other graphs

dbluhm avatar Jan 04 '21 19:01 dbluhm

I would say it is exactly the same issue. I checked out your pull request and can try if it fixes the problem for me. When I have tested your changes I'll report my findings.

alexandergerber avatar Jan 04 '21 19:01 alexandergerber

We tested this and it seems not to work for our plots. It seems that the problem only occurs in the lower part of the plot and also only at specific pixels.

alexandergerber avatar Jan 06 '21 17:01 alexandergerber

unfortunately we also have the same problem. the unhover event gets fired even if the mouse is on the box or the bar. that causes the tooltip to disappear of course and even if we used a custom tooltip we still depend on the unhover event fired from plotly to know when to hide the tooltip.

I have added here some screenshots from the code and hopefully someone can help fix this issue soon.

the Tooltip disappears back and forth because of the unhover event.

E38A5199-F8BC-4749-B483-D4AD168B

the function where we listen to the unhover event from plotly

image

the function where we fetch the html div element from the shadow root

image

magdyamr542 avatar Jan 06 '21 17:01 magdyamr542

We tested this and it seems not to work for our plots. It seems that the problem only occurs in the lower part of the plot and also only at specific pixels.

It seems working on this codepen. How did you test it? Please provide a minimal codepen illustrating the problem.

archmoj avatar Jan 06 '21 17:01 archmoj

it does not work as expected in the codepin that you sent me either. the tooltip disappears frequently even if iam still on the bar.

this codepen prints in console the unhover events. you can see that the unhover event gets fired over and over again with the mouse being on the bars.

i hope this could help.

magdyamr542 avatar Jan 06 '21 18:01 magdyamr542

Ich also checked out the codepen example. I found the problem there as well. plotly_issue

It also seems worse in the bottom part of the graph.

alexandergerber avatar Jan 06 '21 18:01 alexandergerber

Fixed by #5256.

archmoj avatar Jan 28 '21 20:01 archmoj

I don't think this should have been closed. I just tested it with 2.0 and the problem still persists.

alexandergerber avatar Mar 13 '21 17:03 alexandergerber

Just upgraded to version 2.2.0 - problem is still there!

LeUser111 avatar Jul 09 '21 08:07 LeUser111

Is there any update on this? I use version 2.33.0 and the issue still happens.

skordesign avatar Nov 20 '24 09:11 skordesign