kimikage / ProfileSVG.jl

Write flame graphs to SVG format and explore them interactively in Jupyter, Pluto, etc.
MIT License
53 stars 7 forks source link

Improvement of text width estimation #32

Closed kimikage closed 4 years ago

kimikage commented 4 years ago

The texts for the function information are truncated to fit their flame rectangles. Currently, the hard-coded average width of characters is used for the text width estimation.

https://github.com/kimikage/ProfileSVG.jl/blob/6df38434586f521db33fcdfc80a0fdc1a078c417/src/viewer.js#L44 https://github.com/kimikage/ProfileSVG.jl/blob/6df38434586f521db33fcdfc80a0fdc1a078c417/src/viewer.js#L51-L59

However, I plan to make the font and font size customizable in a fix for issue #8. Therefore, the average character width cannot be known in advance. Moreover, the current estimation method is not so accurate with proportional fonts. textwidth

SVG has the ability to clip shapes with clipping paths, but this technique has the problem of growing the DOM tree.

There is also an API to get the bounding box of the text, but this is expensive. In particular, even if we find that the text overflows by calculating its bounding box, we don't know how many characters to be truncated.

I would like to implement a slightly better statistical estimation method.

kimikage commented 4 years ago

BTW, I will add an option to hide the texts in the near future.