GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Fix tex hover label name truncation and rotated label placement by SergeyAxiomatic · Pull Request #8138 · plotly/plotly.js Conversation
Contributor
Follow-up to #8051, fixing two problems @Lexachoc reported there (#8051 (comment) and the comment before it). What changedTex trace names were truncated by Tex was misplaced in rotated hover labels. With ReproductionBoth reproduce on TestsNew cases in
Not includedTex 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
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsTwo 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 <[email protected]> Co-Authored-By: Claude Sonnet 5.5 <[email protected]> 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 <[email protected]>
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. In Firefox, getBoundingClientRect on the g.<class>-math-group wrapper can report a near-empty box (2x0.2px for a 130x14px formula on a rotated hover label) while the glyph group inside it measures correctly. The hover label box was sized from that, so rotated tex names got a ~8px wide box. getMathOrTextNode now returns the glyph group; the rotated-label test measures the glyphs too. Reproduced and verified in Firefox 157 and Chrome. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
KoolADE85
requested changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @SergeyAxiomatic thanks for submitting this PR! It's going to be a very helpful fix! As I reviewed this PR, most of my comments were actually variations on the same theme: we should measure labels once and reuse computed values. Basically, I'm trying to steer us in a direction: I want us to move closer to handling mixed plaintext + LaTeX labels (understanding that this will still require much more work). My proposals are around doing things "one way" and following existing patterns/approaches. Let me know if anything is unclear. And thanks again for your work in this area!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm questioning this new parameter for Plain text labels don't need it, and I'd like to find a way to treat the labels the same way.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
1058
to
1059
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once MathJax finishes, the Mathjax promise callbacks call A rotated element measures larger than it really is, which is why this PR needs its extra rotation handling. And measuring again gives a second chance for the result to differ from the first measurement. As in
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A rotated or scaled label measures differently from how it was laid out. That is the problem this PR works around for rotation, and the same cause leaves tex off-centre when the graph is scaled with CSS (for example I think it should accept an already-measured, unrotated size instead, so we measure once and reuse the result. We can render the tex in place and unrotated with
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
+310
to
+312
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If the unrotated size is measured once and reused, as suggested in the other comments, hover would not need to look inside the tex output at all. The one place that already knows that structure is
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Rotation is already inferred a different way elsewhere in this file ( If we measure once with the rotation cleared, as suggested in the other comments, we never need to detect rotation here at all.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
+2655
to
+2656
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes With We should update attr description. Note the description is part of the schema, so
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test only covers the tex in the name label, but the fix also moves the tex in the main label. Could you add a case where the main label is a single tex expression (for example
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsReview follow-up. The rotated-label fix detected rotation (getScreenCTM) and measured differently in repositionMathGroup than at first placement. Instead, hover now records the tex size measured in the neutral, unrotated state (where finalizePosition and positionCommonLabel already measure) and passes it back into repositionMathGroup, so a label is never re-measured while rotated. - positionMathGroup takes an explicit size; convertToTspans measures exactly as before, so titles, annotations and ternary are unchanged - repositionMathGroup accepts and returns a size; the unrotated flag and getUnrotatedSize are gone - getMathOrTextNode becomes getTextClientRect, so hover no longer handles MathJax's nodes; it still measures the glyphs, as Firefox can report a near-empty rect for the wrapping group - document that a tex name ignores hoverlabel.namelength, and regenerate the schema - add a test for a tex main label in rotated hovermode y Co-Authored-By: Claude Sonnet 5.5 <[email protected]> repositionMathGroup now measures the typeset group with getBBox, which reports its size in the group's own units, instead of its client rect. The size no longer changes when the group or the graph is rotated or scaled, and it matches what positionText uses for plain text. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersRequested changes must be addressed to merge this pull request. Uh oh!
There was an error while loading. Please reload this page. AssigneesLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. 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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |