Skip to content

Commit 6327bd8

Browse files
committed
Fix - correctly draw empty th2 bins when zmin<0 is specified
1 parent d4c3b95 commit 6327bd8

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
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 4.5.x
44
1. Fix - position of TFrame in canvas/pad
55
2. Fix - use histogram fMinimum/fMaximum when creating color palette
6+
3. Fix - correctly draw empty th2 bins when zmin<0 is specified
67

78

89
## Changes in 4.5.1

scripts/JSRootPainter.more.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,7 +2482,7 @@
24822482
for (var i=0;i<contour.length-1;++i) {
24832483
var z0 = z(contour[i]);
24842484
var z1 = z(contour[i+1]);
2485-
var col = this.main_painter().getValueColor(contour[i]);
2485+
var col = this.main_painter().getValueColor((contour[i] + contour[i+1])/2);
24862486

24872487
var pnt = { x: 128, width: 256, y: Math.round(z1/h*512) , height: Math.round((z0-z1)/h*512), fill: col };
24882488

@@ -2544,7 +2544,7 @@
25442544
for (var i=0;i<contour.length-1;++i) {
25452545
var z0 = z(contour[i]),
25462546
z1 = z(contour[i+1]),
2547-
col = this.main_painter().getValueColor(contour[i]);
2547+
col = this.main_painter().getValueColor((contour[i]+contour[i+1])/2);
25482548

25492549
var r = this.draw_g.append("svg:rect")
25502550
.attr("x", 0)
@@ -3132,17 +3132,19 @@
31323132
return l;
31333133
}
31343134

3135+
// bins less than zmin not drawn
3136+
if (zc < this.zmin) return -111;
3137+
3138+
// if bin content exactly zmin, draw it when col0 specified or when content is positive
3139+
if (zc===this.zmin) return ((this.zmin > 0) || (this.options.Color === 111)) ? 0 : -1;
3140+
31353141
return Math.floor(0.01+(zc-this.zmin)*(this.fContour.length-1)/(this.zmax-this.zmin));
31363142
}
31373143

31383144
JSROOT.TH2Painter.prototype.getValueColor = function(zc, asindx) {
31393145
var index = this.getContourIndex(zc);
31403146

3141-
if (index<0) {
3142-
// do not draw bin where color is negative, only with col0 option minimal values are shown
3143-
if (this.options.Color !== 111) return null;
3144-
index = 0;
3145-
}
3147+
if (index<0) return null;
31463148

31473149
if (this.fPalette == null)
31483150
this.fPalette = JSROOT.Painter.GetColorPalette(this.options.Palette);
@@ -3430,7 +3432,7 @@
34303432
for (i = handle.i1; i < handle.i2; ++i) {
34313433
for (j = handle.j1; j < handle.j2; ++j) {
34323434
binz = histo.getBinContent(i + 1, j + 1);
3433-
if ((binz == 0) || (binz < this.minbin)) continue;
3435+
//if ((binz == 0) || (binz < this.minbin)) continue;
34343436

34353437
colindx = this.getValueColor(binz, true);
34363438
if (colindx === null) continue;
@@ -3478,7 +3480,7 @@
34783480
for (i = handle.i1; i < handle.i2; ++i)
34793481
for (j = handle.j1; j < handle.j2; ++j) {
34803482
binz = histo.getBinContent(i + 1, j + 1);
3481-
if ((binz == 0) || (binz < this.minbin)) continue;
3483+
//if ((binz == 0) || (binz < this.minbin)) continue;
34823484

34833485
colindx = this.getValueColor(binz, true);
34843486
if (colindx === null) continue;

0 commit comments

Comments
 (0)