Skip to content

Commit 132c57b

Browse files
committed
Adjust dy to fix offset
1 parent 7f89c73 commit 132c57b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/plot_api/subroutines.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,12 @@ exports.drawMainTitle = function(gd) {
423423
var pushMargin = needsMarginPush(gd, title, titleHeight);
424424
if(pushMargin > 0) {
425425
applyTitleAutoMargin(gd, y, pushMargin, titleHeight);
426-
427426
// Re-position the title once we know where it needs to be
428427
titleObj.attr({
429428
x: x,
430429
y: y,
431430
'text-anchor': textAnchor,
432-
dy: dy
431+
dy: getMainTitleDyAdj(title.yanchor)
433432
}).call(svgTextUtils.positionText, x, y);
434433
}
435434
}
@@ -556,6 +555,16 @@ function getMainTitleY(fullLayout, dy) {
556555
}
557556
}
558557

558+
function getMainTitleDyAdj(yanchor) {
559+
if(yanchor === 'top') {
560+
return alignmentConstants.CAP_SHIFT + 0.3 + 'em';
561+
} else if(yanchor === 'bottom') {
562+
return '-0.3em';
563+
} else {
564+
return alignmentConstants.MID_SHIFT + 'em';
565+
}
566+
}
567+
559568
function getMainTitleTextAnchor(fullLayout) {
560569
var title = fullLayout.title;
561570

0 commit comments

Comments
 (0)