Skip to content

Commit 737150b

Browse files
committed
Ensure width of legend is checked before adding a new width
1 parent 76df791 commit 737150b

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/components/legend/draw.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,17 +613,19 @@ function computeLegendDimensions(gd, groups, traces) {
613613

614614
maxHeight += opts.tracegroupgap;
615615
maxWidth += traceGap;
616+
maxWidth += 40;
616617

617618
var groupXOffsets = [opts._width];
618619
var rowHeights = [];
619620
var rowNum = 1;
620621
for(var i = 0, n = groupData.length; i < n; i++) {
621-
opts._width += maxWidth;
622622

623-
if(fullLayout._size.w < (borderwidth + opts._width + maxWidth)) {
623+
if(fullLayout._size.w < (borderwidth + opts._width + traceGap + maxWidth)) {
624624
groupXOffsets[groupXOffsets.length - 1] = groupXOffsets[0];
625625
opts._width = maxWidth;
626626
rowNum++;
627+
} else {
628+
opts._width += maxWidth + borderwidth;
627629
}
628630

629631
var currRowHeight = ((rowNum - 1) * maxHeight);
@@ -633,9 +635,6 @@ function computeLegendDimensions(gd, groups, traces) {
633635
currRowHeight = currRowHeight > (rowNum - 1 * maxHeight) ? (rowNum - 1) * maxHeight : y;
634636

635637
rowHeights.push(currRowHeight);
636-
637-
opts._width += maxWidth;
638-
639638
groupXOffsets.push(opts._width);
640639
}
641640

-9 Bytes
Loading
-147 Bytes
Loading

0 commit comments

Comments
 (0)