Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flickering tip #1805

Closed
yurivish opened this issue Aug 14, 2023 · 4 comments · Fixed by #1826
Closed

Flickering tip #1805

yurivish opened this issue Aug 14, 2023 · 4 comments · Fixed by #1826
Labels
bug Something isn’t working

Comments

@yurivish
Copy link
Contributor

yurivish commented Aug 14, 2023

I recently built a page that has some charts using tips as chart annotations controlled by a range slider, and noticed that the tooltips sometimes "flicker" before being rendered at their final position. I was following along with tip development a while back and if I remember, there's some layout computation that happens post-initial render, so I wonder if it might have to do with that.

I created a mini test case here. It's hard to get a screenshot, but in Chrome & Safari on macOS I see the tip text appear at the bottom right of the annotated datum for just a moment while I slide the slider, before re-appearing at the top left as requested by the anchor option, along with the rest of the tip.

@mbostock mbostock added the bug Something isn’t working label Aug 14, 2023
@mbostock
Copy link
Member

Thanks for the test case. Yes, this is because the tip renders asynchronously — we need the tip to be attached to the DOM in order to compute exact text metrics as described here:

plot/src/marks/tip.js

Lines 217 to 218 in 63415aa

// Only after the plot is attached to the page can we compute the exact text
// metrics needed to determine the tip size and orientation (anchor).

We can probably find a way to hide the tip text so that it’s not briefly visible before the tip finishes rendering.

Fil added a commit that referenced this issue Aug 23, 2023
@Fil Fil mentioned this issue Aug 23, 2023
@Fil
Copy link
Contributor

Fil commented Aug 23, 2023

please paste this in your notebook to test #1826:

Plot = import("https://esm.sh/gh/observablehq/plot@834810e5e05193191a97ab6d750c4f329a97bd55")

It's not perfect in the sense that the tip doesn't have time to show, but at least it's not showing in the wrong place.

mbostock added a commit that referenced this issue Aug 23, 2023
* closes #1805

* tests

* conditional postrender

---------

Co-authored-by: Mike Bostock <mbostock@gmail.com>
@yurivish
Copy link
Contributor Author

Thank you @Fil and @mbostock! This is much better – and yeah, I suspect with SVG layout there may always be tradeoffs to make. And cool, I didn't know you could import specific hashes with esm.sh; I've been cloning the repository and rebuilding locally to try out Plot branches. Thanks for the tip.

@Fil
Copy link
Contributor

Fil commented Aug 24, 2023

I recently learned this trick from @mootari; the documentation at https://esm.sh is worth a read!

chaichontat pushed a commit to chaichontat/plot that referenced this issue Jan 14, 2024
* closes observablehq#1805

* tests

* conditional postrender

---------

Co-authored-by: Mike Bostock <mbostock@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants