Skip to content

Commit 9c8272f

Browse files
committed
Fix - extra row for legend header
If header entry present in the legend always use extra line for it
1 parent b85084f commit 9c8272f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

modules/hist/TPavePainter.mjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ class TPavePainter extends ObjectPainter {
773773
nlines = legend.fPrimitives.arr.length,
774774
ncols = Math.max(1, legend.fNColumns);
775775
let nrows = Math.round(nlines / ncols),
776-
any_text = false,
776+
any_text = false, has_header = false,
777777
custom_textg = false; // each text entry has own attributes
778778

779779
if (nrows * ncols < nlines)
@@ -783,6 +783,8 @@ class TPavePainter extends ObjectPainter {
783783

784784
for (let ii = 0; ii < nlines; ++ii) {
785785
const entry = legend.fPrimitives.arr[ii];
786+
if ((ii === 0) && (entry.fOption === 'h'))
787+
has_header = true;
786788
if (isEmpty(entry)) {
787789
if (ncols === 1)
788790
nrows--;
@@ -794,6 +796,9 @@ class TPavePainter extends ObjectPainter {
794796
}
795797
}
796798

799+
if (has_header && (ncols > 1) && ((nrows - 1) * ncols < nlines - 1))
800+
nrows++;
801+
797802
if (nrows < 1)
798803
nrows = 1;
799804

@@ -856,8 +861,10 @@ class TPavePainter extends ObjectPainter {
856861

857862
if (ncols === 1)
858863
++i;
859-
else
864+
else if (!has_header || ii === 0)
860865
i = ii;
866+
else
867+
i = ii - 1 + ncols;
861868

862869
const lopt = entry.fOption.toLowerCase(),
863870
icol = i % ncols, irow = (i - icol) / ncols,

0 commit comments

Comments
 (0)