Skip to content

Commit 5e4ad36

Browse files
committed
simplify pattern logic in set_convert
1 parent db38ce9 commit 5e4ad36

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/plots/cartesian/set_convert.js

+9-16
Original file line numberDiff line numberDiff line change
@@ -627,18 +627,19 @@ module.exports = function setConvert(ax, fullLayout) {
627627
if(brk.bounds) {
628628
var doesCrossPeriod = false;
629629

630+
bnds = Lib.simpleMap(brk.bounds, brk.pattern ?
631+
cleanNumber :
632+
ax.d2c // case of pattern: ''
633+
);
634+
b0 = Math.min(bnds[0], bnds[1]);
635+
b1 = Math.max(bnds[0], bnds[1]);
636+
630637
switch(brk.pattern) {
631638
case WEEKDAY_PATTERN:
632-
bnds = Lib.simpleMap(brk.bounds, cleanNumber);
633-
b0 = bnds[0];
634-
b1 = bnds[1];
635639
vb = (new Date(v)).getUTCDay();
636640
if(bnds[0] > bnds[1]) doesCrossPeriod = true;
637641
break;
638642
case HOUR_PATTERN:
639-
bnds = Lib.simpleMap(brk.bounds, cleanNumber);
640-
b0 = bnds[0];
641-
b1 = bnds[1];
642643
var vDate = new Date(v);
643644
vb = vDate.getUTCHours() + (
644645
vDate.getUTCMinutes() * ONEMIN +
@@ -650,23 +651,15 @@ module.exports = function setConvert(ax, fullLayout) {
650651
case '':
651652
// N.B. should work on date axes as well!
652653
// e.g. { bounds: ['2020-01-04', '2020-01-05 23:59'] }
653-
bnds = Lib.simpleMap(brk.bounds, ax.d2c);
654-
if(bnds[0] <= bnds[1]) {
655-
b0 = bnds[0];
656-
b1 = bnds[1];
657-
} else {
658-
b0 = bnds[1];
659-
b1 = bnds[0];
660-
}
661654
// TODO should work with reversed-range axes
662655
vb = v;
663656
break;
664657
}
665658

666659
if(doesCrossPeriod) {
667660
if(
668-
(op0 === '(' ? vb > b0 : vb >= b0) ||
669-
(op1 === ')' ? vb < b1 : vb <= b1)
661+
(op0 === '(' ? vb > b1 : vb >= b1) ||
662+
(op1 === ')' ? vb < b0 : vb <= b0)
670663
) return BADNUM;
671664
} else {
672665
if(

0 commit comments

Comments
 (0)