8000 flat input array before passing to autoType functions · lzhice/plotly.js@f6d8c39 · GitHub
[go: up one dir, main page]

Skip to content

Commit f6d8c39

Browse files
committed
flat input array before passing to autoType functions
1 parent b800a65 commit f6d8c39

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/plots/cartesian/axis_autotype.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ var Lib = require('../../lib');
1515
var BADNUM = require('../../constants/numerical').BADNUM;
1616

1717
module.exports = function autoType(array, calendar, opts) {
18-
if(Lib.isArrayOrTypedArray(array) && !array.length) return '-';
19-
if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory';
18+
var a = array;
2019

21-
if(Lib.isArrayOrTypedArray(array[0])) return '-';
22-
if(moreDates(array, calendar)) return 'date';
20+
if(Lib.isArrayOrTypedArray(a) && !a.length) return '-';
21+
if(!opts.noMultiCategory && multiCategory(a)) return 'multicategory';
22+
if(opts.noMultiCategory && Lib.isArrayOrTypedArray(a[0])) {
23+
a = a.flat(); // TODO: add support for IE
24+
}
25+
26+
if(moreDates(a, calendar)) return 'date';
2327

2428
var convertNumeric = opts.autotypenumbers !== 'strict'; // compare against strict, just in case autotypenumbers was not provided in opts
25-
if(category(array, convertNumeric)) return 'category';
26-
if(linearOK(array, convertNumeric)) return 'linear';
29+
if(category(a, convertNumeric)) return 'category';
30+
if(linearOK(a, convertNumeric)) return 'linear';
2731

2832
return '-';
2933
};

test/jasmine/tests/axes_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ describe('Test axes', function() {
332332
['d', 'e', 'f']
333333
]
334334
});
335-
checkTypes('linear', 'linear');
335+
checkTypes('linear', 'category');
336336
});
337337
});
338338

0 commit comments

Comments
 (0)
0