Skip to content

Commit 5d791ad

Browse files
committed
[jsroot] dev 5/11/2025
1. Implement for `TPie` 3d, text, title drawing including interactivity 2. Fix - proper paint axis labels on both sides when pad.fTickx/y = 2 3. Fix - paint frame border mode/size from TCanvas
1 parent 255a367 commit 5d791ad

18 files changed

+1086
-366
lines changed

js/build/jsroot.js

Lines changed: 534 additions & 180 deletions
Large diffs are not rendered by default.

js/changes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# JSROOT changelog
22

3+
4+
## Changes in dev
5+
1. Implement for `TPie` 3d, text, title drawing including interactivity
6+
1. Fix - proper paint axis labels on both sides when pad.fTickx/y = 2
7+
1. Fix - paint frame border mode/size from TCanvas
8+
9+
310
## Changes in 7.10.0
411
1. `RNtuple` support, thanks to Kriti Mahajan https://github.com/Krmjn09
512
2. Implement `RTreeMapPainter` to display `RNTuple` structure, thanks to Patryk Pilichowski https://github.com/magnustymoteus

js/modules/base/colors.mjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,23 @@ function findColor(name) {
191191
/** @summary Add new color
192192
* @param {string} rgb - color name or just string with rgb value
193193
* @param {array} [lst] - optional colors list, to which add colors
194+
* @param {array} [lst] - optional colors list, to which add colors
194195
* @return {number} index of new color
195196
* @private */
196-
function addColor(rgb, lst) {
197+
function addColor(rgb, lst, indx) {
197198
if (!lst)
198199
lst = gbl_colors_list;
199200

200201
if ((rgb[0] === '#') && (isNodeJs() || (isBatchMode() && settings.ApproxTextSize)))
201202
rgb = d3_color(rgb).formatRgb();
202203

203-
const indx = lst.indexOf(rgb);
204+
if (indx !== undefined) {
205+
if (Number.isInteger(indx) && (indx > 0))
206+
lst[indx] = rgb;
207+
return indx;
208+
}
209+
210+
indx = lst.indexOf(rgb);
204211
if (indx >= 0)
205212
return indx;
206213
lst.push(rgb);

js/modules/core.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const version_id = 'dev',
66

77
/** @summary version date
88
* @desc Release date in format day/month/year like '14/04/2022' */
9-
version_date = '27/10/2025',
9+
version_date = '5/11/2025',
1010

1111
/** @summary version id and date
1212
* @desc Produced by concatenation of {@link version_id} and {@link version_date}

js/modules/draw.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const drawFuncs = { lst: [
101101
{ name: clTEllipse, icon: 'img_graph', draw: () => import_more().then(h => h.drawEllipse), direct: true },
102102
{ name: 'TArc', sameas: clTEllipse },
103103
{ name: 'TCrown', sameas: clTEllipse },
104-
{ name: 'TPie', icon: 'img_graph', draw: () => import_more().then(h => h.drawPie), direct: true },
104+
{ name: 'TPie', icon: 'img_graph', class: () => import('./draw/TPiePainter.mjs').then(h => h.TPiePainter), opt: ';3D' },
105105
{ name: 'TPieSlice', icon: 'img_graph', dummy: true },
106106
{ name: 'TExec', icon: 'img_graph', dummy: true },
107107
{ name: clTLine, icon: 'img_graph', class: () => import('./draw/TLinePainter.mjs').then(h => h.TLinePainter) },

js/modules/draw/TBoxPainter.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class TBoxPainter extends ObjectPainter {
152152
return this;
153153
}
154154

155-
/** @summary Draw TLine object */
155+
/** @summary Draw TBox object */
156156
static async draw(dom, obj, opt) {
157157
const painter = new TBoxPainter(dom, obj, opt);
158158
return ensureTCanvas(painter, false).then(() => painter.redraw());

js/modules/draw/TGraphPolarPainter.mjs

Lines changed: 11 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { settings, gStyle, create, BIT, clTPaveText, kTitle } from '../core.mjs';
1+
import { settings, create, BIT } from '../core.mjs';
22
import { scaleLinear, pointer as d3_pointer } from '../d3.mjs';
33
import { DrawOptions, buildSvgCurve, makeTranslate } from '../base/BasePainter.mjs';
44
import { ObjectPainter, getElementMainPainter } from '../base/ObjectPainter.mjs';
5-
import { TPavePainter, kPosTitle } from '../hist/TPavePainter.mjs';
5+
import { drawObjectTitle } from '../hist/TPavePainter.mjs';
66
import { ensureTCanvas } from '../gpad/TCanvasPainter.mjs';
77
import { TooltipHandler } from '../gpad/TFramePainter.mjs';
88
import { assignContextMenu, kNoReorder } from '../gui/menu.mjs';
@@ -496,9 +496,15 @@ class TGraphPolarPainter extends ObjectPainter {
496496
return true;
497497
}
498498

499+
/** @summary Draw TGraphPolar title */
500+
async drawTitle(first_time) {
501+
return drawObjectTitle(this, first_time, this._draw_axis, !this.getObject()?.TestBit(kNoTitle));
502+
}
503+
499504
/** @summary Redraw TGraphPolar */
500-
redraw() {
501-
return this.drawGraphPolar().then(() => this.updateTitle());
505+
async redraw() {
506+
return this.drawGraphPolar()
507+
.then(() => this.drawTitle());
502508
}
503509

504510
/** @summary Drawing TGraphPolar */
@@ -681,64 +687,6 @@ class TGraphPolarPainter extends ObjectPainter {
681687
return res;
682688
}
683689

684-
/** @summary Only redraw histogram title
685-
* @return {Promise} with painter */
686-
async updateTitle() {
687-
// case when histogram drawn over other histogram (same option)
688-
if (!this._draw_axis)
689-
return this;
690-
691-
const tpainter = this.getPadPainter()?.findPainterFor(null, kTitle, clTPaveText),
692-
pt = tpainter?.getObject();
693-
694-
if (!tpainter || !pt)
695-
return this;
696-
697-
const gr = this.getObject(),
698-
draw_title = !gr.TestBit(kNoTitle) && (gStyle.fOptTitle > 0);
699-
700-
pt.Clear();
701-
if (draw_title)
702-
pt.AddText(gr.fTitle);
703-
return tpainter.redraw().then(() => this);
704-
}
705-
706-
707-
/** @summary Draw histogram title
708-
* @return {Promise} with painter */
709-
async drawTitle() {
710-
// case when histogram drawn over other histogram (same option)
711-
if (!this._draw_axis)
712-
return this;
713-
714-
const gr = this.getObject(),
715-
st = gStyle,
716-
draw_title = !gr.TestBit(kNoTitle) && (st.fOptTitle > 0),
717-
pp = this.getPadPainter();
718-
719-
let pt = pp.findInPrimitives(kTitle, clTPaveText);
720-
721-
if (pt) {
722-
pt.Clear();
723-
if (draw_title)
724-
pt.AddText(gr.fTitle);
725-
return this;
726-
}
727-
728-
pt = create(clTPaveText);
729-
Object.assign(pt, {
730-
fName: kTitle, fFillColor: st.fTitleColor, fFillStyle: st.fTitleStyle, fBorderSize: st.fTitleBorderSize,
731-
fTextFont: st.fTitleFont, fTextSize: st.fTitleFontSize, fTextColor: st.fTitleTextColor, fTextAlign: 22
732-
});
733-
734-
if (draw_title)
735-
pt.AddText(gr.fTitle);
736-
return TPavePainter.draw(pp, pt, kPosTitle).then(p => {
737-
p?.setSecondaryId(this, kTitle);
738-
return this;
739-
});
740-
}
741-
742690
/** @summary Show tooltip */
743691
showTooltip(hint) {
744692
let ttcircle = this.getG()?.selectChild('.tooltip_bin');
@@ -797,7 +745,7 @@ class TGraphPolarPainter extends ObjectPainter {
797745
gram_painter?.setSecondaryId(painter, 'polargram');
798746
painter.addToPadPrimitives();
799747
return painter.drawGraphPolar();
800-
}).then(() => painter.drawTitle());
748+
}).then(() => painter.drawTitle(true));
801749
}
802750

803751
} // class TGraphPolarPainter

0 commit comments

Comments
 (0)