Skip to content

Commit 5d04122

Browse files
committed
Fix conditional logic in legend height calculation
1 parent 8b24220 commit 5d04122

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/components/legend/attributes.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ module.exports = {
4141
'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 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',
46-
'is the plot height.'
44+
'The reference height is the full layout height with the following exceptions: legends to the side of the plot',
45+
'or vertically oriented legends with a `yref` of `"paper". In this case, the reference height is the plot height.'
4746
].join(' ')
4847
},
4948
borderwidth: {

src/components/legend/draw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ function computeLegendDimensions(gd, groups, traces, legendObj) {
771771

772772
const { orientation, yref } = legendObj;
773773
let { maxheight } = legendObj;
774-
const useFullLayoutHeight = (isBelowPlotArea || isAbovePlotArea) && !(orientation === "v" && yref === "paper")
774+
const useFullLayoutHeight = isBelowPlotArea || isAbovePlotArea || !(orientation === "v" && yref === "paper")
775775
// Set default maxheight here since it depends on values passed in by user
776776
maxheight ||= useFullLayoutHeight ? 0.5 : 1;
777777
const heightToBeScaled = useFullLayoutHeight ? fullLayout.height : gs.h;

test/plot-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3451,7 +3451,7 @@
34513451
"valType": "number"
34523452
},
34533453
"maxheight": {
3454-
"description": "Sets the max height (in px) of the legend, or max height ratio (reference height * ratio) if less than one. Default value is: 0.5 for horizontal legends; 1 for vertical legends. The minimum allowed height is 30px. For a ratio of 0.5, the legend will take up to 50% of the reference height before displaying a scrollbar. The reference height is the full layout height with the following exception: vertically oriented legends with a `yref` of `\"paper\"`, unless the legend is located above/below the plot. In this case, the reference height is the plot height.",
3454+
"description": "Sets the max height (in px) of the legend, or max height ratio (reference height * ratio) if less than or equal to 1. Default value is: 0.5 for horizontal legends; 1 for vertical legends. The minimum allowed height is 30px. For a ratio of 0.5, the legend will take up to 50% of the reference height before displaying a scrollbar. 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.",
34553455
"editType": "legend",
34563456
"min": 0,
34573457
"valType": "number"

0 commit comments

Comments
 (0)