Skip to content

Commit 1de2704

Browse files
committed
do not wrap legend items if already at the first column
1 parent aef563b commit 1de2704

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/components/legend/draw.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,19 +700,28 @@ function computeLegendDimensions(gd, groups, traces, legendObj) {
700700
var maxWidthInGroup = 0;
701701
var offsetY = 0;
702702
d3.select(this).selectAll('g.traces').each(function(d) {
703+
var w = d[0].width;
703704
var h = d[0].height;
705+
704706
Drawing.setTranslate(this,
705707
titleSize[0],
706708
titleSize[1] + bw + itemGap + h / 2 + offsetY
707709
);
708710
offsetY += h;
709-
maxWidthInGroup = Math.max(maxWidthInGroup, textGap + d[0].width);
711+
maxWidthInGroup = Math.max(maxWidthInGroup, textGap + w);
710712
});
711713
maxGroupHeightInRow = Math.max(maxGroupHeightInRow, offsetY);
712714

713715
var next = maxWidthInGroup + itemGap;
714716

715-
if((next + bw + groupOffsetX) > legendObj._maxWidth) {
717+
// horizontal_wrapping
718+
if(
719+
// not on the first column already
720+
groupOffsetX > 0 &&
721+
722+
// goes beyound limit
723+
next + bw + groupOffsetX > legendObj._maxWidth
724+
) {
716725
maxRowWidth = Math.max(maxRowWidth, groupOffsetX);
717726
groupOffsetX = 0;
718727
groupOffsetY += maxGroupHeightInRow + traceGroupGap;

0 commit comments

Comments
 (0)