Skip to content

Commit dcceb76

Browse files
committed
fix %H maskBreaks for values greater but on the same hour
... as the lower break bound
1 parent 7080f90 commit dcceb76

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/plots/cartesian/set_convert.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,12 @@ module.exports = function setConvert(ax, fullLayout) {
645645
bnds = Lib.simpleMap(brk.bounds, cleanNumber);
646646
b0 = bnds[0];
647647
b1 = bnds[1];
648-
vb = (new Date(v)).getUTCHours();
648+
var vDate = new Date(v);
649+
vb = vDate.getUTCHours() + (
650+
vDate.getUTCMinutes() * ONEMIN +
651+
vDate.getUTCSeconds() * ONESEC +
652+
vDate.getUTCMilliseconds()
653+
) / ONEDAY;
649654
if(bnds[0] > bnds[1]) doesCrossPeriod = true;
650655
break;
651656
case '':

test/jasmine/tests/axes_test.js

+29
Original file line numberDiff line numberDiff line change
@@ -4195,6 +4195,35 @@ describe('Test axes', function() {
41954195
]);
41964196
});
41974197

4198+
it('should discard coords within break bounds - date %H / high precision case', function() {
4199+
_calc({
4200+
x: [
4201+
'2020-01-03 17:00',
4202+
'2020-01-03 17:15',
4203+
'2020-01-03 17:30',
4204+
'2020-01-06 7:45',
4205+
'2020-01-06 8:00',
4206+
'2020-01-06 8:15',
4207+
'2020-01-06 8:30'
4208+
]
4209+
}, {
4210+
xaxis: {
4211+
breaks: [
4212+
{pattern: '%H', bounds: [17, 8]}
4213+
]
4214+
}
4215+
});
4216+
_assert('with dflt operation', [
4217+
Lib.dateTime2ms('2020-01-03 17:00'),
4218+
BADNUM,
4219+
BADNUM,
4220+
BADNUM,
4221+
Lib.dateTime2ms('2020-01-06 8:00'),
4222+
Lib.dateTime2ms('2020-01-06 8:15'),
4223+
Lib.dateTime2ms('2020-01-06 8:30')
4224+
]);
4225+
});
4226+
41984227
it('should discard coords within [values[i], values[i] + dvalue] bounds', function() {
41994228
var x = [
42004229
// Thursday

0 commit comments

Comments
 (0)