Skip to content

Commit 72f6de8

Browse files
committed
reuse Lib.dateTick0
1 parent 083eae3 commit 72f6de8

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/traces/scatter/attributes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ function axisPeriod0(axis) {
4343
'Only relevant when the axis `type` is *date*.',
4444
'Sets the base for period positioning in milliseconds or date string on the ' + axis + ' axis.',
4545
'When `' + axis + 'period` is round number of weeks,',
46-
'the `' + axis + 'period0` by default would be on a Sunday i.e. 1970-01-04,',
47-
'otherwise it would be at 1970-01-01.'
46+
'the `' + axis + 'period0` by default would be on a Sunday i.e. 2000-01-02,',
47+
'otherwise it would be at 2000-01-01.'
4848
].join(' ')
4949
};
5050
}

src/traces/scatter/period_defaults.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88

99
'use strict';
1010

11+
var dateTick0 = require('../../lib').dateTick0;
1112
var numConstants = require('../../constants/numerical');
1213
var ONEWEEK = numConstants.ONEWEEK;
1314

14-
function getPeriod0Dflt(period) {
15+
function getPeriod0Dflt(period, calendar) {
1516
var n = period / ONEWEEK;
16-
17-
return Math.round(n) === n ?
18-
'1970-01-04' : // a Sunday
19-
'1970-01-01';
17+
return dateTick0(calendar, Math.round(n) === n);
2018
}
2119

2220
module.exports = function handlePeriodDefaults(traceIn, traceOut, layout, coerce, opts) {
@@ -30,15 +28,15 @@ module.exports = function handlePeriodDefaults(traceIn, traceOut, layout, coerce
3028
if(opts.x) {
3129
var xperiod = coerce('xperiod');
3230
if(xperiod) {
33-
coerce('xperiod0', getPeriod0Dflt(xperiod));
31+
coerce('xperiod0', getPeriod0Dflt(xperiod, traceOut.xcalendar));
3432
coerce('xperiodalignment');
3533
}
3634
}
3735

3836
if(opts.y) {
3937
var yperiod = coerce('yperiod');
4038
if(yperiod) {
41-
coerce('yperiod0', getPeriod0Dflt(yperiod));
39+
coerce('yperiod0', getPeriod0Dflt(yperiod, traceOut.ycalendar));
4240
coerce('yperiodalignment');
4341
}
4442
}

0 commit comments

Comments
 (0)