Skip to content

Commit 702e8ec

Browse files
committed
Build with new graph features
1 parent 23ded0d commit 702e8ec

File tree

2 files changed

+106
-38
lines changed

2 files changed

+106
-38
lines changed

build/jsroot.js

Lines changed: 105 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const version_id = 'dev',
1212

1313
/** @summary version date
1414
* @desc Release date in format day/month/year like '14/04/2022' */
15-
version_date = '23/05/2025',
15+
version_date = '26/05/2025',
1616

1717
/** @summary version id and date
1818
* @desc Produced by concatenation of {@link version_id} and {@link version_date}
@@ -394,29 +394,43 @@ gStyle = {
394394
fOptLogy: 0,
395395
/** @summary Default log z scale */
396396
fOptLogz: 0,
397+
/** @summary Show date on canvas */
397398
fOptDate: 0,
399+
/** @summary Show file name on canvas */
398400
fOptFile: 0,
401+
/** @summary X position of date on canvas */
399402
fDateX: 0.01,
403+
/** @summary Y position of date on canvas */
400404
fDateY: 0.01,
401405
/** @summary Draw histogram title */
402406
fOptTitle: 1,
403407
/** @summary Canvas fill color */
404408
fCanvasColor: 0,
405409
/** @summary Pad fill color */
406410
fPadColor: 0,
411+
/** @summary Pad bottom margin */
407412
fPadBottomMargin: 0.1,
413+
/** @summary Pad top margin */
408414
fPadTopMargin: 0.1,
415+
/** @summary Pad left margin */
409416
fPadLeftMargin: 0.1,
417+
/** @summary Pad right margin */
410418
fPadRightMargin: 0.1,
411419
/** @summary TPad.fGridx default value */
412420
fPadGridX: false,
413421
/** @summary TPad.fGridy default value */
414422
fPadGridY: false,
423+
/** @summary TPad.fTickx default value */
415424
fPadTickX: 0,
425+
/** @summary TPad.fTicky default value */
416426
fPadTickY: 0,
427+
/** @summary Pad border size */
417428
fPadBorderSize: 2,
429+
/** @summary Pad border mode */
418430
fPadBorderMode: 0,
431+
/** @summary Canvas border size */
419432
fCanvasBorderSize: 2,
433+
/** @summary Canvas border mode */
420434
fCanvasBorderMode: 0,
421435
/** @summary fill color for stat box */
422436
fStatColor: 0,
@@ -432,16 +446,27 @@ gStyle = {
432446
fStatBorderSize: 1,
433447
/** @summary Printing format for stats */
434448
fStatFormat: '6.4g',
449+
/** @summary Stat box X position - top right corner */
435450
fStatX: 0.98,
451+
/** @summary Stat box Y position - top right corner */
436452
fStatY: 0.935,
453+
/** @summary Stat box width */
437454
fStatW: 0.2,
455+
/** @summary Stat box height */
438456
fStatH: 0.16,
457+
/** @summary Title text align */
439458
fTitleAlign: 23,
459+
/** @summary Title fill color */
440460
fTitleColor: 0,
461+
/** @summary Title text color */
441462
fTitleTextColor: 1,
463+
/** @summary Title border size */
442464
fTitleBorderSize: 0,
465+
/** @summary Title text font */
443466
fTitleFont: 42,
467+
/** @summary Title font size */
444468
fTitleFontSize: 0.05,
469+
/** @summary Title fill style */
445470
fTitleStyle: 0,
446471
/** @summary X position of top left corner of title box */
447472
fTitleX: 0.5,
@@ -453,18 +478,31 @@ gStyle = {
453478
fTitleH: 0,
454479
/** @summary Printing format for fit parameters */
455480
fFitFormat: '5.4g',
481+
/** @summary Default optstat value */
456482
fOptStat: 1111,
483+
/** @summary Default optfit value */
457484
fOptFit: 0,
485+
/** @summary Default number of colors in contour */
458486
fNumberContours: 20,
487+
/** @summary Grids color */
459488
fGridColor: 0,
489+
/** @summary Grids line style */
460490
fGridStyle: 3,
491+
/** @summary Grids line width */
461492
fGridWidth: 1,
493+
/** @summary Frame fill color */
462494
fFrameFillColor: 0,
495+
/** @summary Frame fill style */
463496
fFrameFillStyle: 1001,
497+
/** @summary Frame line color */
464498
fFrameLineColor: 1,
499+
/** @summary Frame line width */
465500
fFrameLineWidth: 1,
501+
/** @summary Frame line style */
466502
fFrameLineStyle: 1,
503+
/** @summary Frame border size */
467504
fFrameBorderSize: 1,
505+
/** @summary Frame border mode */
468506
fFrameBorderMode: 0,
469507
/** @summary size in pixels of end error for E1 draw options */
470508
fEndErrorSize: 2,
@@ -474,20 +512,31 @@ gStyle = {
474512
fHistMinimumZero: false,
475513
/** @summary Margin between histogram's top and pad's top */
476514
fHistTopMargin: 0.05,
515+
/** @summary Histogram fill color */
477516
fHistFillColor: 0,
517+
/** @summary Histogram fill style */
478518
fHistFillStyle: 1001,
519+
/** @summary Histogram line color */
479520
fHistLineColor: 602,
521+
/** @summary Histogram line style */
480522
fHistLineStyle: 1,
523+
/** @summary Histogram line width */
481524
fHistLineWidth: 1,
482525
/** @summary format for bin content */
483526
fPaintTextFormat: 'g',
484527
/** @summary default time offset, UTC time at 01/01/95 */
485528
fTimeOffset: 788918400,
529+
/** @summary Legend border size */
486530
fLegendBorderSize: 1,
531+
/** @summary Legend text font */
487532
fLegendFont: 42,
533+
/** @summary Legend font size */
488534
fLegendTextSize: 0,
535+
/** @summary Legend fill color */
489536
fLegendFillColor: 0,
537+
/** @summary Legend fill style */
490538
fLegendFillStyle: 1001,
539+
/** @summary Hatches line width in fill styles */
491540
fHatchesLineWidth: 1,
492541
fHatchesSpacing: 1,
493542
fCandleWhiskerRange: 1.0,
@@ -503,7 +552,10 @@ gStyle = {
503552
fYAxisExpYOffset: 0,
504553
fAxisMaxDigits: 5,
505554
fStripDecimals: true,
506-
fBarWidth: 1
555+
/** @summary Width of bar for graphs */
556+
fBarWidth: 1,
557+
/** @summary Offset of bar for graphs */
558+
fBarOffset: 0
507559
};
508560

509561
/** @summary Method returns current document in use
@@ -12315,6 +12367,12 @@ function isPadPainter(p) {
1231512367
return isFunc(p?.getRootPad) && isFunc(p?.forEachPainterInPad);
1231612368
}
1231712369

12370+
/** @summary returns canvas painter from DOM element @private */
12371+
function getDomCanvasPainter(dom) {
12372+
const elem = dom?.select('.root_canvas');
12373+
return !elem || elem.empty() ? null : elem.property('pad_painter');
12374+
}
12375+
1231812376
/**
1231912377
* @summary Painter class for ROOT objects
1232012378
*
@@ -12377,18 +12435,11 @@ class ObjectPainter extends BasePainter {
1237712435

1237812436
/** @summary returns canvas painter
1237912437
* @protected */
12380-
getCanvPainter(try_select) {
12438+
getCanvPainter() {
1238112439
let pp = this.getPadPainter();
12382-
if (!pp && try_select) {
12383-
const elem = this.getCanvSvg();
12384-
return elem.empty() ? null : elem.property('pad_painter');
12385-
}
12386-
while (pp && !pp.isCanvas()) {
12387-
const top = pp.getPadPainter();
12388-
if (!top) break;
12389-
pp = top;
12390-
}
12391-
return pp?.isCanvas() ? pp : null;
12440+
while (pp && !pp.isCanvas())
12441+
pp = pp.getPadPainter();
12442+
return pp;
1239212443
}
1239312444

1239412445
/** @summary Indicates that drawing runs in batch mode
@@ -12530,7 +12581,7 @@ class ObjectPainter extends BasePainter {
1253012581
if (isFunc(this.#options.asString)) {
1253112582
let changed = false;
1253212583
const pp = this.getPadPainter();
12533-
if (!this.#options_store || pp?._interactively_changed)
12584+
if (!this.#options_store || pp?.options._interactively_changed)
1253412585
changed = true;
1253512586
else {
1253612587
for (const k in this.#options_store) {
@@ -12942,7 +12993,7 @@ class ObjectPainter extends BasePainter {
1294212993
pad_painter = this.#pad_painter_ref.deref();
1294312994
else {
1294412995
if (!pad_painter)
12945-
pad_painter = this.getCanvPainter(true); // try to detect in DOM
12996+
pad_painter = getDomCanvasPainter(this.selectDom()); // try to detect in DOM
1294612997
if (pad_painter)
1294712998
this.#pad_painter_ref = new WeakRef(pad_painter);
1294812999
}
@@ -13982,21 +14033,21 @@ function drawRawText(dom, txt /* , opt */) {
1398214033
}
1398314034

1398414035
/** @summary Returns canvas painter (if any) for specified DOM element
13985-
* @param {string|object} dom - id or DOM element
14036+
* @param {string|object} dom - id or DOM element or pad painter
1398614037
* @private */
1398714038
function getElementCanvPainter(dom) {
13988-
return isPadPainter(dom) ? dom.getCanvPainter() : new ObjectPainter(dom).getCanvPainter(true);
14039+
return isPadPainter(dom) ? dom.getCanvPainter() : getDomCanvasPainter(new ObjectPainter(dom).selectDom());
1398914040
}
1399014041

1399114042
/** @summary Returns pad painter (if any) for specified DOM element
13992-
* @param {string|object} dom - id or DOM element
14043+
* @param {string|object} dom - id or DOM element or pad painter
1399314044
* @private */
1399414045
function getElementPadPainter(dom) {
1399514046
return isPadPainter(dom) ? dom : new ObjectPainter(dom).getPadPainter();
1399614047
}
1399714048

1399814049
/** @summary Returns main painter (if any) for specified HTML element - typically histogram painter
13999-
* @param {string|object} dom - id or DOM element
14050+
* @param {string|object} dom - id or DOM element or pad painter
1400014051
* @private */
1400114052
function getElementMainPainter(dom) {
1400214053
return isPadPainter(dom) ? dom.getMainPainter() : new ObjectPainter(dom).getMainPainter(true);
@@ -82818,7 +82869,7 @@ class TFramePainter extends FrameInteractive {
8281882869
pad = pp?.getRootPad(true);
8281982870
if (!pad) return;
8282082871

82821-
pp._interactively_changed = true;
82872+
pp.options._interactively_changed = true;
8282282873

8282382874
const name = `fLog${axis}`;
8282482875

@@ -85581,7 +85632,6 @@ class TPadPainter extends ObjectPainter {
8558185632
this.#frame_painter_ref = undefined;
8558285633
this.#pad_x = this.#pad_y = this.#pad_width = this.#pad_height = undefined;
8558385634
this.#doing_draw = undefined;
85584-
delete this._interactively_changed;
8558585635
this.#snap_primitives = undefined;
8558685636
this.#last_grayscale = undefined;
8558785637
this.#custom_palette = this.#custom_colors = this.#custom_palette_indexes = this.#custom_palette_colors = undefined;
@@ -88930,7 +88980,7 @@ async function ensureTCanvas(painter, frame_kind) {
8893088980
canv.fY2 = ranges.maxy + dy * gStyle.fPadTopMargin;
8893188981
return canv;
8893288982
},
88933-
pad_painter = painter.getPadPainter() || painter.getCanvPainter(true),
88983+
pad_painter = painter.getPadPainter() || getDomCanvasPainter(painter.selectDom()),
8893488984
promise = pad_painter ? Promise.resolve(pad_painter) :
8893588985
TCanvasPainter.draw(painter.getDom(), createCanv(), noframe);
8893688986

@@ -90922,7 +90972,7 @@ class THistDrawOptions {
9092290972
}
9092390973

9092490974
if (d.check('LINE_', 'color'))
90925-
this.histoLineColor = getColor(d.color);
90975+
this.histoLineColor = painter.getColor(d.color);
9092690976

9092790977
if (d.check('WIDTH_', true))
9092890978
this.histoLineWidth = d.partAsInt();
@@ -101971,6 +102021,8 @@ const kNotEditable = BIT(18), // bit set if graph is non editable
101971102021
let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
101972102022

101973102023
#bins; // extracted graph bins
102024+
#barwidth; // width of each bar
102025+
#baroffset; // offset of each bar
101974102026
#redraw_hist; // indicate that histogram need to be redrawn
101975102027
#auto_exec; // can be reused when sending option back to server
101976102028
#funcs_handler; // special instance for functions drawing
@@ -102113,6 +102165,17 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
102113102165
d = new DrawOptions(res.original);
102114102166
}
102115102167

102168+
if (d.check('FILL_', 'color')) {
102169+
res.graphFillColor = d.color;
102170+
res.graphFillPattern = 1001;
102171+
}
102172+
102173+
if (d.check('LINE_', 'color'))
102174+
res.graphLineColor = this.getColor(d.color);
102175+
102176+
if (d.check('WIDTH_', true))
102177+
res.graphLineWidth = d.partAsInt();
102178+
102116102179
if (d.check('NOOPT')) res.NoOpt = 1;
102117102180

102118102181
if (d.check('POS3D_', true)) res.pos3d = d.partAsInt() - 0.5;
@@ -102514,7 +102577,8 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
102514102577

102515102578
if (main_block && lineatt.excl_side) {
102516102579
excl_width = lineatt.excl_width;
102517-
if ((lineatt.width > 0) && !options.Line && !options.Curve) options.Line = 1;
102580+
if ((lineatt.width > 0) && !options.Line && !options.Curve)
102581+
options.Line = 1;
102518102582
}
102519102583

102520102584
if (options.EF) {
@@ -102672,14 +102736,10 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
102672102736
}
102673102737
}
102674102738

102675-
if (drawbins.length === 1)
102676-
drawbins[0].width = w/4; // pathologic case of single bin
102677-
else {
102678-
for (let i = 0; i < drawbins.length; ++i)
102679-
drawbins[i].width = (xmax - xmin) / drawbins.length * gStyle.fBarWidth;
102680-
}
102681-
102682-
const yy0 = Math.round(funcs.gry(0));
102739+
const sz0 = drawbins.length < 2 ? w / 4 : (xmax - xmin) / drawbins.length,
102740+
bw = sz0 * gStyle.fBarWidth,
102741+
boff = sz0 * gStyle.fBarOffset,
102742+
yy0 = Math.round(funcs.gry(0));
102683102743
let usefill = fillatt;
102684102744

102685102745
if (main_block) {
@@ -102693,13 +102753,16 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
102693102753
nodes.append('svg:path')
102694102754
.attr('d', d => {
102695102755
d.bar = true; // element drawn as bar
102696-
const dx = d.width > 1 ? Math.round(-d.width/2) : 0,
102697-
dw = d.width > 1 ? Math.round(d.width) : 1,
102756+
const dx = bw > 1 ? Math.round(boff-bw/2) : 0,
102757+
dw = bw > 1 ? Math.round(bw) : 1,
102698102758
dy = (options.Bar !== 1) ? 0 : ((d.gry1 > yy0) ? yy0-d.gry1 : 0),
102699102759
dh = (options.Bar !== 1) ? (h > d.gry1 ? h - d.gry1 : 0) : Math.abs(yy0 - d.gry1);
102700102760
return `M${dx},${dy}h${dw}v${dh}h${-dw}z`;
102701102761
})
102702102762
.call(usefill.func);
102763+
102764+
this.#barwidth = bw;
102765+
this.#baroffset = boff;
102703102766
}
102704102767

102705102768
if (options.Rect) {
@@ -102886,8 +102949,8 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
102886102949
if (only_check_auto)
102887102950
this.deleteAttr();
102888102951
else {
102889-
this.createAttLine({ attr: graph, can_excl: true });
102890-
this.createAttFill({ attr: graph });
102952+
this.createAttLine({ attr: graph, can_excl: true, color0: o.graphLineColor, width: o.graphLineWidth });
102953+
this.createAttFill({ attr: graph, color: o.graphFillColor, pattern: o.graphFillPattern, });
102891102954
}
102892102955
}
102893102956

@@ -102957,6 +103020,8 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
102957103020
const fp = this.get_fp(),
102958103021
o = this.getOptions(),
102959103022
height = fp.getFrameHeight(),
103023+
bw = this.#barwidth,
103024+
boff = this.#baroffset,
102960103025
esz = this.error_size,
102961103026
isbar1 = (o.Bar === 1),
102962103027
funcs = isbar1 ? fp.getGrFuncs(o.second_x, o.second_y) : null,
@@ -102978,7 +103043,7 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
102978103043
y1: Math.min(-esz, d.gry2, -msize),
102979103044
y2: Math.max(esz, d.gry0, msize) };
102980103045
} else if (d.bar) {
102981-
rect = { x1: -d.width/2, x2: d.width/2, y1: 0, y2: height - d.gry1 };
103046+
rect = { x1: boff - bw / 2, x2: boff + bw / 2, y1: 0, y2: height - d.gry1 };
102982103047

102983103048
if (isbar1) {
102984103049
const yy0 = funcs.gry(0);
@@ -167119,6 +167184,8 @@ function readStyleFromURL(url) {
167119167184
settings.ToolBarVert = true;
167120167185
get_float_style('datex', 'fDateX');
167121167186
get_float_style('datey', 'fDateY');
167187+
get_float_style('barwidth', 'fBarWidth');
167188+
get_float_style('baroffset', 'fBarOffset');
167122167189

167123167190
get_int_style('opttitle', 'fOptTitle', 1);
167124167191
if (d.has('utc'))
@@ -181329,6 +181396,7 @@ exports.getActivePad = getActivePad;
181329181396
exports.getBoxDecorations = getBoxDecorations;
181330181397
exports.getColor = getColor;
181331181398
exports.getDocument = getDocument;
181399+
exports.getDomCanvasPainter = getDomCanvasPainter;
181332181400
exports.getElementCanvPainter = getElementCanvPainter;
181333181401
exports.getElementMainPainter = getElementMainPainter;
181334181402
exports.getElementPadPainter = getElementPadPainter;

0 commit comments

Comments
 (0)