@@ -8,6 +8,7 @@ var Lib = require('../../../src/lib');
8
8
var rgb = require ( '../../../src/components/color' ) . rgb ;
9
9
10
10
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
11
+ var createShadowGraphDiv = require ( '../assets/create_shadow_graph_div' ) ;
11
12
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
12
13
var mouseEvent = require ( '../assets/mouse_event' ) ;
13
14
@@ -980,6 +981,48 @@ describe('Title automargining', function() {
980
981
expect ( gd . _fullLayout . _size . h ) . toBeCloseTo ( 243 , - 1 ) ;
981
982
} ) . then ( done , done . fail ) ;
982
983
} ) ;
984
+
985
+ it ( 'computes title automargins independently when multiple plots exist' , function ( done ) {
986
+ var gd1 = gd ;
987
+ var gd2 = createShadowGraphDiv ( ) ;
988
+
989
+ var dataLocal = [ { x : [ 1 , 2 ] , y : [ 1 , 2 ] } ] ;
990
+
991
+ var layout1 = {
992
+ margin : { t : 0 , b : 0 , l : 0 , r : 0 } ,
993
+ height : 300 ,
994
+ width : 400 ,
995
+ title : {
996
+ text : 'Large title for plot 1' ,
997
+ font : { size : 36 } ,
998
+ yref : 'paper' ,
999
+ automargin : true
1000
+ }
1001
+ } ;
1002
+
1003
+ var layout2 = {
1004
+ margin : { t : 0 , b : 0 , l : 0 , r : 0 } ,
1005
+ height : 300 ,
1006
+ width : 400 ,
1007
+ title : {
1008
+ text : 'Small' ,
1009
+ font : { size : 12 } ,
1010
+ yref : 'paper' ,
1011
+ automargin : true
1012
+ }
1013
+ } ;
1014
+
1015
+ Plotly . newPlot ( gd1 , dataLocal , layout1 )
1016
+ . then ( function ( ) { return Plotly . newPlot ( gd2 , dataLocal , layout2 ) ; } )
1017
+ . then ( function ( ) {
1018
+ // Each graph should compute its own top automargin from its own title bbox
1019
+ var t1 = gd1 . _fullLayout . _size . t ;
1020
+ var t2 = gd2 . _fullLayout . _size . t ;
1021
+
1022
+ expect ( t1 ) . toBeGreaterThan ( t2 ) ;
1023
+ } )
1024
+ . then ( done , done . fail ) ;
1025
+ } ) ;
983
1026
} ) ;
984
1027
985
1028
function expectTitle ( expTitle ) {
0 commit comments