Skip to content

Commit c9fda09

Browse files
committed
Optimize TH1 error draw
Use less dummy move operations in the svg:path
1 parent 6fc4792 commit c9fda09

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

scripts/JSRoot.hist.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3844,7 +3844,7 @@ JSROOT.define(['d3', 'painter', 'gpad'], (d3, jsrp) => {
38443844
path_fill = null, path_err = null, path_marker = null, path_line = null,
38453845
hints_err = null, hints_marker = null,
38463846
do_marker = false, do_err = false,
3847-
endx = "", endy = "", dend = 0, my, yerr1, yerr2, bincont, binerr, mx1, mx2, midx, mmx1, mmx2,
3847+
dend = 0, dlw = 0, my, yerr1, yerr2, bincont, binerr, mx1, mx2, midx, mmx1, mmx2,
38483848
text_col, text_angle, text_size;
38493849

38503850
if (show_errors && !show_markers && (histo.fMarkerStyle > 1))
@@ -3860,6 +3860,10 @@ JSROOT.define(['d3', 'painter', 'gpad'], (d3, jsrp) => {
38603860
}
38613861

38623862
if (show_line) path_line = "";
3863+
3864+
dlw = this.lineatt.width + JSROOT.gStyle.fEndErrorSize;
3865+
if (this.options.ErrorKind === 1)
3866+
dend = Math.floor((this.lineatt.width-1)/2);
38633867

38643868
if (show_markers) {
38653869
// draw markers also when e2 option was specified
@@ -3907,13 +3911,6 @@ JSROOT.define(['d3', 'painter', 'gpad'], (d3, jsrp) => {
39073911
// instead define min and max value and made min-max drawing
39083912
let use_minmax = ((right-left) > 3*width);
39093913

3910-
if (this.options.ErrorKind === 1) {
3911-
let lw = this.lineatt.width + JSROOT.gStyle.fEndErrorSize;
3912-
endx = "m0," + lw + "v-" + 2*lw + "m0," + lw;
3913-
endy = "m" + lw + ",0h-" + 2*lw + "m" + lw + ",0";
3914-
dend = Math.floor((this.lineatt.width-1)/2);
3915-
}
3916-
39173914
if (draw_any_but_hist) use_minmax = true;
39183915

39193916
// just to get correct values for the specified bin
@@ -3939,11 +3936,17 @@ JSROOT.define(['d3', 'painter', 'gpad'], (d3, jsrp) => {
39393936
edx = Math.round((mx2-mx1)*this.options.errorX);
39403937
mmx1 = midx - edx;
39413938
mmx2 = midx + edx;
3942-
path_err += "M" + (mmx1+dend) +","+ my + endx + "h" + (mmx2-mmx1-2*dend) + endx;
3939+
if (this.options.ErrorKind === 1)
3940+
path_err += `M${mmx1+dend},${my-dlw}v${2*dlw}m0,-${dlw}h${mmx2-mmx1-2*dend}m0,-${dlw}v${2*dlw}`;
3941+
else
3942+
path_err += `M${mmx1+dend},${my}h${mmx2-mmx1-2*dend}`;
39433943
}
3944-
path_err += "M" + midx + "," + (my-yerr1+dend) + endy + "v" + (yerr1+yerr2-2*dend) + endy;
3944+
if (this.options.ErrorKind === 1)
3945+
path_err += `M${midx-dlw},${my-yerr1+dend}h${2*dlw}m${-dlw},0v${yerr1+yerr2-2*dend}m${-dlw},0h${2*dlw}`;
3946+
else
3947+
path_err += `M${midx},${my-yerr1+dend}v${yerr1+yerr2-2*dend}`;
39453948
if (hints_err !== null)
3946-
hints_err += "M" + (midx-edx) + "," + (my-yerr1) + "h" + (2*edx) + "v" + (yerr1+yerr2) + "h" + (-2*edx) + "z";
3949+
hints_err += `M${midx-edx},${my-yerr1}h${2*edx}v${yerr1+yerr2}h${-2*edx}z`;
39473950
};
39483951

39493952
let draw_bin = bin => {

0 commit comments

Comments
 (0)