@@ -1331,6 +1331,50 @@ describe('A bar plot', function() {
1331
1331
. catch ( failTest )
1332
1332
. then ( done ) ;
1333
1333
} ) ;
1334
+
1335
+ it ( 'should update axis range according to visible edits' , function ( done ) {
1336
+ var schema = Plotly . PlotSchema . get ( ) ;
1337
+ expect ( schema . traces . bar . attributes . visible . editType )
1338
+ . toBe ( 'plot' , 'visible editType' ) ;
1339
+
1340
+ function _assert ( msg , xrng , yrng , calls ) {
1341
+ var fullLayout = gd . _fullLayout ;
1342
+ expect ( fullLayout . xaxis . range ) . toBeCloseToArray ( xrng , 2 , msg + ' xrng' ) ;
1343
+ expect ( fullLayout . yaxis . range ) . toBeCloseToArray ( yrng , 2 , msg + ' yrng' ) ;
1344
+
1345
+ var setPositions = gd . _fullData [ 0 ] . _module . setPositions ;
1346
+ expect ( setPositions ) . toHaveBeenCalledTimes ( calls ) ;
1347
+ setPositions . calls . reset ( ) ;
1348
+ }
1349
+
1350
+ Plotly . plot ( gd , [
1351
+ { type : 'bar' , x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 1 ] } ,
1352
+ { type : 'bar' , x : [ 1 , 2 , 3 ] , y : [ - 1 , - 2 , - 1 ] }
1353
+ ] )
1354
+ . then ( function ( ) {
1355
+ spyOn ( gd . _fullData [ 0 ] . _module , 'setPositions' ) . and . callThrough ( ) ;
1356
+
1357
+ _assert ( 'base' , [ 0.5 , 3.5 ] , [ - 2.222 , 2.222 ] , 0 ) ;
1358
+ return Plotly . restyle ( gd , 'visible' , false , [ 1 ] ) ;
1359
+ } )
1360
+ . then ( function ( ) {
1361
+ _assert ( 'visible [true,false]' , [ 0.5 , 3.5 ] , [ 0 , 2.105 ] , 1 ) ;
1362
+ return Plotly . restyle ( gd , 'visible' , false , [ 0 ] ) ;
1363
+ } )
1364
+ . then ( function ( ) {
1365
+ _assert ( 'both invisible' , [ 0.5 , 3.5 ] , [ 0 , 2.105 ] , 0 ) ;
1366
+ return Plotly . restyle ( gd , 'visible' , true , [ 1 ] ) ;
1367
+ } )
1368
+ . then ( function ( ) {
1369
+ _assert ( 'visible [false,true]' , [ 0.5 , 3.5 ] , [ - 2.105 , 0 ] , 1 ) ;
1370
+ return Plotly . restyle ( gd , 'visible' , true ) ;
1371
+ } )
1372
+ . then ( function ( ) {
1373
+ _assert ( 'back to both visible' , [ 0.5 , 3.5 ] , [ - 2.222 , 2.222 ] , 1 ) ;
1374
+ } )
1375
+ . catch ( failTest )
1376
+ . then ( done ) ;
1377
+ } ) ;
1334
1378
} ) ;
1335
1379
1336
1380
describe ( 'bar hover' , function ( ) {
0 commit comments