Skip to content

Commit b800a65

Browse files
committed
add early returns - array of arrays is not relevant to date, category & linear functions
1 parent d218bab commit b800a65

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/plots/cartesian/axis_autotype.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ 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 '-';
1819
if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory';
20+
21+
if(Lib.isArrayOrTypedArray(array[0])) return '-';
1922
if(moreDates(array, calendar)) return 'date';
2023

2124
var convertNumeric = opts.autotypenumbers !== 'strict'; // compare against strict, just in case autotypenumbers was not provided in opts
@@ -49,7 +52,6 @@ function linearOK(a, convertNumeric) {
4952
// as with categories, consider DISTINCT values only.
5053
function moreDates(a, calendar) {
5154
var len = a.length;
52-
if(!len) return false;
5355

5456
var inc = getIncrement(len);
5557
var dats = 0;
@@ -79,7 +81,6 @@ function getIncrement(len) {
7981
// require twice as many DISTINCT categories as distinct numbers
8082
function category(a, convertNumeric) {
8183
var len = a.length;
82-
if(!len) return false;
8384

8485
var inc = getIncrement(len);
8586
var nums = 0;

0 commit comments

Comments
 (0)