@@ -3383,6 +3383,86 @@ describe('Test axes', function() {
3383
3383
. catch ( failTest )
3384
3384
. then ( done ) ;
3385
3385
} ) ;
3386
+
3387
+ it ( 'should not lead to negative plot area heights' , function ( done ) {
3388
+ function _assert ( msg , exp ) {
3389
+ var gs = gd . _fullLayout . _size ;
3390
+ expect ( gs . h ) . toBeGreaterThan ( 0 , msg + '- positive height' ) ;
3391
+ expect ( gs . b ) . toBeGreaterThan ( exp . bottomLowerBound , msg + ' - margin bottom' ) ;
3392
+ expect ( gs . b + gs . h + gs . t ) . toBeWithin ( exp . totalHeight , 1.5 , msg + ' - total height' ) ;
3393
+ }
3394
+
3395
+ Plotly . plot ( gd , [ {
3396
+ x : [ 'loooooong label 1' , 'loooooong label 2' ] ,
3397
+ y : [ 1 , 2 ]
3398
+ } ] , {
3399
+ xaxis : { automargin : true , tickangle : 90 } ,
3400
+ width : 500 ,
3401
+ height : 500
3402
+ } )
3403
+ . then ( function ( ) {
3404
+ _assert ( 'base' , {
3405
+ bottomLowerBound : 80 ,
3406
+ totalHeight : 500
3407
+ } ) ;
3408
+ } )
3409
+ . then ( function ( ) { return Plotly . relayout ( gd , 'height' , 100 ) ; } )
3410
+ . then ( function ( ) {
3411
+ _assert ( 'after relayout to *small* height' , {
3412
+ bottomLowerBound : 30 ,
3413
+ totalHeight : 100
3414
+ } ) ;
3415
+ } )
3416
+ . then ( function ( ) { return Plotly . relayout ( gd , 'height' , 800 ) ; } )
3417
+ . then ( function ( ) {
3418
+ _assert ( 'after relayout to *big* height' , {
3419
+ bottomLowerBound : 80 ,
3420
+ totalHeight : 800
3421
+ } ) ;
3422
+ } )
3423
+ . catch ( failTest )
3424
+ . then ( done ) ;
3425
+ } ) ;
3426
+
3427
+ it ( 'should not lead to negative plot area widths' , function ( done ) {
3428
+ function _assert ( msg , exp ) {
3429
+ var gs = gd . _fullLayout . _size ;
3430
+ expect ( gs . w ) . toBeGreaterThan ( 0 , msg + '- positive width' ) ;
3431
+ expect ( gs . l ) . toBeGreaterThan ( exp . leftLowerBound , msg + ' - margin left' ) ;
3432
+ expect ( gs . l + gs . w + gs . r ) . toBeWithin ( exp . totalWidth , 1.5 , msg + ' - total width' ) ;
3433
+ }
3434
+
3435
+ Plotly . plot ( gd , [ {
3436
+ y : [ 'loooooong label 1' , 'loooooong label 2' ] ,
3437
+ x : [ 1 , 2 ]
3438
+ } ] , {
3439
+ yaxis : { automargin : true } ,
3440
+ width : 500 ,
3441
+ height : 500
3442
+ } )
3443
+ . then ( function ( ) {
3444
+ _assert ( 'base' , {
3445
+ leftLowerBound : 80 ,
3446
+ totalWidth : 500
3447
+ } ) ;
3448
+ } )
3449
+ . then ( function ( ) { return Plotly . relayout ( gd , 'width' , 100 ) ; } )
3450
+ . then ( function ( ) {
3451
+ _assert ( 'after relayout to *small* width' , {
3452
+ leftLowerBound : 30 ,
3453
+ totalWidth : 100
3454
+ } ) ;
3455
+ } )
3456
+ . then ( function ( ) { return Plotly . relayout ( gd , 'width' , 1000 ) ; } )
3457
+ . then ( function ( ) {
3458
+ _assert ( 'after relayout to *big* width' , {
3459
+ leftLowerBound : 80 ,
3460
+ totalWidth : 1000
3461
+ } ) ;
3462
+ } )
3463
+ . catch ( failTest )
3464
+ . then ( done ) ;
3465
+ } ) ;
3386
3466
} ) ;
3387
3467
3388
3468
describe ( 'zeroline visibility logic' , function ( ) {
0 commit comments