Skip to content

Commit 9a71ba3

Browse files
committed
set limit of 100 for num2frac denominator
- for `thetaunit: 'radians'` angular axes, labels with den >= 100 are displayed in radians (instead of fractions of PI)
1 parent 5357501 commit 9a71ba3

File tree

3 files changed

+511
-30
lines changed

3 files changed

+511
-30
lines changed

src/plots/cartesian/axes.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,28 +1426,33 @@ function formatLinear(ax, out, hover, extraPrecision, hideexp) {
14261426

14271427
function formatAngle(ax, out, hover, extraPrecision, hideexp) {
14281428
if(ax.thetaunit === 'radians' && !hover) {
1429-
var isNeg = out.x < 0;
14301429
var num = out.x / 180;
14311430

14321431
if(num === 0) {
14331432
out.text = '0';
14341433
} else {
14351434
var frac = num2frac(num);
14361435

1437-
if(frac[1] === 1) {
1438-
if(frac[0] === 1) out.text = 'π';
1439-
else out.text = frac[0] + 'π';
1436+
if(frac[1] >= 100) {
1437+
out.text = numFormat(Lib.deg2rad(out.x), ax, hideexp, extraPrecision);
14401438
} else {
1441-
out.text = [
1442-
'<sup>', frac[0], '</sup>',
1443-
'⁄',
1444-
'<sub>', frac[1], '</sub>',
1445-
'π'
1446-
].join('');
1439+
var isNeg = out.x < 0;
1440+
1441+
if(frac[1] === 1) {
1442+
if(frac[0] === 1) out.text = 'π';
1443+
else out.text = frac[0] + 'π';
1444+
} else {
1445+
out.text = [
1446+
'<sup>', frac[0], '</sup>',
1447+
'⁄',
1448+
'<sub>', frac[1], '</sub>',
1449+
'π'
1450+
].join('');
1451+
}
1452+
1453+
if(isNeg) out.text = MINUS_SIGN + out.text;
14471454
}
14481455
}
1449-
1450-
if(isNeg) out.text = MINUS_SIGN + out.text;
14511456
} else {
14521457
out.text = numFormat(out.x, ax, hideexp, extraPrecision);
14531458
}

test/image/baselines/polar_ticks.png

6.57 KB
Loading

0 commit comments

Comments
 (0)