@@ -90,24 +90,17 @@ module.exports = function draw(gd) {
90
90
. call ( style , gd )
91
91
. each ( function ( ) { d3 . select ( this ) . call ( setupTraceToggle , gd ) ; } ) ;
92
92
93
- Lib . syncOrAsync ( [ Plots . previousPromises ,
93
+ Lib . syncOrAsync ( [
94
+ Plots . previousPromises ,
95
+ function ( ) { return computeLegendDimensions ( gd , groups , traces ) ; } ,
96
+ function ( ) { return expandMargin ( gd ) ; } ,
94
97
function ( ) {
95
98
// Position and size the legend
96
99
var lxMin = 0 ;
97
100
var lxMax = fullLayout . width ;
98
101
var lyMin = 0 ;
99
102
var lyMax = fullLayout . height ;
100
103
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
-
111
104
// Scroll section must be executed after repositionLegend.
112
105
// It requires the legend width, height, x and y to position the scrollbox
113
106
// and these values are mutated in repositionLegend.
@@ -689,25 +682,3 @@ function expandMargin(gd) {
689
682
t : opts . _height * ( FROM_TL [ yanchor ] )
690
683
} ) ;
691
684
}
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