Skip to content

Commit 0848054

Browse files
committed
Export default frame position in JSROOT.gStyle.FrameNDC field
1 parent 8bfcb8e commit 0848054

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

scripts/JSRootPainter.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
AutoStat : true,
4646
OptStat : 1111,
4747
OptFit : 0,
48-
StatNDC : { fX1NDC : 0.78, fY1NDC: 0.75, fX2NDC: 0.98, fY2NDC: 0.91 },
48+
FrameNDC : { fX1NDC: 0.07, fY1NDC: 0.12, fX2NDC: 0.95, fY2NDC: 0.88 },
49+
StatNDC : { fX1NDC: 0.78, fY1NDC: 0.75, fX2NDC: 0.98, fY2NDC: 0.91 },
4950
StatText : { fTextAngle: 0, fTextSize: 9, fTextAlign: 12, fTextColor: 1, fTextFont: 42 },
5051
StatFill : { fFillColor: 0, fFillStyle: 1001 },
5152
TimeOffset : 788918400000, // UTC time at 01/01/95
@@ -1820,8 +1821,8 @@
18201821
JSROOT.TFramePainter.prototype.Shrink = function(shrink_left, shrink_right) {
18211822
var ndc = this.svg_frame().property('NDC');
18221823
if (ndc) {
1823-
ndc.x1 += shrink_left;
1824-
ndc.x2 -= shrink_right;
1824+
ndc.fX1NDC += shrink_left;
1825+
ndc.fX2NDC -= shrink_right;
18251826
}
18261827
}
18271828

@@ -1830,14 +1831,14 @@
18301831
var w = width, h = height;
18311832

18321833
var ndc = this.svg_frame().empty() ? null : this.svg_frame().property('NDC');
1833-
if (ndc == null) ndc = { x1 : 0.07, y1 : 0.12, x2 : 0.95, y2 : 0.88 };
1834+
if (ndc == null) ndc = JSROOT.clone(JSROOT.gStyle.FrameNDC);
18341835

18351836
var root_pad = this.root_pad();
18361837

1837-
var lm = width * ndc.x1;
1838-
var rm = width * (1 - ndc.x2);
1839-
var tm = height * ndc.y1;
1840-
var bm = height * (1 - ndc.y2);
1838+
var lm = width * ndc.fX1NDC;
1839+
var rm = width * (1 - ndc.fX2NDC);
1840+
var tm = height * ndc.fY1NDC;
1841+
var bm = height * (1 - ndc.fY2NDC);
18411842

18421843
var framecolor = this.createAttFill('white'),
18431844
lineatt = JSROOT.Painter.createAttLine('black'),
@@ -1906,10 +1907,10 @@
19061907

19071908
// calculate actual NDC coordinates, use them to properly locate PALETTE
19081909
frame_g.property('NDC', {
1909-
x1 : lm / width,
1910-
x2 : (lm + w) / width,
1911-
y1 : tm / height,
1912-
y2 : (tm + h) / height
1910+
fX1NDC : lm / width,
1911+
fX2NDC : (lm + w) / width,
1912+
fY1NDC : tm / height,
1913+
fY2NDC : (tm + h) / height
19131914
});
19141915

19151916
// simple workaround to access painter via frame container
@@ -6142,10 +6143,10 @@
61426143

61436144
var ndc = this.svg_frame().property('NDC');
61446145

6145-
pal['fX1NDC'] = ndc.x2 - rel_width;
6146-
pal['fY1NDC'] = ndc.y1;
6147-
pal['fX2NDC'] = ndc.x2;
6148-
pal['fY2NDC'] = ndc.y2;
6146+
pal['fX1NDC'] = ndc.fX2NDC - rel_width;
6147+
pal['fY1NDC'] = ndc.fY1NDC;
6148+
pal['fX2NDC'] = ndc.fX2NDC;
6149+
pal['fY2NDC'] = ndc.fY2NDC;
61496150
pal['fInit'] = 1;
61506151
pal['fShadowColor'] = 1;
61516152
pal['fCorenerRadius'] = 0;

0 commit comments

Comments
 (0)