Skip to content

fix: Update legend maxheight calculation logic #7483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 7, 2025

Conversation

camdecoster
Copy link
Contributor

@camdecoster camdecoster commented Jul 21, 2025

Description

Update the legend maxheight calculation logic to account for the legend being located above/below the plot. Closes #7473.

Changes

  • Updates the maxheight calculation logic
  • Moves the default calculation into the sizing method
  • Updates attribute description
  • Adds test mock for image comparison

Demo

Before After
image image

Testing instructions

  • Be on master
  • Create a mock using the config from this PR
  • Open the mock in Plotly DevTools
  • Note that the legend overlaps the plot
  • Switch to this branch
  • Open the mock in Plotly DevTools
  • Note that the mock shows up correctly

@camdecoster camdecoster marked this pull request as ready for review July 22, 2025 16:34
@archmoj archmoj added bug something broken regression this used to work labels Jul 24, 2025
@camdecoster camdecoster requested a review from emilykl July 30, 2025 20:10
@gvwilson gvwilson added P1 needed for current cycle fix fixes something broken and removed bug something broken labels Aug 5, 2025
Copy link
Contributor

@emilykl emilykl left a comment

Choose a reason for hiding this comment

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

See comments about the boolean logic and attribute description, otherwise looks good!

@camdecoster camdecoster requested a review from emilykl August 5, 2025 20:33
@emilykl
Copy link
Contributor

emilykl commented Aug 5, 2025

@camdecoster The new image test is failing, can you double check?

Comment on lines 44 to 45
'The reference height is the full layout height with the following exceptions: legends to the side of the plot',
'or vertically oriented legends with a `yref` of `"paper". In this case, the reference height is the plot height.'
Copy link
Contributor

Choose a reason for hiding this comment

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

@camdecoster I think the previous version of this docstring correctly reflects what is in the code after your latest changes -- can you confirm?

Suggested change
'The reference height is the full layout height with the following exceptions: legends to the side of the plot',
'or vertically oriented legends with a `yref` of `"paper". In this case, the reference height is the plot height.'
'The reference height is the full layout height, except in the case of vertically oriented legends with',
'a `yref` of `"paper" located to the side of the plot, in which case the reference height',
'is the plot height.'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we discussed, you're right. In some JS-like pseudocode:

isAboveBelow = isBelowPlotArea || isAbovePlotArea
!(isAboveBelow || !(orientation === "v" && yref === "paper")) -> !isAboveBelow && !(!(orientation === "v" && yref === "paper")) -> !isAboveBelow && (orientation === "v" && yref === "paper")

I'll switch it back the description back.

For future Cam reference, remember De Morgan's laws.

@camdecoster camdecoster merged commit 540e335 into master Aug 7, 2025
6 checks passed
@camdecoster camdecoster deleted the cam/7473/update-legend-maxheight-logic branch August 7, 2025 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix fixes something broken P1 needed for current cycle regression this used to work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vertical legend sizing/positioning broken
4 participants