Skip to content

Commit 049b181

Browse files
committed
Fix - limit maximal font size for TLegend
It is still good idea to scale down font size if text too long
1 parent 319cafb commit 049b181

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/JSRootPainter.hist.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,12 +1929,15 @@
19291929
padding_x = Math.round(0.03*w/ncols),
19301930
padding_y = Math.round(0.03*h),
19311931
step_y = (h - 2*padding_y)/nrows,
1932+
font_size = 0.9*step_y,
1933+
max_font_size = 0, // not limited in the beggining
19321934
ph = this.pad_height(),
19331935
fsize, any_opt = false, i = -1;
19341936

1935-
if (legend.fTextSize && (ph*legend.fTextSize > 2) && (ph*legend.fTextSize < step_y)) fsize = Math.round(ph*legend.fTextSize);
1937+
if (legend.fTextSize && (ph*legend.fTextSize > 2) && (ph*legend.fTextSize < font_size))
1938+
font_size = max_font_size = Math.round(ph*legend.fTextSize);
19361939

1937-
this.StartTextDrawing(legend.fTextFont, 0.9*step_y);
1940+
this.StartTextDrawing(legend.fTextFont, font_size, this.draw_g, max_font_size);
19381941

19391942
for (var ii = 0; ii < nlines; ++ii) {
19401943
var leg = legend.fPrimitives.arr[ii];
@@ -2016,11 +2019,11 @@
20162019
else if (!any_opt) pos_x = x0 + padding_x;
20172020

20182021
if (leg.fLabel)
2019-
this.DrawText({ align: "start", x: pos_x, y: pos_y, width: x0+column_width-pos_x-padding_x, height: step_y, text: leg.fLabel, color: tcolor, font_size: fsize });
2022+
this.DrawText({ align: "start", x: pos_x, y: pos_y, width: x0+column_width-pos_x-padding_x, height: step_y, text: leg.fLabel, color: tcolor });
20202023
}
20212024

20222025
// rescale after all entries are shown
2023-
this.FinishTextDrawing(null, this.FinishPave);
2026+
this.FinishTextDrawing(this.draw_g, this.FinishPave);
20242027
}
20252028

20262029
TPavePainter.prototype.FillContextMenu = function(menu) {

0 commit comments

Comments
 (0)