Skip to content

Commit 21a573c

Browse files
committed
Refactor periodCompatibleWithTickformat to make behavior clearer.
1 parent 6fcda1a commit 21a573c

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

src/plots/cartesian/axes.js

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4584,28 +4584,18 @@ function setShiftVal(ax, axShifts) {
45844584
* @returns {boolean}
45854585
*/
45864586
function periodCompatibleWithTickformat(period, tickformat) {
4587-
if(/%f/.test(tickformat)) {
4588-
if(period < ONEMICROSEC) return false;
4589-
} else if(/%L/.test(tickformat)) {
4590-
if(period < 1) return false;
4591-
} else if(/%[SX]/.test(tickformat)) {
4592-
if(period < ONESEC) return false;
4593-
} else if(/%M/.test(tickformat)) {
4594-
if(period < ONEMIN) return false;
4595-
} else if(/%[HI]/.test(tickformat)) {
4596-
if(period < ONEHOUR) return false;
4597-
} else if(/%p/.test(tickformat)) {
4598-
if(period < HALFDAY) return false;
4599-
} else if(/%[Aadejuwx]/.test(tickformat)) {
4600-
if(period < ONEDAY) return false;
4601-
} else if(/%[UVW]/.test(tickformat)) {
4602-
if(period < ONEWEEK) return false;
4603-
} else if(/%[Bbm]/.test(tickformat)) {
4604-
if(period < ONEMINMONTH) return false;
4605-
} else if(/%[q]/.test(tickformat)) {
4606-
if(period < ONEMINQUARTER) return false;
4607-
} else if(/%[Yy]/.test(tickformat)) {
4608-
if(period < ONEMINYEAR) return false;
4609-
}
4610-
return true;
4587+
return (
4588+
/%f/.test(tickformat) ? period >= ONEMICROSEC :
4589+
/%L/.test(tickformat) ? period >= 1 :
4590+
/%[SX]/.test(tickformat) ? period >= ONESEC :
4591+
/%M/.test(tickformat) ? period >= ONEMIN :
4592+
/%[HI]/.test(tickformat) ? period >= ONEHOUR :
4593+
/%p/.test(tickformat) ? period >= HALFDAY :
4594+
/%[Aadejuwx]/.test(tickformat) ? period >= ONEDAY :
4595+
/%[UVW]/.test(tickformat) ? period >= ONEWEEK :
4596+
/%[Bbm]/.test(tickformat) ? period >= ONEMINMONTH :
4597+
/%[q]/.test(tickformat) ? period >= ONEMINQUARTER :
4598+
/%[Yy]/.test(tickformat) ? period >= ONEMINYEAR :
4599+
true
4600+
);
46114601
}

0 commit comments

Comments
 (0)