Skip to content

Commit ba6171b

Browse files
committed
Rotate X axis labels when they are too big
Solves https://sft.its.cern.ch/jira/browse/ROOT-8073
1 parent 546aa35 commit ba6171b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

scripts/JSRootPainter.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3648,12 +3648,21 @@
36483648
}
36493649

36503650
if ((textscale>0) && (textscale<1.)) {
3651-
labelfont.size = Math.floor(labelfont.size * textscale);
3651+
// rotate X lables if they are too big
3652+
if ((textscale < 0.7) && !vertical) {
3653+
label_g.selectAll("text").each(function() {
3654+
var txt = d3.select(this), x = txt.attr("x"), y = txt.attr("y");
3655+
3656+
txt.attr("transform", "translate(" + x+ ","+y + ") rotate(20)")
3657+
.attr("x",null).attr("y",null);
3658+
});
3659+
textscale*=2;
3660+
}
3661+
// round to upper boundary for calculated value like 4.4
3662+
labelfont.size = Math.floor(labelfont.size * textscale + 0.7);
36523663
label_g.call(labelfont.func);
36533664
}
36543665

3655-
// axis.fTitle = "M_{#mu#mu}";
3656-
36573666
if (axis.fTitle.length > 0) {
36583667
var title_g = axis_g.append("svg:g").attr("class", "axis_title"),
36593668
title_fontsize = Math.round(axis.fTitleSize * text_scaling_size),

0 commit comments

Comments
 (0)