Skip to content

Commit 0786c32

Browse files
committed
Implment col0 and col0z draw option for TH2 histograms, similar to ROOT6
1 parent 099cd27 commit 0786c32

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
8. Enable usage of all context menus on touch devices
1212
9. Implement JSROOT.Math.Prob function, provides probability value in stat box
1313
10. Introduce context menu for color palette (z axis)
14+
11. Implment col0 and col0z draw option for TH2 histograms, similar to ROOT6
1415

1516

1617
## Changes in 3.8

docs/drawoptions.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130

131131
LoadFile("hsimple.root", function(file) {
132132
draw_item_options(file, "hpx;1", "h1_draw", ";P;P0;E;E1;pE2", 0., "TH1");
133-
draw_item_options(file, "hpxpy;1", "h2_draw", ";COL;COLZ;COL2;COL3;LEGO", 0., "TH2");
133+
draw_item_options(file, "hpxpy;1", "h2_draw", ";COL;COLZ;COL0Z;COL2;COL3;LEGO", 0., "TH2");
134134
draw_item_options(file, "hprof;1", "prof_draw", ";E;E1;pE2;hist", 0., "TProfile");
135135
});
136136

scripts/JSRootPainter.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4327,6 +4327,7 @@
43274327
if (l!=-1) {
43284328
var name = 'COL';
43294329

4330+
if (chopt.charAt(l+3)=='0') { option.Color = 111; name += "0"; l++; } else
43304331
if (chopt.charAt(l+3)=='1') { option.Color = 1; name += "1"; l++; } else
43314332
if (chopt.charAt(l+3)=='2') { option.Color = 2; name += "2"; l++; } else
43324333
if (chopt.charAt(l+3)=='3') { option.Color = 3; name += "3"; l++; } else
@@ -6548,8 +6549,8 @@
65486549

65496550
JSROOT.TH2Painter.prototype.FillContextMenu = function(menu) {
65506551
JSROOT.THistPainter.prototype.FillContextMenu.call(this, menu);
6551-
menu.add("Auto zoom-in", function() { this.AutoZoom(); });
6552-
menu.add("Draw in 3D", function() { this.Draw3D(); });
6552+
menu.add("Auto zoom-in", this.AutoZoom().bind(this));
6553+
menu.add("Draw in 3D", this.Draw3D().bind(this));
65536554
menu.add("Toggle col", function() {
65546555
if (this.options.Color == 0)
65556556
this.options.Color = JSROOT.gStyle.DefaultCol;
@@ -6559,7 +6560,7 @@
65596560
});
65606561

65616562
if (this.options.Color > 0)
6562-
menu.add("Toggle colz", function() { this.ToggleColz(); });
6563+
menu.add("Toggle colz", this.ToggleColz().bind(this));
65636564
}
65646565

65656566
JSROOT.TH2Painter.prototype.FindPalette = function(remove) {
@@ -6947,8 +6948,11 @@
69476948
color = Math.floor(0.01+(zc-this.zmin)*(this.fContour.length-1)/(this.zmax-this.zmin));
69486949
}
69496950

6951+
if (color<0) {
69506952
// do not draw bin where color is negative
6951-
if (color<0) return null;
6953+
if (this.options.Color != 111) return null;
6954+
color = 0;
6955+
}
69526956

69536957
var palette = JSROOT.gStyle.GetColorPalette();
69546958
var theColor = Math.floor((color+0.99)*palette.length/(this.fContour.length-1));
@@ -7011,7 +7015,6 @@
70117015
if (gry1 < 0) gry1 = this.gry(y1);
70127016
gry2 = this.gry(y2);
70137017

7014-
70157018
binz = this.histo.getBinContent(i + 1, j + 1);
70167019
if ((binz == 0) || (binz < this.minbin)) continue;
70177020

@@ -9612,7 +9615,7 @@
96129615
JSROOT.addDrawFunc({ name: "TPaveLabel", func:JSROOT.Painter.drawText });
96139616
JSROOT.addDrawFunc({ name: /^TH1/, icon: "img_histo1d", func:JSROOT.Painter.drawHistogram1D, opt:";P;P0;E;E1;E2;same"});
96149617
JSROOT.addDrawFunc({ name: "TProfile", icon: "img_profile", func:JSROOT.Painter.drawHistogram1D, opt:";E0;E1;E2;p;hist"});
9615-
JSROOT.addDrawFunc({ name: /^TH2/, icon: "img_histo2d", func:JSROOT.Painter.drawHistogram2D, opt:";COL;COLZ;COL3;LEGO;same" });
9618+
JSROOT.addDrawFunc({ name: /^TH2/, icon: "img_histo2d", func:JSROOT.Painter.drawHistogram2D, opt:";COL;COLZ;COL0Z;COL3;LEGO;same" });
96169619
JSROOT.addDrawFunc({ name: /^TH3/, icon: 'img_histo3d', prereq: "3d", func: "JSROOT.Painter.drawHistogram3D" });
96179620
JSROOT.addDrawFunc({ name: "THStack", func:JSROOT.Painter.drawHStack });
96189621
JSROOT.addDrawFunc({ name: "TF1", icon: "img_graph", func:JSROOT.Painter.drawFunction });

0 commit comments

Comments
 (0)