Skip to content

Commit 79c8d18

Browse files
committed
Set pad ranges for any kind of log scale
1 parent 02c8044 commit 79c8d18

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

modules/gpad/TPadPainter.mjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,23 +1684,23 @@ class TPadPainter extends ObjectPainter {
16841684
if (!r.ranges || p.empty()) return true;
16851685

16861686
// calculate user range for full pad
1687-
const log10 = (x,e) => (x<=0) ? e : Math.log10(x),
1688-
log2 = (x,e) => (x<=0) ? e : Math.log10(x)/Math.log10(2),
1689-
funcs = [ x => x, log10, log2 ],
1690-
frect = main.getFrameRect();
1687+
const func = (log, value, err) => {
1688+
if (!log) return value;
1689+
if (value <= 0) return err;
1690+
value = Math.log10(value);
1691+
if (log > 1) value = value/Math.log10(log);
1692+
return value;
1693+
}, frect = main.getFrameRect();
16911694

1692-
let func = funcs[main.logx] || log10;
1693-
r.ux1 = func(r.ux1, 0);
1694-
r.ux2 = func(r.ux2, 1);
1695+
r.ux1 = func(main.logx, r.ux1, 0);
1696+
r.ux2 = func(main.logx, r.ux2, 1);
16951697

16961698
let k = (r.ux1 - r.ux2)/frect.width;
16971699
r.px1 = r.ux1 - k*frect.x;
16981700
r.px2 = r.px1 + k*this.getPadWidth();
16991701

1700-
func = funcs[main.logy] || log10;
1701-
1702-
r.uy1 = func(r.uy1, 0);
1703-
r.uy2 = func(r.uy2, 1);
1702+
r.uy1 = func(main.logy, r.uy1, 0);
1703+
r.uy2 = func(main.logy, r.uy2, 1);
17041704

17051705
k = (r.uy2 - r.uy1)/frect.height;
17061706
r.py1 = r.uy1 - k*frect.y;

0 commit comments

Comments
 (0)