Skip to content

Commit 3523406

Browse files
committed
Only reposition title if necessary
1 parent d70fb46 commit 3523406

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/plot_api/subroutines.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,18 @@ exports.drawMainTitle = function(gd) {
411411
propContainer: fullLayout,
412412
propName: 'title.text',
413413
placeholder: fullLayout._dfltTitle.plot,
414+
attributes: ({
415+
x: x,
416+
y: y,
417+
'text-anchor': textAnchor,
418+
dy: dy
419+
})
414420
});
415421

416-
var titleObj = d3.selectAll('.gtitle');
422+
417423

418424
if(title.text && title.automargin) {
425+
var titleObj = d3.selectAll('.gtitle');
419426
var titleHeight = Drawing.bBox(titleObj.node()).height;
420427
var pushMargin = needsMarginPush(gd, title, titleHeight);
421428
if(pushMargin > 0) {
@@ -424,16 +431,18 @@ exports.drawMainTitle = function(gd) {
424431
dy = getMainTitleDy(fullLayout);
425432
y = getMainTitleY(fullLayout, dy);
426433
applyTitleAutoMargin(gd, y, pushMargin, titleHeight);
434+
435+
// Position the title once we know where it needs to be
436+
titleObj.attr({
437+
x: x,
438+
y: y,
439+
'text-anchor': textAnchor,
440+
dy: dy
441+
}).call(svgTextUtils.positionText, x, y);
427442
}
428443
}
429444

430-
// Position the title once we know where it needs to be
431-
titleObj.attr({
432-
x: x,
433-
y: y,
434-
'text-anchor': textAnchor,
435-
dy: dy
436-
}).call(svgTextUtils.positionText, x, y);
445+
437446
};
438447

439448

0 commit comments

Comments
 (0)