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

performance bottleneck caused by getComputedTextLength #23

Closed
beardhatcode opened this issue Aug 14, 2019 · 1 comment
Closed

performance bottleneck caused by getComputedTextLength #23

beardhatcode opened this issue Aug 14, 2019 · 1 comment
Labels

Comments

@beardhatcode
Copy link
Contributor

If there are a lot of matches in a sunburst, getComputedTextLength gets called a lot. Each call forces a re-layout. But this is not necessary because the pie pieces are too small to even see the name.

shot

I have taken a look at the code and i do not immediately see how to fix this. The function is used to precompute all textlengths at first draw.

A heuristic might help (First printing all of [a-zA-Z0-9 -]) and computing only their lengths. To estimate the length of a new word we could just add the values form the map that correspond to the characters in the string.

Original issue by @beardhatcode on Wed Apr 11 2018 at 15:31.

@pverscha pverscha changed the title perforamance bottleneck caused by getComputedTextLength performance bottleneck caused by getComputedTextLength Mar 5, 2021
@pverscha
Copy link
Member

pverscha commented Mar 5, 2021

I did only spot this issue now, but I have actually resolved this problem in version 2.0 of the sunburst. The available height of each piece of the chart is computed (as well as the height of the text that should fit into this piece) and the text is now only rendered if it fits into the piece of the chart.

I also noticed that the getComputedTextLength function is very slow in Chromium-based browsers. The measureText() function of OffscreenCanvas proves to be a lot faster, resolving this bottleneck :)

@pverscha pverscha closed this as completed Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants