Uh oh!
There was an error while loading. Please reload this page.
Fix: legend sizing for MathJax names - #7927
Conversation
| var vbWidth = (vbParts[2] / 1000) * emPx; | ||
| var vbHeight = (vbParts[3] / 1000) * emPx; |
There was a problem hiding this comment.
Hi @rajnisht7, can you explain why this calculation gives the correct width and height?
emilykl
commented
Aug 4, 2026
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 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 Thanks for your work so far! |
rajnisht7
commented
Aug 5, 2026
@emilykl Thank you for the review, MathJax draw its math using its own internal units wherer 1000units =1em which was confirmed by a MathJax member on this issue mathjax/MathJax#2003 (comment) The viewbox on the svg that MathJax creates already contains the exact size info, and we also know the real font size of text, we can turn that into real pixel size with pixelWidth = (viewBoxWidth / 1000) * fontSizeInPixels and it works better than Drawing.bBox() because it never use math. and if anything about this is missing or doesn't give a proper number,the code falls back to the old it can be tested using: open this file in firefox also applied the same fix to the |
Bug fix:
When a trace's
namecontains 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