Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 540e335

Browse files
Merge pull request #7483 from plotly/cam/7473/update-legend-maxheight-logic
fix: Update legend maxheight calculation logic
2 parents bddbb14 + 82499ad commit 540e335

File tree

6 files changed

+365
-9
lines changed

6 files changed

+365
-9
lines changed

‎src/components/legend/attributes.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ module.exports = {
3838
min: 0,
3939
editType: 'legend',
4040
description: [
41-
'Sets the max height (in px) of the legend, or max height ratio (reference height * ratio) if less than one.',
41+
'Sets the max height (in px) of the legend, or max height ratio (reference height * ratio) if less than or equal to 1.',
4242
'Default value is: 0.5 for horizontal legends; 1 for vertical legends. The minimum allowed height is 30px.',
4343
'For a ratio of 0.5, the legend will take up to 50% of the reference height before displaying a scrollbar.',
44-
'The reference height is the full layout height except for vertically oriented legends with',
45-
'a `yref` of `"paper"`, where the reference height is the plot height.'
44+
'The reference height is the full layout height with the following exception: vertically oriented legends with',
45+
'a `yref` of `"paper", located to the side of the plot. In this case, the reference height is the plot height.'
4646
].join(' ')
4747
},
4848
borderwidth: {
@@ -243,7 +243,7 @@ module.exports = {
243243
values: ['auto', 'top', 'middle', 'bottom'],
244244
editType: 'legend',
245245
description: [
246-
'Sets the legend\'s vertical position anchor',
246+
'Sets the legend\'s vertical position anchor.',
247247
'This anchor binds the `y` position to the *top*, *middle*',
248248
'or *bottom* of the legend.',
249249
'Value *auto* anchors legends at their bottom for `y` values less than or equal to 1/3,',

‎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;
40.6 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /