Skip to content

Commit ade0021

Browse files
committed
Update maxheight calculation logic
1 parent 7a0fa22 commit ade0021

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/components/legend/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function groupDefaults(legendId, layoutIn, layoutOut, fullData) {
188188

189189
coerce('xanchor', defaultXAnchor);
190190
coerce('yanchor', defaultYAnchor);
191-
coerce('maxheight', isHorizontal ? 0.5 : 1);
191+
coerce('maxheight');
192192
coerce('valign');
193193
Lib.noneOrAll(containerIn, containerOut, ['x', 'y']);
194194

src/components/legend/draw.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,12 @@ function computeLegendDimensions(gd, groups, traces, legendObj) {
769769
var traceGroupGap = legendObj.tracegroupgap;
770770
var legendGroupWidths = {};
771771

772-
var { maxheight, orientation, yref } = legendObj;
773-
var heightToBeScaled = orientation === "v" && yref === "paper" ? gs.h : fullLayout.height;
772+
const { orientation, yref } = legendObj;
773+
let { maxheight } = legendObj;
774+
const useFullLayoutHeight = isBelowPlotArea || isAbovePlotArea && !(orientation === "v" && yref === "paper")
775+
// Set default maxheight here since it depends on values passed in by user
776+
maxheight ||= useFullLayoutHeight ? 0.5 : 1;
777+
const heightToBeScaled = useFullLayoutHeight ? fullLayout.height : gs.h;
774778
legendObj._maxHeight = Math.max(maxheight > 1 ? maxheight : maxheight * heightToBeScaled, 30);
775779

776780
var toggleRectWidth = 0;

0 commit comments

Comments
 (0)