8000 Fix legend container overflow by attatrol · Pull Request #7158 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Fix legend container overflow #7158

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Code formatting.
  • Loading branch information
godyaev committed Sep 17, 2024
commit 1fc426683642a7292c24b157a9c177f2eac0a5f7
12 changes: 6 additions & 6 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ function computeLegendDimensions(gd, groups, traces, legendObj) {
var traceGroupGap = legendObj.tracegroupgap;
var legendGroupWidths = {};

if (legendObj.yref === 'paper') {
if(legendObj.yref === 'paper') {
isBelowPlotArea = legendObj.y < 0 || (legendObj.y === 0 && yanchor === 'top');
isAbovePlotArea = legendObj.y > 1 || (legendObj.y === 1 && yanchor === 'bottom');
// - if below/above plot area, give it the maximum potential margin-push value
Expand All @@ -790,9 +790,9 @@ function computeLegendDimensions(gd, groups, traces, legendObj) {
30
);
} else {
if (yanchor === 'top')
if(yanchor === 'top')
legendObj._maxHeight = legendObj.y * fullLayout.height;
else if (yanchor === 'bottom')
else if(yanchor === 'bottom')
legendObj._maxHeight = (1 - legendObj.y) * fullLayout.height;
else // if (yanchor === 'middle')
legendObj._maxHeight = 2 * Math.min(1 - legendObj.y, legendObj.y) * fullLayout.height;
Expand Down Expand Up @@ -827,7 +827,7 @@ function computeLegendDimensions(gd, groups, traces, legendObj) {
}
} else {
var xanchor = getXanchor(legendObj);
if (legendObj.xref === 'paper') {
if(legendObj.xref === 'paper') {
var isLeftOfPlotArea = legendObj.x < 0 || (legendObj.x === 0 && xanchor === 'right');
var isRightOfPlotArea = legendObj.x > 1 || (legendObj.x === 1 && xanchor === 'left');
var isBeyondPlotAreaY = isAbovePlotArea || isBelowPlotArea;
Expand All @@ -842,9 +842,9 @@ function computeLegendDimensions(gd, groups, traces, legendObj) {
gs.w,
2 * textGap);
} else {
if (xanchor === 'right')
if(xanchor === 'right')
legendObj._maxWidth = legendObj.x * fullLayout.width;
else if (xanchor === 'left')
else if(xanchor === 'left')
legendObj._maxWidth = (1 - legendObj.x) * fullLayout.width;
else // if (xanchor === 'center')
legendObj._maxWidth = 2 * Math.min(1 - legendObj.x, legendObj.x) * fullLayout.width;
Expand Down
0