{{ message }}
Repository navigation
Fix tex hover label name truncation and rotated label placement - #8138
Open
SergeyAxiomatic wants to merge 3 commits into
Open
SergeyAxiomatic wants to merge 3 commits into
SergeyAxiomatic wants to merge 3 commits into
Conversation
Two follow-ups to plotly#8051, reported on that PR: - A trace name that is a single tex expression was cut to hoverlabel.namelength (default 15) before the pure-tex check, which dropped the closing $ so it was never typeset. Skip truncation for pure-tex names. - In hovermode 'y' with several traces the labels are rotated, and positionMathGroup measured the glyphs with getBoundingClientRect, which is the larger screen-space box of the rotated shape, so the math landed far from its label. Measure in the group's own coordinates when an ancestor is rotated. The draftlog file name carries a placeholder PR number to be renamed once the PR is opened. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Measuring the typeset glyphs in their own coordinates when an ancestor is rotated also moved the rotated ternary axis titles, which go through convertToTspans and failed the ternary-mathjax image baselines. Only repositionMathGroup (used by hover labels) opts in now; convertToTspans measures exactly as before. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Follow-up to #8051, fixing two problems @Lexachoc reported there (#8051 (comment) and the comment before it).
What changed
Tex trace names were truncated by
hoverlabel.namelength. A trace name that is a single tex expression was cut tonamelength(default 15) before the pure-tex check ran. That removed the closing$, so a long formula was never typeset and showed up as$\alpha_{1c}.... Settinghoverlabel.namelength: -1worked around it.plainTextinhover.jsnow skips truncation when the whole string is one tex expression; plain-text names are still truncated.Tex was misplaced in rotated hover labels. With
hovermode: 'y'and more than one trace, hover labels are rotated.positionMathGroupmeasured the typeset glyphs withgetBoundingClientRect, which returns the larger screen-space box of the rotated shape (for example 75x116 for a glyph group that is really about 75x14), so the math group landed tens of pixels from its label. It now measures in the group's own coordinates when an ancestor is rotated (getBBoxtimes the SVG's letterbox scale). When nothing is rotated it uses the same measurement as before, so titles, annotations and unrotated hover labels are unaffected.Reproduction
Both reproduce on
mainwith the mock from the linked comment, minus thehoverlabelstyling from #8115. For the second one, hover near the top point withhovermode: 'y'so that several labels are shown and rotated.Tests
New cases in
test/jasmine/bundle_tests/mathjax_test.js:main);hovertemplate<extra>is not truncated (already passed; guards that path);hovermode: 'y'(fails onmain, off by about 73px).karma start test/jasmine/karma.conf.js --bundleTest=mathjax_test.js --nowatchpasses 20/20, andnpm run test-jasmine -- svg_text_utils hover legend annotations --nowatchpasses 456/456. I also checked the rotated case in the browser before and after.Not included
Tex in unified hover is still limited to rows that are a single tex expression. That is the existing scope from #8051, not something this change affects.
🤖 Generated with Claude Code