Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c680558

Browse files
committed
don't coerce ticktext/tickvals on multicategory axes
1 parent d986f94 commit c680558

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/plots/cartesian/tick_value_defaults.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var cleanTicks = require('./clean_ticks');
1312

14-
1513
module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) {
1614
var tickmode;
1715

1816
if(containerIn.tickmode === 'array' &&
1917
(axType === 'log' || axType === 'date')) {
2018
tickmode = containerOut.tickmode = 'auto';
21-
}
22-
else {
23-
var tickmodeDefault =
24-
Array.isArray(containerIn.tickvals) ? 'array' :
19+
} else {
20+
var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' :
2521
containerIn.dtick ? 'linear' :
2622
'auto';
2723
tickmode = coerce('tickmode', tickmodeDefault);
@@ -36,8 +32,7 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe
3632
containerIn.dtick, axType);
3733
containerOut.tick0 = cleanTicks.tick0(
3834
containerIn.tick0, axType, containerOut.calendar, dtick);
39-
}
40-
else {
35+
} else if(axType !== 'multicategory') {
4136
var tickvals = coerce('tickvals');
4237
if(tickvals === undefined) containerOut.tickmode = 'auto';
4338
else coerce('ticktext');

test/jasmine/tests/axes_test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,14 @@ describe('Test axes', function() {
13471347
expect(axOut.tickvals).toEqual([2, 4, 6, 8]);
13481348
expect(axOut.ticktext).toEqual(['who', 'do', 'we', 'appreciate']);
13491349
});
1350+
1351+
it('should not coerce ticktext/tickvals on multicategory axes', function() {
1352+
var axIn = {tickvals: [1, 2, 3], ticktext: ['4', '5', '6']};
1353+
var axOut = {};
1354+
mockSupplyDefaults(axIn, axOut, 'multicategory');
1355+
expect(axOut.tickvals).toBe(undefined);
1356+
expect(axOut.ticktext).toBe(undefined);
1357+
});
13501358
});
13511359

13521360
describe('saveRangeInitial', function() {

0 commit comments

Comments
 (0)