Skip to content

Commit 2d2e627

Browse files
committed
refactor rangebreak handle pattern
1 parent 5e4ad36 commit 2d2e627

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/plots/cartesian/set_convert.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ module.exports = function setConvert(ax, fullLayout) {
614614

615615
ax.maskBreaks = function(v) {
616616
var rangebreaksIn = ax.rangebreaks || [];
617-
var bnds, b0, b1, vb;
617+
var bnds, b0, b1, vb, vDate;
618618

619619
for(var i = 0; i < rangebreaksIn.length; i++) {
620620
var brk = rangebreaksIn[i];
@@ -625,28 +625,27 @@ module.exports = function setConvert(ax, fullLayout) {
625625
var op1 = op.charAt(1);
626626

627627
if(brk.bounds) {
628-
var doesCrossPeriod = false;
629-
630-
bnds = Lib.simpleMap(brk.bounds, brk.pattern ?
628+
var pattern = brk.pattern;
629+
bnds = Lib.simpleMap(brk.bounds, pattern ?
631630
cleanNumber :
632631
ax.d2c // case of pattern: ''
633632
);
634633
b0 = Math.min(bnds[0], bnds[1]);
635634
b1 = Math.max(bnds[0], bnds[1]);
635+
var doesCrossPeriod = !!(pattern && bnds[0] > bnds[1]);
636636

637-
switch(brk.pattern) {
637+
switch(pattern) {
638638
case WEEKDAY_PATTERN:
639-
vb = (new Date(v)).getUTCDay();
640-
if(bnds[0] > bnds[1]) doesCrossPeriod = true;
639+
vDate = new Date(v);
640+
vb = vDate.getUTCDay();
641641
break;
642642
case HOUR_PATTERN:
643-
var vDate = new Date(v);
643+
vDate = new Date(v);
644644
vb = vDate.getUTCHours() + (
645645
vDate.getUTCMinutes() * ONEMIN +
646646
vDate.getUTCSeconds() * ONESEC +
647647
vDate.getUTCMilliseconds()
648648
) / ONEDAY;
649-
if(bnds[0] > bnds[1]) doesCrossPeriod = true;
650649
break;
651650
case '':
652651
// N.B. should work on date axes as well!

0 commit comments

Comments
 (0)