@@ -123,6 +123,31 @@ describe('legend defaults', function() {
123
123
expect ( layoutOut . legend . traceorder ) . toEqual ( 'reversed' ) ;
124
124
} ) ;
125
125
126
+ it ( 'should default traceorder to reversed for stack bar charts | multi-legend case' , function ( ) {
127
+ fullData = allShown ( [
128
+ { type : 'scatter' } ,
129
+ { legend : 'legend2' , type : 'bar' , visible : 'legendonly' } ,
130
+ { legend : 'legend2' , type : 'bar' , visible : 'legendonly' } ,
131
+ { legend : 'legend2' , type : 'scatter' } ,
132
+ { legend : 'legend3' , type : 'scatter' }
133
+ ] ) ;
134
+
135
+ layoutOut . legend2 = { } ;
136
+ layoutOut . legend3 = { } ;
137
+
138
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
139
+ expect ( layoutOut . legend . traceorder ) . toEqual ( 'normal' ) ;
140
+ expect ( layoutOut . legend2 . traceorder ) . toEqual ( 'normal' ) ;
141
+ expect ( layoutOut . legend3 . traceorder ) . toEqual ( 'normal' ) ;
142
+
143
+ layoutOut . barmode = 'stack' ;
144
+
145
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
146
+ expect ( layoutOut . legend . traceorder ) . toEqual ( 'normal' ) ;
147
+ expect ( layoutOut . legend2 . traceorder ) . toEqual ( 'reversed' ) ;
148
+ expect ( layoutOut . legend3 . traceorder ) . toEqual ( 'normal' ) ;
149
+ } ) ;
150
+
126
151
it ( 'should default traceorder to reversed for filled tonext scatter charts' , function ( ) {
127
152
fullData = allShown ( [
128
153
{ type : 'scatter' } ,
@@ -148,6 +173,30 @@ describe('legend defaults', function() {
148
173
expect ( layoutOut . legend . traceorder ) . toEqual ( 'grouped+reversed' ) ;
149
174
} ) ;
150
175
176
+ it ( 'should default traceorder to grouped when a group is present | multi-legend case' , function ( ) {
177
+ fullData = allShown ( [
178
+ { type : 'scatter' } ,
179
+ { legend : 'legend2' , type : 'scatter' , legendgroup : 'group' } ,
180
+ { legend : 'legend2' , type : 'scatter' } ,
181
+ { legend : 'legend3' , type : 'scatter' }
182
+ ] ) ;
183
+
184
+ layoutOut . legend2 = { } ;
185
+ layoutOut . legend3 = { } ;
186
+
187
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
188
+ expect ( layoutOut . legend . traceorder ) . toEqual ( 'normal' ) ;
189
+ expect ( layoutOut . legend2 . traceorder ) . toEqual ( 'grouped' ) ;
190
+ expect ( layoutOut . legend3 . traceorder ) . toEqual ( 'normal' ) ;
191
+
192
+ fullData [ 1 ] . fill = 'tonextx' ;
193
+
194
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
195
+ expect ( layoutOut . legend . traceorder ) . toEqual ( 'normal' ) ;
196
+ expect ( layoutOut . legend2 . traceorder ) . toEqual ( 'reversed+grouped' ) ;
197
+ expect ( layoutOut . legend3 . traceorder ) . toEqual ( 'normal' ) ;
198
+ } ) ;
199
+
151
200
it ( 'does not consider invisible traces for traceorder default' , function ( ) {
152
201
fullData = allShown ( [
153
202
{ type : 'bar' , visible : false } ,
@@ -169,6 +218,38 @@ describe('legend defaults', function() {
169
218
expect ( layoutOut . legend . traceorder ) . toEqual ( 'normal' ) ;
170
219
} ) ;
171
220
221
+ it ( 'does not consider invisible traces for traceorder default | multi-legend case' , function ( ) {
222
+ fullData = allShown ( [
223
+ { type : 'scatter' } ,
224
+ { legend : 'legend2' , type : 'bar' , visible : false } ,
225
+ { legend : 'legend2' , type : 'bar' , visible : false } ,
226
+ { legend : 'legend2' , type : 'scatter' } ,
227
+ { legend : 'legend3' , type : 'scatter' } ,
228
+ ] ) ;
229
+
230
+ layoutOut . legend2 = { } ;
231
+ layoutOut . legend3 = { } ;
232
+
233
+ layoutOut . barmode = 'stack' ;
234
+
235
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
236
+ expect ( layoutOut . legend . traceorder ) . toEqual ( 'normal' ) ;
237
+ expect ( layoutOut . legend2 . traceorder ) . toEqual ( 'normal' ) ;
238
+ expect ( layoutOut . legend3 . traceorder ) . toEqual ( 'normal' ) ;
239
+
240
+ fullData = allShown ( [
241
+ { type : 'scatter' } ,
242
+ { legend : 'legend2' , type : 'scatter' , legendgroup : 'group' , visible : false } ,
243
+ { legend : 'legend2' , type : 'scatter' } ,
244
+ { legend : 'legend3' , type : 'scatter' }
245
+ ] ) ;
246
+
247
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
248
+ expect ( layoutOut . legend . traceorder ) . toEqual ( 'normal' ) ;
249
+ expect ( layoutOut . legend2 . traceorder ) . toEqual ( 'normal' ) ;
250
+ expect ( layoutOut . legend3 . traceorder ) . toEqual ( 'normal' ) ;
251
+ } ) ;
252
+
172
253
it ( 'should default orientation to vertical' , function ( ) {
173
254
supplyLayoutDefaults ( layoutIn , layoutOut , [ ] ) ;
174
255
expect ( layoutOut . legend . orientation ) . toEqual ( 'v' ) ;
0 commit comments