From 4b1132948b3af7bf97b43a90b84a0203134b0250 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Wed, 19 Jun 2024 14:40:08 +0200 Subject: [PATCH] Build with new TProfile draw options --- build/jsroot.js | 40 ++++++++++++++++++++++++++++++++++------ changes.md | 2 +- modules/core.mjs | 2 +- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/build/jsroot.js b/build/jsroot.js index 967a6156c..a440c9b63 100644 --- a/build/jsroot.js +++ b/build/jsroot.js @@ -11,7 +11,7 @@ const version_id = 'dev', /** @summary version date * @desc Release date in format day/month/year like '14/04/2022' */ -version_date = '18/06/2024', +version_date = '19/06/2024', /** @summary version id and date * @desc Produced by concatenation of {@link version_id} and {@link version_date} @@ -1724,6 +1724,9 @@ function getMethods(typename, obj) { if (!this.fArray) return 0; return this.fArray[bin]/this.fBinEntries[bin]; }; + m.getBinEntries = function(bin) { + return (bin < 0) || (bin >= this.fNcells) ? 0 : this.fBinEntries[bin]; + }; } m.getBinEffectiveEntries = function(bin) { if (bin < 0 || bin >= this.fNcells) return 0; @@ -72907,7 +72910,7 @@ class THistDrawOptions { Lego: 0, Surf: 0, Off: 0, Tri: 0, Proj: 0, AxisPos: 0, Ortho: gStyle.fOrthoCamera, Spec: false, Pie: false, List: false, Zscale: false, Zvert: true, PadPalette: false, Candle: '', Violin: '', Scaled: null, Circular: 0, - GLBox: 0, GLColor: false, Project: '', Profile2DProj: '', System: kCARTESIAN, + GLBox: 0, GLColor: false, Project: '', ProfileProj: '', Profile2DProj: '', System: kCARTESIAN, AutoColor: false, NoStat: false, ForceStat: false, PadStats: false, PadTitle: false, AutoZoom: false, HighRes: 0, Zero: 1, Palette: 0, BaseLine: false, ShowEmpty: false, Optimize: settings.OptimizeDraw, adjustFrame: false, @@ -73244,7 +73247,12 @@ class THistDrawOptions { this.Project = 'XY' + d.partAsInt(0, 1); } - if (d.check('PROJX', true)) this.Project = 'X' + d.part; + if (d.check('PROJX', true)) { + if (histo?._typename === clTProfile) + this.ProfileProj = d.part || 'B'; + else + this.Project = 'X' + d.part; + } if (d.check('PROJY', true)) this.Project = 'Y' + d.part; if (d.check('PROJ')) this.Project = 'Y1'; @@ -73432,6 +73440,9 @@ class THistDrawOptions { if (this.is3d() && this.Ortho && is_main_hist) res += '_ORTHO'; + if (this.ProfileProj) + res += '_PROJX' + this.ProfileProj; + if (this.Profile2DProj) res += '_PROJXY' + this.Profile2DProj; @@ -75936,7 +75947,7 @@ let TH2Painter$2 = class TH2Painter extends THistPainter { this.projection_widthY = widthY; this.is_projection = ''; // avoid projection handling until area is created - this.provideSpecialDrawArea(new_proj).then(() => { this.is_projection = new_proj; return this.redrawProjection(); }); + return this.provideSpecialDrawArea(new_proj).then(() => { this.is_projection = new_proj; return this.redrawProjection(); }); } /** @summary Redraw projection */ @@ -76094,7 +76105,7 @@ let TH2Painter$2 = class TH2Painter extends THistPainter { return this.showInspector(arg); const oldProject = this.options.Project; this.decodeOptions(arg); - if (oldProject === this.options.Project) + if ((oldProject === this.options.Project) || this.mode3d) this.interactiveRedraw('pad', 'drawopt'); else this.toggleProjection(this.options.Project); @@ -80985,6 +80996,23 @@ const PadDrawOptions = ['LOGXY', 'LOGX', 'LOGY', 'LOGZ', 'LOGV', 'LOG', 'LOG2X', let TH1Painter$2 = class TH1Painter extends THistPainter { + /** @summary Returns histogram + * @desc Also assigns custom getBinContent method for TProfile if PROJX options specified */ + getHisto() { + const histo = super.getHisto(); + if (histo?._typename === clTProfile) { + if (!histo.$getBinContent) + histo.$getBinContent = histo.getBinContent; + switch (this.options?.ProfileProj) { + case 'B': histo.getBinContent = histo.getBinEntries; break; + case 'C=E': histo.getBinContent = histo.getBinError; break; + case 'W': histo.getBinContent = function(i) { return this.$getBinContent(i) * this.getBinEntries(i); }; break; + default: histo.getBinContent = histo.$getBinContent; break; + } + } + return histo; + } + /** @summary Convert TH1K into normal binned histogram */ convertTH1K() { const histo = this.getObject(); @@ -103238,7 +103266,7 @@ drawFuncs = { lst: [ { name: clTText, sameas: clTLatex }, { name: clTAnnotation, sameas: clTLatex }, { name: /^TH1/, icon: 'img_histo1d', class: () => Promise.resolve().then(function () { return TH1Painter$1; }).then(h => h.TH1Painter), opt: ';hist;P;P0;E;E1;E2;E3;E4;E1X0;L;LF2;C;B;B1;A;TEXT;LEGO;same', ctrl: 'l', expand_item: fFunctions, for_derived: true }, - { name: clTProfile, icon: 'img_profile', class: () => Promise.resolve().then(function () { return TH1Painter$1; }).then(h => h.TH1Painter), opt: ';E0;E1;E2;p;AH;hist', expand_item: fFunctions }, + { name: clTProfile, icon: 'img_profile', class: () => Promise.resolve().then(function () { return TH1Painter$1; }).then(h => h.TH1Painter), opt: ';E0;E1;E2;p;AH;hist;projx;projxb;projxc=e;projxw', expand_item: fFunctions }, { name: clTH2Poly, icon: 'img_histo2d', class: () => Promise.resolve().then(function () { return TH2Painter$1; }).then(h => h.TH2Painter), opt: ';COL;COL0;COLZ;LCOL;LCOL0;LCOLZ;LEGO;TEXT;same', expand_item: 'fBins', theonly: true }, { name: 'TProfile2Poly', sameas: clTH2Poly }, { name: 'TH2PolyBin', icon: 'img_histo2d', draw_field: 'fPoly', draw_field_opt: 'L' }, diff --git a/changes.md b/changes.md index 071e1e911..f42ee55ba 100644 --- a/changes.md +++ b/changes.md @@ -5,7 +5,7 @@ 2. Support gStyle.fLegendFillStyle 3. Let change histogram min/max values via context menu 4. Support Z-scale zooming with TScatter -5. TProfile2D projections https://github.com/root-project/root/issues/15851 +5. TProfile and TProfile2D projections https://github.com/root-project/root/issues/15851 6. Fix - hide empty title on the canvas 7. Fix - properly handle zooming in THStack histogram 8. Fix - properly save zoomed ranges in drawingJSON() diff --git a/modules/core.mjs b/modules/core.mjs index e146ffcf7..47b73ef74 100644 --- a/modules/core.mjs +++ b/modules/core.mjs @@ -4,7 +4,7 @@ const version_id = 'dev', /** @summary version date * @desc Release date in format day/month/year like '14/04/2022' */ -version_date = '18/06/2024', +version_date = '19/06/2024', /** @summary version id and date * @desc Produced by concatenation of {@link version_id} and {@link version_date}