Skip to content

Commit 18b2400

Browse files
committed
Adjust title position for vertical axis with fTitleOffset==0
1 parent 1ca7ec3 commit 18b2400

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Changes in 5.2.1
44
1. Fix - correctly handle new TF1 parameter coding convention (#132)
55
2. Fix - Check if pad name can be used as element id (#133)
6+
3. Fix - adjust title position for vertical axis with fTitleOffset==0
67

78

89
## Changes in 5.2.0

scripts/JSRootPainter.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6111,12 +6111,19 @@
61116111
axis.fTitle, title_color, 1, title_g);
61126112
}
61136113

6114-
this.FinishTextDrawing(title_g);
6115-
6116-
title_g.attr('transform', 'translate(' + shift_x + ',' + shift_y + ')')
6117-
.property('shift_x',shift_x)
6118-
.property('shift_y',shift_y);
6119-
6114+
var axis_rect = null;
6115+
if (vertical && (axis.fTitleOffset == 0) && ('getBoundingClientRect' in axis_g.node()))
6116+
axis_rect = axis_g.node().getBoundingClientRect();
6117+
this.FinishTextDrawing(title_g, function() {
6118+
if (axis_rect) {
6119+
var title_rect = title_g.node().getBoundingClientRect();
6120+
shift_x = (side>0) ? Math.round(axis_rect.left - title_rect.right - title_fontsize*0.3) :
6121+
Math.round(axis_rect.right - title_rect.left + title_fontsize*0.3);
6122+
}
6123+
title_g.attr('transform', 'translate(' + shift_x + ',' + shift_y + ')')
6124+
.property('shift_x', shift_x)
6125+
.property('shift_y', shift_y);
6126+
});
61206127
this.AddTitleDrag(title_g, vertical, title_offest_k, reverse, vertical ? h : w);
61216128
}
61226129

0 commit comments

Comments
 (0)