@@ -1423,6 +1423,37 @@ describe('bar visibility toggling:', function() {
14231423 . catch ( failTest )
14241424 . then ( done ) ;
14251425 } ) ;
1426+
1427+ it ( 'gets the right legend traceorder if all bars are visible: false' , function ( done ) {
1428+ function _assert ( traceorder , yRange , legendCount ) {
1429+ expect ( gd . _fullLayout . legend . traceorder ) . toBe ( traceorder ) ;
1430+ expect ( gd . _fullLayout . yaxis . range ) . toBeCloseToArray ( yRange , 2 ) ;
1431+ expect ( d3 . select ( gd ) . selectAll ( '.legend .traces' ) . size ( ) ) . toBe ( legendCount ) ;
1432+ }
1433+ Plotly . newPlot ( gd , [
1434+ { type : 'bar' , y : [ 1 , 2 , 3 ] } ,
1435+ { type : 'bar' , y : [ 3 , 2 , 1 ] } ,
1436+ { y : [ 2 , 3 , 2 ] } ,
1437+ { y : [ 3 , 2 , 3 ] }
1438+ ] , {
1439+ barmode : 'stack' , width : 400 , height : 400
1440+ } )
1441+ . then ( function ( ) {
1442+ _assert ( 'reversed' , [ 0 , 4.211 ] , 4 ) ;
1443+
1444+ return Plotly . restyle ( gd , { visible : false } , [ 0 , 1 ] ) ;
1445+ } )
1446+ . then ( function ( ) {
1447+ _assert ( 'normal' , [ 1.922 , 3.077 ] , 2 ) ;
1448+
1449+ return Plotly . restyle ( gd , { visible : 'legendonly' } , [ 0 , 1 ] ) ;
1450+ } )
1451+ . then ( function ( ) {
1452+ _assert ( 'reversed' , [ 1.922 , 3.077 ] , 4 ) ;
1453+ } )
1454+ . catch ( failTest )
1455+ . then ( done ) ;
1456+ } ) ;
14261457} ) ;
14271458
14281459describe ( 'bar hover' , function ( ) {
0 commit comments