Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,12 @@ function computeLegendDimensions(gd, groups, traces) {
});

// check if legend fits in one row
oneRowLegend = (fullLayout.width - (fullLayout.margin.r + fullLayout.margin.l)) > borderwidth + fullTracesWidth - traceGap;
oneRowLegend = (fullLayout.width - (fullLayout._size.r + fullLayout._size.l)) > borderwidth + fullTracesWidth - traceGap;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fullLayout.width - (fullLayout._size.r + fullLayout._size.l) === fullLayout._size.w

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing gets by you :) Thank you again for the quick review!

traces.each(function(d) {
var legendItem = d[0],
traceWidth = oneRowLegend ? 40 + d[0].width : maxTraceWidth;

if((borderwidth + offsetX + traceGap + traceWidth) > (fullLayout.width - (fullLayout.margin.r + fullLayout.margin.l))) {
if((borderwidth + offsetX + traceGap + traceWidth) > (fullLayout.width - (fullLayout._size.r + fullLayout._size.l))) {
offsetX = 0;
rowHeight = rowHeight + maxTraceHeight;
opts._height = opts._height + maxTraceHeight;
Expand Down
Binary file added test/image/baselines/legend_large_margin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions test/image/mocks/legend_large_margin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"data": [{
"x": [1, 2, 3, 4],
"y": ["long y label long y label long y label", "a", "b", "c"],
"name": "trace 1"
},
{
"x": [1.1, 2.1, 3.1, 4.1],
"y": ["long y label long y label long y label", "a", "b", "c"],
"name": "trace 1"
},
{
"x": [1.2, 2.2, 3.2, 4.2],
"y": ["long y label long y label long y label", "a", "b", "c"],
"name": "trace 1"
},
{
"x": [1.3, 2.3, 3.3, 4.3],
"y": ["long y label long y label long y label", "a", "b", "c"],
"name": "trace 1"
},
{
"x": [1.4, 2.4, 3.4, 4.4],
"y": ["long y label long y label long y label", "a", "b", "c"],
"name": "trace 1"
}
],
"layout": {
"width": 500,
"height": 500,
"legend": {
"orientation": "h",
"bgcolor": "#ffffff00"
},
"yaxis": {
"automargin": true
}

}
}