Skip to content

fix: Keep Cartesian traces aligned with axes after automargin - #7958

Closed
gokul-debugger wants to merge 2 commits into
plotly:mainfrom
gokul-debugger:fix/title-automargin-slider-alignment
Closed

gokul-debugger wants to merge 2 commits into
plotly:mainfrom
gokul-debugger:fix/title-automargin-slider-alignment

Conversation

@gokul-debugger

Copy link
Copy Markdown
Contributor

Summary

Fixes #7750.

When an automargin-enabled plot title was displayed together with sliders or update menus, the title margin was calculated after the Cartesian plot layer had already been positioned. The axes used the updated margin, but the traces retained the earlier position.

This change draws the title during the existing margin-pusher phase so the title, controls, axes, and traces all use the same final plot dimensions.

A Jasmine regression test reproduces the reported slider and button configuration and verifies that the trace remains aligned with its corresponding y-axis tick.

Testing

  • npm run pretest
  • npm run lint
  • npm run test-syntax
  • npm run test-jasmine -- titles --nowatch
  • npm run test-jasmine -- titles sliders updatemenus plots --nowatch
  • npm run test-jasmine -- plot_api plot_api_react pie polar ternary geo gl3dlayout --nowatch

The new regression test fails on the unchanged upstream code with a 43.5 px displacement and passes with this fix.

The local Chrome 151 runs also contain existing rendering-tolerance failures. The same failures reproduce on the unchanged upstream branch, and this change introduces no additional failures.

@gokul-debugger
gokul-debugger marked this pull request as ready for review August 13, 2026 11:27
@robertclaus
robertclaus requested a review from emilykl August 13, 2026 19:47
@robertclaus
robertclaus requested review from KoolADE85 and removed request for emilykl September 15, 2026 20:11
@robertclaus robertclaus assigned KoolADE85 and unassigned emilykl Sep 15, 2026
@KoolADE85

Copy link
Copy Markdown
Contributor

Hey @gokul-debugger , thanks for looking into this issue and submitting the PR. Your work caught my attention and got me digging into the underlying bug. I found that the bug can be solved by removing a render step rather adding another render of the title.
I posted #8045 showing that.
While the tests are all passing, I'm curious if you have any real-world usage examples that you could test against, just in case there's a scenario that I'm missing?

Everything else being equal, I'd prefer to merge the version that removes code!

Thanks again.

@gokul-debugger

Copy link
Copy Markdown
Contributor Author

I tested #8045 against the original regression and additional slider-only, update-menu-only, and combined-control layouts. I also checked a larger automargin title and repeated Plotly.react calls. The trace and axis stayed aligned in every focused scenario.

Syntax and lint checks passed. The remaining local title-suite failures reproduce unchanged on upstream main and appear to be Chrome rendering tolerance differences.

The smaller fix in #8045 is preferable, so I am closing this PR in its favor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Trace doesn't line up with axis when having an automargin title and there are sliders/buttons displayed

3 participants