GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Apply `hoverlabel.align` to unified hover label items by MannXo · Pull Request #8104 · plotly/plotly.js

Conversation

@MannXo

@MannXo MannXo commented Oct 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

Make hoverlabel.align take effect in x unified and y unified hover labels. The unified label draws its items through the legend, and the legend always anchored item text at the start. Each item now reads the hoverlabel.align value 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

  • Anchor the text of unified hover items that have hoverlabel.align: 'right' at the right edge of the label
  • Add a test to hover_test.js for the layout value and a trace value
  • Add draftlog

Screenshots

Repro from the issue, layout.hoverlabel.align: 'right'

Before After
image image

Testing

  • npm run test-jasmine -- hover legend --nowatch passes (357 specs). The new spec fails on main.
  • Open Plotly devtools and paste the following into the browser devtools console, then hover over a category:
    const gd = Tabs.fresh();
    Plotly.newPlot(
        gd,
        [
            { type: 'bar', x: ['A', 'B', 'C'], y: [3944, 2810, 1675], name: 'Series 1' },
            { type: 'bar', x: ['A', 'B', 'C'], y: [-266, -1020, -85], name: 'Series 2' },
            { type: 'bar', x: ['A', 'B', 'C'], y: [-44, -310, -7], name: 'Series 3' }
        ],
        { barmode: 'relative', hovermode: 'x unified', hoverlabel: { align: 'right' } }
    );

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
MannXo added 3 commits October 3, 2026 21:25
@MannXo
fix: Apply hoverlabel.align to unified hover label items
79ee28d
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
@MannXo
Rename draftlog to the PR number
0366890
@MannXo
Link the draftlog to the PR
8f5eeaa
camdecoster
camdecoster requested changes Oct 3, 2026
View reviewed changes

@camdecoster camdecoster left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/jasmine/tests/hover_test.js Outdated
_hover(gd, { xval: 1 });
const [short, long] = getItems();
expect([short.anchor, long.anchor]).toEqual(['end', 'start']);
expect(short.right).toBeCloseTo(long.right, 0);

@camdecoster camdecoster Oct 3, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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);

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@camdecoster camdecoster self-assigned this Oct 3, 2026
MannXo and others added 6 commits October 4, 2026 17:29
@MannXo
Fix the hoverlabel.align description and loosen the right-edge check
6d29071
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.
@camdecoster
Merge remote-tracking branch 'origin/main' into fix/8100-unified-hove…
77d6d05
…rlabel-align
@camdecoster
Add CI debugging code
3915055
@camdecoster
Revert "Add CI debugging code"
1f96bfa
This reverts commit 3915055.
@camdecoster
Update test to check same rows
6b5f2b8
@camdecoster
Update draftlog
dc20017
camdecoster
camdecoster approved these changes Oct 5, 2026
View reviewed changes

@camdecoster camdecoster left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for the fix!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@camdecoster
camdecoster merged commit b6684b7 into plotly:main Oct 5, 2026
76 of 77 checks passed

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

Reviewers

@camdecoster camdecoster camdecoster approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@camdecoster camdecoster

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG]: hoverlabel.align is ignored in hovermode: "x unified"

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@MannXo @camdecoster
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.