Skip to content

Commit 99caf23

Browse files
committed
Format hist painters
1 parent af1381f commit 99caf23

File tree

2 files changed

+135
-83
lines changed

2 files changed

+135
-83
lines changed

modules/hist2d/TH1Painter.mjs

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ class TH1Painter extends THistPainter {
278278
for (i = left; i < right; ++i) {
279279
xx = xaxis.GetBinCoord(i + 0.5);
280280

281-
if (cond && !cond(xx)) continue;
281+
if (cond && !cond(xx))
282+
continue;
282283

283284
if (profile) {
284285
w = histo.fBinEntries[i + 1];
@@ -350,10 +351,13 @@ class TH1Painter extends THistPainter {
350351
/** @summary Fill stat box */
351352
fillStatistic(stat, dostat, dofit) {
352353
// no need to refill statistic if histogram is dummy
353-
if (this.isIgnoreStatsFill()) return false;
354+
if (this.isIgnoreStatsFill())
355+
return false;
354356

355-
if (dostat === 1) dostat = 1111;
356-
if (dofit === 1) dofit = 111;
357+
if (dostat === 1)
358+
dostat = 1111;
359+
if (dofit === 1)
360+
dofit = 111;
357361

358362
const histo = this.getHisto(),
359363
print_name = dostat % 10,
@@ -417,7 +421,8 @@ class TH1Painter extends THistPainter {
417421
stat.addText(`Kurtosis = ${stat.format(data.kurtx)}`);
418422
}
419423

420-
if (dofit) stat.fillFunctionStat(this.findFunction(clTF1), dofit, 1);
424+
if (dofit)
425+
stat.fillFunctionStat(this.findFunction(clTF1), dofit, 1);
421426

422427
return true;
423428
}
@@ -440,9 +445,11 @@ class TH1Painter extends THistPainter {
440445
xaxis = histo.fXaxis,
441446
show_text = o.Text;
442447
let text_col, text_angle, text_size,
443-
side = (o.BarStyle > 10) ? o.BarStyle % 10 : 0, pr = Promise.resolve();
448+
side = (o.BarStyle > 10) ? o.BarStyle % 10 : 0,
449+
pr = Promise.resolve();
444450

445-
if (side > 4) side = 4;
451+
if (side > 4)
452+
side = 4;
446453
const gry2 = this.getBarBaseline(funcs, height);
447454

448455
if (show_text) {
@@ -463,14 +470,16 @@ class TH1Painter extends THistPainter {
463470
const x1 = xaxis.GetBinLowEdge(i + 1),
464471
x2 = xaxis.GetBinLowEdge(i + 2);
465472

466-
if (funcs.logx && (x2 <= 0)) continue;
473+
if (funcs.logx && (x2 <= 0))
474+
continue;
467475

468476
let grx1 = Math.round(funcs.grx(x1)),
469477
grx2 = Math.round(funcs.grx(x2)),
470478
w = grx2 - grx1;
471479
const y = histo.getBinContent(i+1);
472480

473-
if (funcs.logy && (y < funcs.scale_ymin)) continue;
481+
if (funcs.logy && (y < funcs.scale_ymin))
482+
continue;
474483
const gry1 = Math.round(funcs.gry(y));
475484

476485
grx1 += Math.round(histo.fBarOffset/1000*w);
@@ -535,7 +544,8 @@ class TH1Painter extends THistPainter {
535544

536545
for (let i = left; i < right; ++i) {
537546
const x = histo.fXaxis.GetBinCoord(i+0.5);
538-
if (funcs.logx && (x <= 0)) continue;
547+
if (funcs.logx && (x <= 0))
548+
continue;
539549
const grx = Math.round(funcs.grx(x)),
540550
y = histo.getBinContent(i+1),
541551
yerrs = this.getBinErrors(histo, i + 1, y);
@@ -982,7 +992,8 @@ class TH1Painter extends THistPainter {
982992
}
983993
} else {
984994
tips.push(`bin = ${bin+1}`, `x = ${xlbl}`);
985-
if (histo.$baseh) cont -= histo.$baseh.getBinContent(bin+1);
995+
if (histo.$baseh)
996+
cont -= histo.$baseh.getBinContent(bin+1);
986997
if (cont === Math.round(cont))
987998
tips.push(`entries = ${cont}`);
988999
else
@@ -1092,7 +1103,8 @@ class TH1Painter extends THistPainter {
10921103
show_rect = !this.isTF1();
10931104

10941105
let msize = 3;
1095-
if (this.markeratt) msize = Math.max(msize, this.markeratt.getFullSize());
1106+
if (this.markeratt)
1107+
msize = Math.max(msize, this.markeratt.getFullSize());
10961108

10971109
if (o.Error) {
10981110
const cont = histo.getBinContent(findbin + 1),
@@ -1104,7 +1116,7 @@ class TH1Painter extends THistPainter {
11041116
if ((cont === 0) && this.isTProfile())
11051117
findbin = null;
11061118

1107-
const dx = (grx2 - grx1)*o.errorX;
1119+
const dx = (grx2 - grx1) * o.errorX;
11081120
grx1 = Math.round(midx - dx);
11091121
grx2 = Math.round(midx + dx);
11101122
}
@@ -1115,12 +1127,14 @@ class TH1Painter extends THistPainter {
11151127
gry1 = Math.min(gry1, midy - msize);
11161128
gry2 = Math.max(gry2, midy + msize);
11171129

1118-
if (!pnt.touch && (pnt.nproc === 1))
1119-
if ((pnt_y < gry1) || (pnt_y > gry2)) findbin = null;
1130+
if (!pnt.touch && (pnt.nproc === 1)) {
1131+
if ((pnt_y < gry1) || (pnt_y > gry2))
1132+
findbin = null;
1133+
}
11201134
} else {
11211135
// if histogram alone, use old-style with rects
11221136
// if there are too many points at pixel, use circle
1123-
show_rect = (pnt.nproc === 1) && (right-left < width);
1137+
show_rect = (pnt.nproc === 1) && (right - left < width);
11241138

11251139
if (show_rect) {
11261140
gry2 = height;
@@ -1188,7 +1202,7 @@ class TH1Painter extends THistPainter {
11881202

11891203
res.menu = res.exact; // one could show context menu when histogram is selected
11901204
// distance to middle point, use to decide which menu to activate
1191-
res.menu_dist = Math.sqrt((midx-pnt_x)**2 + (midy-pnt_y)**2);
1205+
res.menu_dist = Math.sqrt((midx - pnt_x)**2 + (midy - pnt_y)**2);
11921206
} else {
11931207
const radius = this.lineatt.width + 3;
11941208

@@ -1251,8 +1265,9 @@ class TH1Painter extends THistPainter {
12511265
rebinHist(sz) {
12521266
const histo = this.getHisto(),
12531267
xaxis = histo.fXaxis,
1254-
nbins = Math.floor(xaxis.fNbins/ sz);
1255-
if (nbins < 2) return;
1268+
nbins = Math.floor(xaxis.fNbins / sz);
1269+
if (nbins < 2)
1270+
return;
12561271

12571272
const arr = new Array(nbins+2),
12581273
xbins = xaxis.fXbins.length ? new Array(nbins) : null;
@@ -1298,13 +1313,15 @@ class TH1Painter extends THistPainter {
12981313
const dist = right - left,
12991314
histo = this.getHisto();
13001315

1301-
if ((dist === 0) || !histo) return;
1316+
if ((dist === 0) || !histo)
1317+
return;
13021318

13031319
// first find minimum
13041320
let min = histo.getBinContent(left + 1);
13051321
for (let indx = left; indx < right; ++indx)
13061322
min = Math.min(min, histo.getBinContent(indx+1));
1307-
if (min > 0) return; // if all points positive, no chance for auto-scale
1323+
if (min > 0)
1324+
return; // if all points positive, no chance for auto-scale
13081325

13091326
while ((left < right) && (histo.getBinContent(left+1) <= min)) ++left;
13101327
while ((left < right) && (histo.getBinContent(right) <= min)) --right;
@@ -1322,9 +1339,11 @@ class TH1Painter extends THistPainter {
13221339
canZoomInside(axis, min, max) {
13231340
const histo = this.getHisto();
13241341

1325-
if ((axis === 'x') && histo && (histo.fXaxis.FindBin(max, 0.5) - histo.fXaxis.FindBin(min, 0) > 1)) return true;
1342+
if ((axis === 'x') && histo && (histo.fXaxis.FindBin(max, 0.5) - histo.fXaxis.FindBin(min, 0) > 1))
1343+
return true;
13261344

1327-
if ((axis === 'y') && (Math.abs(max-min) > Math.abs(this.ymax-this.ymin)*1e-6)) return true;
1345+
if ((axis === 'y') && (Math.abs(max - min) > Math.abs(this.ymax - this.ymin)*1e-6))
1346+
return true;
13281347

13291348
return false;
13301349
}

0 commit comments

Comments
 (0)