Conversation
Unified hover labels draw their items through the legend, which always anchors item text at the start. The resolved hoverlabel.align of each point was never read there, so layout and trace values had no effect. Items with align 'right' now anchor at the right edge of the label. Closes plotly#8100
camdecoster
requested changes
Oct 3, 2026
camdecoster
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the PR! This looks like a reasonable solution. Could you please address the failing test in CI? Also, could you update the hoverlabel.align description in fx/layout_attributes.js to fix the typo?
| _hover(gd, { xval: 1 }); | ||
| const [short, long] = getItems(); | ||
| expect([short.anchor, long.anchor]).toEqual(['end', 'start']); | ||
| expect(short.right).toBeCloseTo(long.right, 0); |
Contributor
There was a problem hiding this comment.
This check is failing in CI. It's likely due to font rendering differences between your computer and CI. You could change the check to the following to make it a bit more forgiving:
Suggested change
| expect(short.right).toBeCloseTo(long.right, 0); | |
| expect(short.right).toBeWithin(long.right, 1); |
The description read "spans more two or more lines". The right-edge check compared positions to the nearest pixel, and font rendering differs between machines, so it failed in CI.
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.
Description
Make
hoverlabel.aligntake effect inx unifiedandy unifiedhover labels. The unified label draws its items through the legend, and the legend always anchored item text at the start. Each item now reads thehoverlabel.alignvalue of its point, so the layout value and the trace values both apply. With'right', the item text aligns to the right edge of the label.'left'and'auto'keep the current output.The title of the label stays left-aligned. I can align it with the items too if you prefer.
Closes #8100.
Changes
hoverlabel.align: 'right'at the right edge of the labelhover_test.jsfor the layout value and a trace valueScreenshots
Repro from the issue,
layout.hoverlabel.align: 'right'Testing
npm run test-jasmine -- hover legend --nowatchpasses (357 specs). The new spec fails onmain.