Skip to content

Commit

Permalink
replace rangebrekas.pattern (time of day) with (hour)
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Mar 17, 2020
1 parent 0bf5ceb commit d82db2e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,21 +279,21 @@ module.exports = {
pattern: {
valType: 'enumerated',
// TODO could add '%H:%M:%S'
values: ['day of week', 'time of day', ''],
values: ['day of week', 'hour', ''],
dflt: '',
role: 'info',
editType: 'calc',
description: [
'Determines a pattern on the time line that generates breaks.',
'If *day of week* - Sunday-based weekday as a decimal number [0, 6].',
'If *time of day* - hour (24-hour clock) as a decimal number [0, 23].',
'*day of week* and *time of day* are similar to *%w* and *%H* directives',
'If *hour* - hour (24-hour clock) as a decimal number [0, 23].',
'*day of week* and *hour* are similar to *%w* and *%H* directives',
'applied in `tickformat`, see https://github.com/d3/d3-time-format#locale_format',
'for more info.',
'Examples:',
'- { pattern: \'day of week\', bounds: [6, 0] }',
' breaks from Saturday to Monday (i.e. skips the weekends).',
'- { pattern: \'time of day\', bounds: [16, 8] }',
'- { pattern: \'hour\', bounds: [16, 8] }',
' breaks from 4pm to 8am (i.e. skips non-work hours).'
].join(' ')
},
Expand Down
8 changes: 4 additions & 4 deletions src/plots/cartesian/set_convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ module.exports = function setConvert(ax, fullLayout) {
vb = (new Date(v)).getUTCDay();
if(bnds[0] > bnds[1]) doesCrossPeriod = true;
break;
case 'time of day':
case 'hour':
bnds = Lib.simpleMap(brk.bounds, cleanNumber);
b0 = bnds[0];
b1 = bnds[1];
Expand Down Expand Up @@ -699,8 +699,8 @@ module.exports = function setConvert(ax, fullLayout) {
if(!ax.rangebreaks) return rangebreaksOut;

var rangebreaksIn = ax.rangebreaks.slice().sort(function(a, b) {
if(a.pattern === 'day of week' && b.pattern === 'time of day') return -1;
else if(b.pattern === 'day of week' && a.pattern === 'time of day') return 1;
if(a.pattern === 'day of week' && b.pattern === 'hour') return -1;
else if(b.pattern === 'day of week' && a.pattern === 'hour') return 1;
return 0;
});

Expand Down Expand Up @@ -771,7 +771,7 @@ module.exports = function setConvert(ax, fullLayout) {
r0Date.getUTCSeconds() * ONESEC -
r0Date.getUTCMilliseconds();
break;
case 'time of day':
case 'hour':
b0 = bnds[0];
b1 = bnds[1];
r0Pattern = r0Date.getUTCHours();
Expand Down
8 changes: 4 additions & 4 deletions test/image/mocks/axes_breaks-night_autorange-reversed.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"xaxis": {
"rangebreaks": [
{
"pattern": "time of day",
"pattern": "hour",
"bounds": [
18,
6
Expand All @@ -208,7 +208,7 @@
"xaxis2": {
"rangebreaks": [
{
"pattern": "time of day",
"pattern": "hour",
"bounds": [
18,
6
Expand Down Expand Up @@ -253,7 +253,7 @@
"yaxis3": {
"rangebreaks": [
{
"pattern": "time of day",
"pattern": "hour",
"bounds": [
18,
6
Expand All @@ -270,7 +270,7 @@
"yaxis4": {
"rangebreaks": [
{
"pattern": "time of day",
"pattern": "hour",
"bounds": [
18,
6
Expand Down
6 changes: 3 additions & 3 deletions test/image/mocks/axes_breaks-rangeslider.json
Original file line number Diff line number Diff line change
Expand Up @@ -2659,17 +2659,17 @@
"operation": "[]"
},
{
"pattern": "time of day",
"pattern": "hour",
"bounds": [0, 9],
"operation": "()"
},
{
"pattern": "time of day",
"pattern": "hour",
"bounds": [12, 13],
"operation": "()"
},
{
"pattern": "time of day",
"pattern": "hour",
"bounds": [15, 21],
"operation": "()"
}
Expand Down
2 changes: 1 addition & 1 deletion test/image/mocks/axes_breaks-weekends-weeknights.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"operation": "[]"
},
{
"pattern": "time of day",
"pattern": "hour",
"bounds": [ 16, 8 ],
"operation": "()"
}
Expand Down
20 changes: 10 additions & 10 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4166,7 +4166,7 @@ describe('Test axes', function() {
_assert('(5,0]', noWeekend);
});

it('should discard coords within break bounds - date time of day case', function() {
it('should discard coords within break bounds - date hour case', function() {
_calc({
x: [
'2020-01-02 08:00', '2020-01-02 20:00',
Expand All @@ -4179,7 +4179,7 @@ describe('Test axes', function() {
}, {
xaxis: {
rangebreaks: [
{pattern: 'time of day', bounds: [17, 8], operation: '()'}
{pattern: 'hour', bounds: [17, 8], operation: '()'}
]
}
});
Expand All @@ -4193,7 +4193,7 @@ describe('Test axes', function() {
]);
});

it('should discard coords within break bounds - date time of day / high precision case', function() {
it('should discard coords within break bounds - date hour / high precision case', function() {
_calc({
x: [
'2020-01-03 17:00',
Expand All @@ -4207,7 +4207,7 @@ describe('Test axes', function() {
}, {
xaxis: {
rangebreaks: [
{pattern: 'time of day', bounds: [17, 8], operation: '()'}
{pattern: 'hour', bounds: [17, 8], operation: '()'}
]
}
});
Expand Down Expand Up @@ -4680,7 +4680,7 @@ describe('Test axes', function() {
})
.then(function() {
gd.layout.xaxis.rangebreaks = [
{pattern: 'time of day', bounds: [17, 8], operation: '()'}
{pattern: 'hour', bounds: [17, 8], operation: '()'}
];
return Plotly.react(gd, gd.data, gd.layout);
})
Expand All @@ -4706,7 +4706,7 @@ describe('Test axes', function() {
.then(function() {
gd.layout.xaxis.rangebreaks = [
{pattern: 'day of week', bounds: [5, 1], operation: '()'},
{pattern: 'time of day', bounds: [17, 8], operation: '()'}
{pattern: 'hour', bounds: [17, 8], operation: '()'}
];
return Plotly.react(gd, gd.data, gd.layout);
})
Expand All @@ -4728,7 +4728,7 @@ describe('Test axes', function() {
})
.then(function() {
gd.layout.xaxis.rangebreaks = [
{pattern: 'time of day', bounds: [17, 8], operation: '()'},
{pattern: 'hour', bounds: [17, 8], operation: '()'},
{pattern: 'day of week', bounds: [5, 1], operation: '()'}
];
return Plotly.react(gd, gd.data, gd.layout);
Expand All @@ -4751,15 +4751,15 @@ describe('Test axes', function() {
})
.then(function() {
gd.layout.xaxis.rangebreaks = [
{pattern: 'time of day', bounds: [17, 8], operation: '()'}
{pattern: 'hour', bounds: [17, 8], operation: '()'}
];
// N.B. xaxis.range[0] falls within a break
gd.layout.xaxis.autorange = false;
gd.layout.xaxis.range = ['2020-01-01 20:00:00', '2020-01-04 20:00:00'];
return Plotly.react(gd, gd.data, gd.layout);
})
.then(function() {
_assert('when range[0] falls within a break pattern (time of day case)', 'x', {
_assert('when range[0] falls within a break pattern (hour case)', 'x', {
rangebreaks: [
[1577908800000, Lib.dateTime2ms('2020-01-02 08:00:00')],
['2020-01-02 17:00:00', '2020-01-03 08:00:00'].map(Lib.dateTime2ms),
Expand Down Expand Up @@ -4917,7 +4917,7 @@ describe('Test axes', function() {
]
}], {
xaxis: {
rangebreaks: [{pattern: 'time of day', bounds: [17, 8]}]
rangebreaks: [{pattern: 'hour', bounds: [17, 8]}]
}
})
.then(function() {
Expand Down

0 comments on commit d82db2e

Please sign in to comment.