@@ -30,7 +30,7 @@ module.exports = function draw(gd, opts) {
30
30
// Check whether this is the main legend (ie. called without any opts)
31
31
if ( ! opts ) {
32
32
opts = fullLayout . legend || { } ;
33
- opts . _main = true ;
33
+ opts . _isLegend = true ;
34
34
layer = fullLayout . _infolayer ;
35
35
} else {
36
36
layer = opts . layer ;
@@ -42,7 +42,7 @@ module.exports = function draw(gd, opts) {
42
42
if ( ! gd . _legendMouseDownTime ) gd . _legendMouseDownTime = 0 ;
43
43
44
44
var legendData ;
45
- if ( opts . _main ) {
45
+ if ( opts . _isLegend ) {
46
46
if ( ! gd . calcdata ) return ;
47
47
legendData = fullLayout . showlegend && getLegendData ( gd . calcdata , opts ) ;
48
48
} else {
@@ -52,14 +52,14 @@ module.exports = function draw(gd, opts) {
52
52
53
53
var hiddenSlices = fullLayout . hiddenlabels || [ ] ;
54
54
55
- if ( opts . _main && ( ! fullLayout . showlegend || ! legendData . length ) ) {
55
+ if ( opts . _isLegend && ( ! fullLayout . showlegend || ! legendData . length ) ) {
56
56
layer . selectAll ( '.legend' ) . remove ( ) ;
57
57
fullLayout . _topdefs . select ( '#' + clipId ) . remove ( ) ;
58
58
return Plots . autoMargin ( gd , 'legend' ) ;
59
59
}
60
60
61
61
var legend = Lib . ensureSingle ( layer , 'g' , 'legend' , function ( s ) {
62
- if ( opts . _main ) s . attr ( 'pointer-events' , 'all' ) ;
62
+ if ( opts . _isLegend ) s . attr ( 'pointer-events' , 'all' ) ;
63
63
} ) ;
64
64
65
65
var clipPath = Lib . ensureSingleById ( fullLayout . _topdefs , 'clipPath' , clipId , function ( s ) {
@@ -112,7 +112,7 @@ module.exports = function draw(gd, opts) {
112
112
} )
113
113
. each ( function ( ) { d3 . select ( this ) . call ( drawTexts , gd , opts ) ; } )
114
114
. call ( style , gd , opts )
115
- . each ( function ( ) { if ( opts . _main ) d3 . select ( this ) . call ( setupTraceToggle , gd ) ; } ) ;
115
+ . each ( function ( ) { if ( opts . _isLegend ) d3 . select ( this ) . call ( setupTraceToggle , gd ) ; } ) ;
116
116
117
117
Lib . syncOrAsync ( [
118
118
Plots . previousPromises ,
@@ -121,15 +121,15 @@ module.exports = function draw(gd, opts) {
121
121
// IF expandMargin return a Promise (which is truthy),
122
122
// we're under a doAutoMargin redraw, so we don't have to
123
123
// draw the remaining pieces below
124
- if ( opts . _main && expandMargin ( gd ) ) return ;
124
+ if ( opts . _isLegend && expandMargin ( gd ) ) return ;
125
125
126
126
var gs = fullLayout . _size ;
127
127
var bw = opts . borderwidth ;
128
128
129
129
var lx = gs . l + gs . w * opts . x - FROM_TL [ getXanchor ( opts ) ] * opts . _width ;
130
130
var ly = gs . t + gs . h * ( 1 - opts . y ) - FROM_TL [ getYanchor ( opts ) ] * opts . _effHeight ;
131
131
132
- if ( opts . _main && fullLayout . margin . autoexpand ) {
132
+ if ( opts . _isLegend && fullLayout . margin . autoexpand ) {
133
133
var lx0 = lx ;
134
134
var ly0 = ly ;
135
135
@@ -146,18 +146,18 @@ module.exports = function draw(gd, opts) {
146
146
147
147
// Set size and position of all the elements that make up a legend:
148
148
// legend, background and border, scroll box and scroll bar as well as title
149
- if ( opts . _main ) Drawing . setTranslate ( legend , lx , ly ) ;
149
+ if ( opts . _isLegend ) Drawing . setTranslate ( legend , lx , ly ) ;
150
150
151
151
// to be safe, remove previous listeners
152
152
scrollBar . on ( '.drag' , null ) ;
153
153
legend . on ( 'wheel' , null ) ;
154
154
155
- if ( ! opts . _main || opts . _height <= opts . _maxHeight || gd . _context . staticPlot ) {
155
+ if ( ! opts . _isLegend || opts . _height <= opts . _maxHeight || gd . _context . staticPlot ) {
156
156
// if scrollbar should not be shown.
157
157
var height = opts . _effHeight ;
158
158
159
- // if not the main legend , let it be its full size
160
- if ( ! opts . _main ) height = opts . _height ;
159
+ // if unified hover , let it be its full size
160
+ if ( ! opts . _isLegend ) height = opts . _height ;
161
161
162
162
bg . attr ( {
163
163
width : opts . _width - bw ,
@@ -386,7 +386,7 @@ function drawTexts(g, gd, opts) {
386
386
var trace = legendItem . trace ;
387
387
var isPieLike = Registry . traceIs ( trace , 'pie-like' ) ;
388
388
var traceIndex = trace . index ;
389
- var isEditable = opts . _main && gd . _context . edits . legendText && ! isPieLike ;
389
+ var isEditable = opts . _isLegend && gd . _context . edits . legendText && ! isPieLike ;
390
390
var maxNameLength = opts . _maxNameLength ;
391
391
392
392
var name ;
@@ -491,15 +491,15 @@ function setupTraceToggle(g, gd) {
491
491
}
492
492
493
493
function textLayout ( s , g , gd , opts ) {
494
- if ( ! opts . _main ) s . attr ( 'data-notex' , true ) ; // do not process MathJax if not main
494
+ if ( ! opts . _isLegend ) s . attr ( 'data-notex' , true ) ; // do not process MathJax for unified hover
495
495
svgTextUtils . convertToTspans ( s , gd , function ( ) {
496
496
computeTextDimensions ( g , gd , opts ) ;
497
497
} ) ;
498
498
}
499
499
500
500
function computeTextDimensions ( g , gd , opts ) {
501
501
var legendItem = g . data ( ) [ 0 ] [ 0 ] ;
502
- if ( opts . _main && legendItem && ! legendItem . trace . showlegend ) {
502
+ if ( opts . _isLegend && legendItem && ! legendItem . trace . showlegend ) {
503
503
g . remove ( ) ;
504
504
return ;
505
505
}
0 commit comments