Skip to content

Commit 043ac1b

Browse files
committed
plotly#189 PR feedback and linting
1 parent 0314f37 commit 043ac1b

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/plots/cartesian/category_mode_defaults.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

11+
var layoutAttributes = require('./layout_attributes');
12+
1213
module.exports = function handleCategoryModeDefaults(containerIn, containerOut, coerce) {
1314

14-
if(containerIn.type === 'category') {
15+
if(containerIn.type !== 'category') return;
1516

16-
var validCategories = ['trace', 'category ascending', 'category descending', 'array'];
17+
var validCategories = layoutAttributes.categorymode.values;
1718

18-
var properCategoryList = Array.isArray(containerIn.categorylist) && containerIn.categorylist.length > 0;
19+
var properCategoryList = Array.isArray(containerIn.categorylist) && containerIn.categorylist.length > 0;
1920

20-
if(validCategories.indexOf(containerIn.categorymode) === -1 && properCategoryList) {
21+
if(validCategories.indexOf(containerIn.categorymode) === -1 && properCategoryList) {
2122

22-
// when unspecified or invalid, use the default, unless categorylist implies 'array'
23-
coerce('categorymode', 'array'); // promote to 'array'
23+
// when unspecified or invalid, use the default, unless categorylist implies 'array'
24+
coerce('categorymode', 'array'); // promote to 'array'
2425

25-
} else if(containerIn.categorymode === 'array' && !properCategoryList) {
26+
} else if(containerIn.categorymode === 'array' && !properCategoryList) {
2627

27-
// when mode is 'array' but no list is given, revert to default
28+
// when mode is 'array' but no list is given, revert to default
2829

29-
containerIn.categorymode = 'trace'; // revert to default
30-
coerce('categorymode');
30+
containerIn.categorymode = 'trace'; // revert to default
31+
coerce('categorymode');
3132

32-
} else {
33+
} else {
3334

34-
// otherwise use the supplied mode, or the default one if unsupplied or invalid
35-
coerce('categorymode');
35+
// otherwise use the supplied mode, or the default one if unsupplied or invalid
36+
coerce('categorymode');
3637

37-
}
3838
}
3939
};

test/jasmine/tests/axes_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ describe('Test axes', function() {
364364
});
365365
expect(gd._fullLayout.xaxis.categorymode).toBe('array');
366366
});
367-
367+
368368
it('should switch categorymode on "array" if it is not supplied but categorylist is supplied', function() {
369369
PlotlyInternal.plot(gd, [{x: ['c','a','e','b','d'], y: [15,11,12,13,14]}], {
370370
xaxis: {type: 'category', categorylist: ['b','a','d','e','c']}

0 commit comments

Comments
 (0)