Skip to content

Commit 37d52fe

Browse files
committed
fix handling of default tick0 with dtick for date axes
1 parent 2e9dbad commit 37d52fe

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/plots/cartesian/layout_attributes.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ module.exports = {
138138
},
139139
tick0: {
140140
valType: 'any',
141-
dflt: 0,
142141
role: 'style',
143142
description: [
144143
'Sets the placement of the first tick on this axis.',

src/plots/cartesian/tick_value_defaults.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe
6060

6161
// tick0 can have different valType for different axis types, so
6262
// validate that now. Also for dates, change milliseconds to date strings
63-
var tick0 = coerce('tick0');
63+
var tick0Dflt = (axType === 'date') ? '2000-01-01' : 0;
64+
var tick0 = coerce('tick0', tick0Dflt);
6465
if(axType === 'date') {
65-
containerOut.tick0 = Lib.cleanDate(tick0, '2000-01-01');
66+
containerOut.tick0 = Lib.cleanDate(tick0, tick0Dflt);
6667
}
6768
// Aside from date axes, dtick must be numeric; D1 and D2 modes ignore tick0 entirely
6869
else if(isNumeric(tick0) && dtick !== 'D1' && dtick !== 'D2') {
6970
containerOut.tick0 = Number(tick0);
7071
}
7172
else {
72-
containerOut.tick0 = 0;
73+
containerOut.tick0 = tick0Dflt;
7374
}
7475
}
7576
else {

test/jasmine/tests/axes_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,13 @@ describe('Test axes', function() {
693693
expect(axOut.tick0).toBe(someDate);
694694
expect(axOut.dtick).toBe('M15');
695695

696+
// dtick without tick0: get the right default
697+
axIn = {dtick: 'M12'};
698+
axOut = {};
699+
mockSupplyDefaults(axIn, axOut, 'date');
700+
expect(axOut.tick0).toBe('2000-01-01');
701+
expect(axOut.dtick).toBe('M12');
702+
696703
// now some stuff that shouldn't work, should give defaults
697704
[
698705
['next thursday', -1],

0 commit comments

Comments
 (0)