@@ -1782,7 +1782,7 @@ describe('legend interaction', function() {
1782
1782
} ) ;
1783
1783
} ) ;
1784
1784
1785
- describe ( 'traces in different legends' , function ( ) {
1785
+ describe ( 'for regular traces in different legends' , function ( ) {
1786
1786
beforeEach ( function ( done ) {
1787
1787
Plotly . newPlot ( gd , [
1788
1788
{ x : [ 1 , 2 ] , y : [ 0 , 1 ] , visible : false } ,
@@ -2337,6 +2337,78 @@ describe('legend interaction', function() {
2337
2337
. then ( done , done . fail ) ;
2338
2338
} , 2 * jasmine . DEFAULT_TIMEOUT_INTERVAL ) ;
2339
2339
} ) ;
2340
+
2341
+ describe ( 'should honor *itemclick* and *itemdoubleclick* settings | case of pie in multiple legends' , function ( ) {
2342
+ var _assert ;
2343
+
2344
+ function run ( ) {
2345
+ return Promise . resolve ( )
2346
+ . then ( click ( 0 , 1 ) ) . then ( _assert ( [ 'legendonly' , true , true , true , true , true ] ) )
2347
+ . then ( click ( 0 , 1 ) ) . then ( _assert ( [ true , true , true , true , true , true ] ) )
2348
+ . then ( click ( 0 , 2 ) ) . then ( _assert ( [ true , 'legendonly' , 'legendonly' , true , true , true ] ) )
2349
+ . then ( click ( 0 , 2 ) ) . then ( _assert ( [ true , true , true , true , true , true ] ) )
2350
+ . then ( function ( ) {
2351
+ return Plotly . relayout ( gd , {
2352
+ 'legend.itemclick' : false ,
2353
+ 'legend.itemdoubleclick' : false
2354
+ } ) ;
2355
+ } )
2356
+ . then ( delay ( 100 ) )
2357
+ . then ( click ( 0 , 1 ) ) . then ( _assert ( [ true , true , true , true , true , true ] ) )
2358
+ . then ( click ( 0 , 2 ) ) . then ( _assert ( [ true , true , true , true , true , true ] ) )
2359
+ . then ( function ( ) {
2360
+ return Plotly . relayout ( gd , {
2361
+ 'legend.itemclick' : 'toggleothers' ,
2362
+ 'legend.itemdoubleclick' : 'toggle'
2363
+ } ) ;
2364
+ } )
2365
+ . then ( delay ( 100 ) )
2366
+ . then ( click ( 0 , 1 ) ) . then ( _assert ( [ true , 'legendonly' , 'legendonly' , true , true , true ] ) )
2367
+ . then ( click ( 0 , 1 ) ) . then ( _assert ( [ true , true , true , true , true , true ] ) )
2368
+ . then ( click ( 0 , 2 ) ) . then ( _assert ( [ 'legendonly' , true , true , true , true , true ] ) )
2369
+ . then ( click ( 0 , 2 ) ) . then ( _assert ( [ true , true , true , true , true , true ] ) ) ;
2370
+ }
2371
+
2372
+ _assert = function ( _exp ) {
2373
+ return function ( ) {
2374
+ var exp = [ ] ;
2375
+ if ( _exp [ 0 ] === 'legendonly' ) exp . push ( 'F' ) ;
2376
+ if ( _exp [ 1 ] === 'legendonly' ) exp . push ( 'E' ) ;
2377
+ if ( _exp [ 2 ] === 'legendonly' ) exp . push ( 'D' ) ;
2378
+ if ( _exp [ 3 ] === 'legendonly' ) exp . push ( 'C' ) ;
2379
+ if ( _exp [ 4 ] === 'legendonly' ) exp . push ( 'B' ) ;
2380
+ if ( _exp [ 5 ] === 'legendonly' ) exp . push ( 'A' ) ;
2381
+ expect ( gd . _fullLayout . hiddenlabels || [ ] ) . toEqual ( exp ) ;
2382
+ } ;
2383
+ } ;
2384
+
2385
+ it ( '- pie case | multiple legends' , function ( done ) {
2386
+ Plotly . newPlot ( gd , [ {
2387
+ legend : 'legend2' ,
2388
+ type : 'pie' ,
2389
+ labels : [ 'A' , 'B' , 'C' ] ,
2390
+ values : [ 1 , 2 , 3 ] ,
2391
+ domain : {
2392
+ y : [ 0 , 0.45 ]
2393
+ }
2394
+ } , {
2395
+ type : 'pie' ,
2396
+ labels : [ 'D' , 'E' , 'F' ] ,
2397
+ values : [ 1 , 2 , 3 ] ,
2398
+ domain : {
2399
+ y : [ 0.55 , 1 ]
2400
+ }
2401
+ } ] , {
2402
+ legend2 : {
2403
+ y : 0.35
2404
+ } ,
2405
+ width : 500 ,
2406
+ height : 500
2407
+ } )
2408
+ . then ( run )
2409
+ . then ( done , done . fail ) ;
2410
+ } , 2 * jasmine . DEFAULT_TIMEOUT_INTERVAL ) ;
2411
+ } ) ;
2340
2412
} ) ;
2341
2413
} ) ;
2342
2414
0 commit comments