Skip to content
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

Legend cannot be scrolled to the end if xref/yref is set to container #7072

Open
attatrol opened this issue Aug 6, 2024 · 1 comment · May be fixed by #7158
Open

Legend cannot be scrolled to the end if xref/yref is set to container #7072

attatrol opened this issue Aug 6, 2024 · 1 comment · May be fixed by #7158
Labels
bug something broken P2 needed for current cycle

Comments

@attatrol
Copy link

attatrol commented Aug 6, 2024

If a legend is anchored to the container, the container sizes aren't taken into account when the legend sizes are computed.

In the example codepen legends aren't visible fully and it is not possible to scroll then to the end.

function computeLegendDimensions should take into account the container sizes for calculation of _maxHeight and _maxWidth

@attatrol
Copy link
Author

attatrol commented Aug 6, 2024

My fix for _maxHeight calculation:

  // - if below/above plot area, give it the maximum potential margin-push value
  // - otherwise, extend the height of the plot area
  legendObj._maxHeight = Math.max(
    (isBelowPlotArea || isAbovePlotArea) ? fullLayout.height / 2 : gs.h,
    30
  );
  // _maxHeight is also limited by the container if it is anchored to it
  if (legendObj.yref === 'container' && legendObj._maxHeight > 30) {
    var yanchor = getYanchor(legendObj);
    var containerAllowedHeight;
    if (yanchor === 'top')
      containerAllowedHeight = legendObj.y * fullLayout.height;
    else if (yanchor === 'bottom')
      containerAllowedHeight = (1 - legendObj.y) * fullLayout.height;
    else // if (yanchor === 'middle')
      containerAllowedHeight = 2 * Math.min(1 - legendObj.y, legendObj.y) * fullLayout.height;
    legendObj._maxHeight = Math.min(containerAllowedHeight, legendObj._maxHeight);
  }

@gvwilson gvwilson added bug something broken P2 needed for current cycle labels Aug 7, 2024
@attatrol attatrol linked a pull request Sep 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P2 needed for current cycle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants