Skip to content

Commit 84e54e4

Browse files
committed
replace rangebrekas.pattern (%w) with (week of day)
1 parent 9a75ef0 commit 84e54e4

File tree

7 files changed

+31
-31
lines changed

7 files changed

+31
-31
lines changed

src/plots/cartesian/layout_attributes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,19 @@ module.exports = {
279279
pattern: {
280280
valType: 'enumerated',
281281
// TODO could add '%H:%M:%S'
282-
values: ['%w', '%H', ''],
282+
values: ['day of week', '%H', ''],
283283
dflt: '',
284284
role: 'info',
285285
editType: 'calc',
286286
description: [
287287
'Determines a pattern on the time line that generates breaks.',
288-
'If *%w* - Sunday-based weekday as a decimal number [0, 6].',
288+
'If *day of week* - Sunday-based weekday as a decimal number [0, 6].',
289289
'If *%H* - hour (24-hour clock) as a decimal number [0, 23].',
290290
'These are the same directive as in `tickformat`, see',
291291
'https://github.com/d3/d3-time-format#locale_format',
292292
'for more info.',
293293
'Examples:',
294-
'- { pattern: \'%w\', bounds: [6, 0], operation: \'[]\' }',
294+
'- { pattern: \'day of week\', bounds: [6, 0], operation: \'[]\' }',
295295
' breaks from Saturday to Monday (i.e. skips the weekends).',
296296
'- { pattern: \'%H\', bounds: [17, 8] }',
297297
' breaks from 5pm to 8am (i.e. skips non-work hours).'

src/plots/cartesian/set_convert.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ module.exports = function setConvert(ax, fullLayout) {
625625
var doesCrossPeriod = false;
626626

627627
switch(brk.pattern) {
628-
case '%w':
628+
case 'day of week':
629629
bnds = Lib.simpleMap(brk.bounds, cleanNumber);
630630
b0 = bnds[0];
631631
b1 = bnds[1];
@@ -699,8 +699,8 @@ module.exports = function setConvert(ax, fullLayout) {
699699
if(!ax.rangebreaks) return rangebreaksOut;
700700

701701
var rangebreaksIn = ax.rangebreaks.slice().sort(function(a, b) {
702-
if(a.pattern === '%w' && b.pattern === '%H') return -1;
703-
else if(b.pattern === '%w' && a.pattern === '%H') return 1;
702+
if(a.pattern === 'day of week' && b.pattern === '%H') return -1;
703+
else if(b.pattern === 'day of week' && a.pattern === '%H') return 1;
704704
return 0;
705705
});
706706

@@ -756,7 +756,7 @@ module.exports = function setConvert(ax, fullLayout) {
756756
var t;
757757

758758
switch(brk.pattern) {
759-
case '%w':
759+
case 'day of week':
760760
b0 = bnds[0] + (op0 === '(' ? 1 : 0);
761761
b1 = bnds[1];
762762
r0Pattern = r0Date.getUTCDay();

test/image/mocks/axes_breaks-finance.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
"rangeslider": { "visible": true },
364364
"rangebreaks": [
365365
{
366-
"pattern": "%w",
366+
"pattern": "day of week",
367367
"bounds": [ 6, 0 ]
368368
},
369369
{
@@ -376,7 +376,7 @@
376376
"rangeslider": { "visible": true },
377377
"rangebreaks": [
378378
{
379-
"pattern": "%w",
379+
"pattern": "day of week",
380380
"bounds": [ 6, 0 ]
381381
},
382382
{

test/image/mocks/axes_breaks-rangeslider.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,7 @@
26542654
"tickfont": {"size": 8},
26552655
"rangebreaks": [
26562656
{
2657-
"pattern": "%w",
2657+
"pattern": "day of week",
26582658
"bounds": [6, 0],
26592659
"operation": "[]"
26602660
},

test/image/mocks/axes_breaks-weekends-weeknights.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"xaxis": {
1616
"rangebreaks": [
1717
{
18-
"pattern": "%w",
18+
"pattern": "day of week",
1919
"bounds": [ 6, 0 ],
2020
"operation": "[]"
2121
},

test/image/mocks/axes_breaks-weekends_autorange-reversed.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"xaxis": {
8989
"rangebreaks": [
9090
{
91-
"pattern": "%w",
91+
"pattern": "day of week",
9292
"bounds": [
9393
6,
9494
0
@@ -104,7 +104,7 @@
104104
"xaxis2": {
105105
"rangebreaks": [
106106
{
107-
"pattern": "%w",
107+
"pattern": "day of week",
108108
"bounds": [
109109
6,
110110
0
@@ -149,7 +149,7 @@
149149
"yaxis3": {
150150
"rangebreaks": [
151151
{
152-
"pattern": "%w",
152+
"pattern": "day of week",
153153
"bounds": [
154154
6,
155155
0
@@ -166,7 +166,7 @@
166166
"yaxis4": {
167167
"rangebreaks": [
168168
{
169-
"pattern": "%w",
169+
"pattern": "day of week",
170170
"bounds": [
171171
6,
172172
0

test/jasmine/tests/axes_test.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,14 +1125,14 @@ describe('Test axes', function() {
11251125
it('should only coerce rangebreaks *pattern* with *bounds*', function() {
11261126
layoutIn = {
11271127
xaxis: {type: 'date', rangebreaks: [{bounds: ['2020-01-04', '2020-01-05']}]},
1128-
xaxis2: {type: 'date', rangebreaks: [{bounds: [6, 0], pattern: '%w'}]},
1128+
xaxis2: {type: 'date', rangebreaks: [{bounds: [6, 0], pattern: 'day of week'}]},
11291129
xaxis3: {type: 'date', rangebreaks: [{values: ['2020-01-04', '2020-01-05'], pattern: 'NOP'}]},
11301130
};
11311131
layoutOut._subplots.xaxis.push('x2', 'x3');
11321132
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
11331133

11341134
expect(layoutOut.xaxis.rangebreaks[0].pattern).toBe('', 'coerced to dflt value');
1135-
expect(layoutOut.xaxis2.rangebreaks[0].pattern).toBe('%w', 'coerced');
1135+
expect(layoutOut.xaxis2.rangebreaks[0].pattern).toBe('day of week', 'coerced');
11361136
expect(layoutOut.xaxis3.rangebreaks[0].pattern).toBe(undefined, 'not coerce, using *values*');
11371137
});
11381138
});
@@ -4104,7 +4104,7 @@ describe('Test axes', function() {
41044104
_assert('with mixed operation values', [0, BADNUM, BADNUM, 90, 100, BADNUM, BADNUM, 200]);
41054105
});
41064106

4107-
it('should discard coords within break bounds - date %w case', function() {
4107+
it('should discard coords within break bounds - date day of week case', function() {
41084108
var x = [
41094109
// Thursday
41104110
'2020-01-02 08:00', '2020-01-02 16:00',
@@ -4132,7 +4132,7 @@ describe('Test axes', function() {
41324132
_calc({x: x}, {
41334133
xaxis: {
41344134
rangebreaks: [
4135-
{pattern: '%w', bounds: [6, 0], operation: '[]'}
4135+
{pattern: 'day of week', bounds: [6, 0], operation: '[]'}
41364136
]
41374137
}
41384138
});
@@ -4141,7 +4141,7 @@ describe('Test axes', function() {
41414141
_calc({x: x}, {
41424142
xaxis: {
41434143
rangebreaks: [
4144-
{pattern: '%w', bounds: [5, 1], operation: '()'}
4144+
{pattern: 'day of week', bounds: [5, 1], operation: '()'}
41454145
]
41464146
}
41474147
});
@@ -4150,7 +4150,7 @@ describe('Test axes', function() {
41504150
_calc({x: x}, {
41514151
xaxis: {
41524152
rangebreaks: [
4153-
{pattern: '%w', bounds: [6, 1], operation: '[)'}
4153+
{pattern: 'day of week', bounds: [6, 1], operation: '[)'}
41544154
]
41554155
}
41564156
});
@@ -4159,7 +4159,7 @@ describe('Test axes', function() {
41594159
_calc({x: x}, {
41604160
xaxis: {
41614161
rangebreaks: [
4162-
{pattern: '%w', bounds: [5, 0], operation: '(]'}
4162+
{pattern: 'day of week', bounds: [5, 0], operation: '(]'}
41634163
]
41644164
}
41654165
});
@@ -4611,7 +4611,7 @@ describe('Test axes', function() {
46114611
})
46124612
.then(function() {
46134613
gd.layout.xaxis.rangebreaks = [
4614-
{pattern: '%w', bounds: [5, 1], operation: '()'}
4614+
{pattern: 'day of week', bounds: [5, 1], operation: '()'}
46154615
];
46164616
return Plotly.react(gd, gd.data, gd.layout);
46174617
})
@@ -4626,7 +4626,7 @@ describe('Test axes', function() {
46264626
})
46274627
.then(function() {
46284628
gd.layout.xaxis.rangebreaks = [
4629-
{pattern: '%w', bounds: [6, 0], operation: '[]'}
4629+
{pattern: 'day of week', bounds: [6, 0], operation: '[]'}
46304630
];
46314631
return Plotly.react(gd, gd.data, gd.layout);
46324632
})
@@ -4641,7 +4641,7 @@ describe('Test axes', function() {
46414641
})
46424642
.then(function() {
46434643
gd.layout.xaxis.rangebreaks = [
4644-
{pattern: '%w', bounds: [4, 6], operation: '()'}
4644+
{pattern: 'day of week', bounds: [4, 6], operation: '()'}
46454645
];
46464646
return Plotly.react(gd, gd.data, gd.layout);
46474647
})
@@ -4656,7 +4656,7 @@ describe('Test axes', function() {
46564656
})
46574657
.then(function() {
46584658
gd.layout.xaxis.rangebreaks = [
4659-
{pattern: '%w', bounds: [5, 5], operation: '[]'}
4659+
{pattern: 'day of week', bounds: [5, 5], operation: '[]'}
46604660
];
46614661
return Plotly.react(gd, gd.data, gd.layout);
46624662
})
@@ -4671,7 +4671,7 @@ describe('Test axes', function() {
46714671
})
46724672
.then(function() {
46734673
gd.layout.xaxis.rangebreaks = [
4674-
{pattern: '%w', bounds: [5, 5], operation: '()'}
4674+
{pattern: 'day of week', bounds: [5, 5], operation: '()'}
46754675
];
46764676
return Plotly.react(gd, gd.data, gd.layout);
46774677
})
@@ -4705,7 +4705,7 @@ describe('Test axes', function() {
47054705
})
47064706
.then(function() {
47074707
gd.layout.xaxis.rangebreaks = [
4708-
{pattern: '%w', bounds: [5, 1], operation: '()'},
4708+
{pattern: 'day of week', bounds: [5, 1], operation: '()'},
47094709
{pattern: '%H', bounds: [17, 8], operation: '()'}
47104710
];
47114711
return Plotly.react(gd, gd.data, gd.layout);
@@ -4729,7 +4729,7 @@ describe('Test axes', function() {
47294729
.then(function() {
47304730
gd.layout.xaxis.rangebreaks = [
47314731
{pattern: '%H', bounds: [17, 8], operation: '()'},
4732-
{pattern: '%w', bounds: [5, 1], operation: '()'}
4732+
{pattern: 'day of week', bounds: [5, 1], operation: '()'}
47334733
];
47344734
return Plotly.react(gd, gd.data, gd.layout);
47354735
})
@@ -4772,15 +4772,15 @@ describe('Test axes', function() {
47724772
})
47734773
.then(function() {
47744774
gd.layout.xaxis.rangebreaks = [
4775-
{pattern: '%w', bounds: [1, 4], operation: '()'}
4775+
{pattern: 'day of week', bounds: [1, 4], operation: '()'}
47764776
];
47774777
// N.B. xaxis.range[0] falls within a break
47784778
gd.layout.xaxis.autorange = false;
47794779
gd.layout.xaxis.range = ['2020-01-01', '2020-01-09'];
47804780
return Plotly.react(gd, gd.data, gd.layout);
47814781
})
47824782
.then(function() {
4783-
_assert('when range[0] falls within a break pattern (%w case)', 'x', {
4783+
_assert('when range[0] falls within a break pattern (day of week case)', 'x', {
47844784
rangebreaks: [
47854785
['2020-01-01 00:00:00', '2020-01-02 00:00:00'].map(Lib.dateTime2ms),
47864786
['2020-01-07 00:00:00', '2020-01-09 00:00:00'].map(Lib.dateTime2ms)

0 commit comments

Comments
 (0)