Skip to content

Commit bc80967

Browse files
committed
Add test for title automargins in multiple plots
1 parent 0b1d6c9 commit bc80967

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/jasmine/tests/titles_test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var Lib = require('../../../src/lib');
88
var rgb = require('../../../src/components/color').rgb;
99

1010
var createGraphDiv = require('../assets/create_graph_div');
11+
var createShadowGraphDiv = require('../assets/create_shadow_graph_div');
1112
var destroyGraphDiv = require('../assets/destroy_graph_div');
1213
var mouseEvent = require('../assets/mouse_event');
1314

@@ -980,6 +981,48 @@ describe('Title automargining', function() {
980981
expect(gd._fullLayout._size.h).toBeCloseTo(243, -1);
981982
}).then(done, done.fail);
982983
});
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+
});
9831026
});
9841027

9851028
function expectTitle(expTitle) {

0 commit comments

Comments
 (0)