Skip to content

Commit f12c62c

Browse files
committed
drop expandHorizontalMargin logic
... which doesn't appear to do anything, and mv computeLegendDimension to separate step
1 parent 0c497bb commit f12c62c

File tree

1 file changed

+4
-33
lines changed

1 file changed

+4
-33
lines changed

src/components/legend/draw.js

+4-33
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,17 @@ module.exports = function draw(gd) {
9090
.call(style, gd)
9191
.each(function() { d3.select(this).call(setupTraceToggle, gd); });
9292

93-
Lib.syncOrAsync([Plots.previousPromises,
93+
Lib.syncOrAsync([
94+
Plots.previousPromises,
95+
function() { return computeLegendDimensions(gd, groups, traces); },
96+
function() { return expandMargin(gd); },
9497
function() {
9598
// Position and size the legend
9699
var lxMin = 0;
97100
var lxMax = fullLayout.width;
98101
var lyMin = 0;
99102
var lyMax = fullLayout.height;
100103

101-
computeLegendDimensions(gd, groups, traces);
102-
103-
if(opts._height > lyMax) {
104-
// If the legend doesn't fit in the plot area,
105-
// do not expand the vertical margins.
106-
expandHorizontalMargin(gd);
107-
} else {
108-
expandMargin(gd);
109-
}
110-
111104
// Scroll section must be executed after repositionLegend.
112105
// It requires the legend width, height, x and y to position the scrollbox
113106
// and these values are mutated in repositionLegend.
@@ -689,25 +682,3 @@ function expandMargin(gd) {
689682
t: opts._height * (FROM_TL[yanchor])
690683
});
691684
}
692-
693-
function expandHorizontalMargin(gd) {
694-
var fullLayout = gd._fullLayout;
695-
var opts = fullLayout.legend;
696-
697-
var xanchor = 'left';
698-
if(Lib.isRightAnchor(opts)) {
699-
xanchor = 'right';
700-
} else if(Lib.isCenterAnchor(opts)) {
701-
xanchor = 'center';
702-
}
703-
704-
// lastly check if the margin auto-expand has changed
705-
Plots.autoMargin(gd, 'legend', {
706-
x: opts.x,
707-
y: 0.5,
708-
l: opts._width * (FROM_TL[xanchor]),
709-
r: opts._width * (FROM_BR[xanchor]),
710-
b: 0,
711-
t: 0
712-
});
713-
}

0 commit comments

Comments
 (0)