Skip to content

Commit 355fb09

Browse files
committed
stop pushing tickmode back to axis in for a particular edge case
1 parent b8950c5 commit 355fb09

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/plots/cartesian/tick_value_defaults.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@ var ONEDAY = require('../../constants/numerical').ONEDAY;
1515

1616

1717
module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) {
18-
var tickmodeDefault = 'auto';
18+
var tickmode;
1919

2020
if(containerIn.tickmode === 'array' &&
2121
(axType === 'log' || axType === 'date')) {
22-
containerIn.tickmode = 'auto';
22+
tickmode = containerOut.tickmode = 'auto';
2323
}
24-
25-
if(Array.isArray(containerIn.tickvals)) tickmodeDefault = 'array';
26-
else if(containerIn.dtick) {
27-
tickmodeDefault = 'linear';
24+
else {
25+
var tickmodeDefault =
26+
Array.isArray(containerIn.tickvals) ? 'array' :
27+
containerIn.dtick ? 'linear' :
28+
'auto';
29+
tickmode = coerce('tickmode', tickmodeDefault);
2830
}
29-
var tickmode = coerce('tickmode', tickmodeDefault);
3031

3132
if(tickmode === 'auto') coerce('nticks');
3233
else if(tickmode === 'linear') {

test/jasmine/tests/axes_test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,26 +1073,32 @@ describe('Test axes', function() {
10731073
axOut = {};
10741074
mockSupplyDefaults(axIn, axOut, 'linear');
10751075
expect(axOut.tickmode).toBe('auto');
1076+
// and not push it back to axIn (which we used to do)
1077+
expect(axIn.tickmode).toBeUndefined();
10761078

10771079
axIn = {tickmode: 'array', tickvals: 'stuff'};
10781080
axOut = {};
10791081
mockSupplyDefaults(axIn, axOut, 'linear');
10801082
expect(axOut.tickmode).toBe('auto');
1083+
expect(axIn.tickmode).toBe('array');
10811084

10821085
axIn = {tickmode: 'array', tickvals: [1, 2, 3]};
10831086
axOut = {};
10841087
mockSupplyDefaults(axIn, axOut, 'date');
10851088
expect(axOut.tickmode).toBe('auto');
1089+
expect(axIn.tickmode).toBe('array');
10861090

10871091
axIn = {tickvals: [1, 2, 3]};
10881092
axOut = {};
10891093
mockSupplyDefaults(axIn, axOut, 'linear');
10901094
expect(axOut.tickmode).toBe('array');
1095+
expect(axIn.tickmode).toBeUndefined();
10911096

10921097
axIn = {dtick: 1};
10931098
axOut = {};
10941099
mockSupplyDefaults(axIn, axOut, 'linear');
10951100
expect(axOut.tickmode).toBe('linear');
1101+
expect(axIn.tickmode).toBeUndefined();
10961102
});
10971103

10981104
it('should set nticks iff tickmode=auto', function() {

0 commit comments

Comments
 (0)