Skip to content

Fix: legend sizing for MathJax names - #7927

Open
rajnisht7 wants to merge 4 commits into
plotly:masterfrom
rajnisht7:firefox-legend-fix
Open

Fix: legend sizing for MathJax names#7927
rajnisht7 wants to merge 4 commits into
plotly:masterfrom
rajnisht7:firefox-legend-fix

Conversation

@rajnisht7

@rajnisht7 rajnisht7 commented Aug 1, 2026

Copy link
Copy Markdown

Bug fix:

When a trace's name contains LaTeX/MathJax (e.g. $\alpha_{1c} = 352$), the legend sometimes renders too small to fit the math cutting it off completely. This mostlyshows up in Firefox, but the underlying bug isn't Firefox-specific.
This PR tries to resolve this bug

Fixes #559

Comment on lines +781 to +782
var vbWidth = (vbParts[2] / 1000) * emPx;
var vbHeight = (vbParts[3] / 1000) * emPx;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rajnisht7, can you explain why this calculation gives the correct width and height?

@emilykl

emilykl commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Thank you @rajnisht7 for the contribution! It would be great to fix this bug.

However I'm not totally confident that we can count on the viewBox attribute to get the correct width and height. If you think this approach is reliable, could you provide a bit more explanation?

If you can provide steps for reproducing and verifying the fix, that would also be helpful.

Also, we have recently updated the MathJax handling to support MathJax v4. Any approach used here will need to work with the new MathJax logic and support MathJax v3 and v4. Those changes are on the v4.0 branch, which will be merged into master on the release of the 4.0 version. So I would recommend that you either rebase these changes onto the v4.0 branch, or wait until v4.0 has been merged into master and verify whether the fix still works with the latest MathJax changes.

Thanks for your work so far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MathJax does not render in hover labels

3 participants