src/data/helper/sourceHelper.js
function doGuessOrdinal(
    data, sourceFormat, seriesLayoutBy, dimensionsDefine, startIndex, dimIndex
) {
    var result;
    // Experience value.
    var maxLoop = 5;

    if (isTypedArray(data)) {
        return false;
    }

    // When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
    // always exists in source.
    var dimName;
    if (dimensionsDefine) {
        dimName = dimensionsDefine[dimIndex];
        dimName = isObject(dimName) ? dimName.name : dimName;
    }

    if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
        if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
            var sample = data[dimIndex];
            for (var i = 0; i < (sample || []).length && i < maxLoop; i++) {
                if ((result = detectValue(sample[startIndex + i])) != null) {
                    return result;
                }
            }
        }
        else {
            for (var i = 0; i < data.length && i < maxLoop; i++) {
                var row = data[startIndex + i];
                if (row && (result = detectValue(row[dimIndex])) != null) {
                    return result;
                }
            }
        }
    }
    else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
        if (!dimName) {
            return;
        }
        for (var i = 0; i < data.length && i < maxLoop; i++) {
            var item = data[i];
            if (item && (result = detectValue(item[dimName])) != null) {
                return result;
            }
        }
    }
    else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
        if (!dimName) {
            return;
        }
        var sample = data[dimName];
        if (!sample || isTypedArray(sample)) {
            return false;
        }
        for (var i = 0; i < sample.length && i < maxLoop; i++) {
            if ((result = detectValue(sample[i])) != null) {
                return result;
            }
        }
    }
    else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
        for (var i = 0; i < data.length && i < maxLoop; i++) {
            var item = data[i];
            var val = getDataItemValue(item);
            if (!isArray(val)) {
                return false;
            }
            if ((result = detectValue(val[dimIndex])) != null) {
                return result;
            }
        }
    }

    function detectValue(val) {
        // Consider usage convenience, '1', '2' will be treated as "number".
        // `isFinit('')` get `true`.
        if (val != null && isFinite(val) && val !== '') {
            return false;
        }
        else if (isString(val) && val !== '-') {
            return true;
        }
    }

    return false;
}
function doGuessOrdinal(
    data, sourceFormat, seriesLayoutBy, dimensionsDefine, startIndex, dimIndex
) {
    var result;
    // Experience value.
    var maxLoop = 5;

    if (isTypedArray(data)) {
        return false;
    }

    // When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
    // always exists in source.
    var dimName;
    if (dimensionsDefine) {
        dimName = dimensionsDefine[dimIndex];
        dimName = isObject(dimName) ? dimName.name : dimName;
    }

    if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
        if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
            var sample = data[dimIndex];
            for (var i = 0; i < (sample || []).length && i < maxLoop; i++) {
                if ((result = detectValue(sample[startIndex + i])) != null) {
                    return result;
                }
            }
        }
        else {
            for (var i = 0; i < data.length && i < maxLoop; i++) {
                var row = data[startIndex + i];
                if (row && (result = detectValue(row[dimIndex])) != null) {
                    return result;
                }
            }
        }
    }
    else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
        if (!dimName) {
            return;
        }
        for (var i = 0; i < data.length && i < maxLoop; i++) {
            var item = data[i];
            if (item && (result = detectValue(item[dimName])) != null) {
                return result;
            }
        }
    }
    else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
        if (!dimName) {
            return;
        }
        var sample = data[dimName];
        if (!sample || isTypedArray(sample)) {
            return false;
        }
        for (var i = 0; i < sample.length && i < maxLoop; i++) {
            if ((result = detectValue(sample[i])) != null) {
                return result;
            }
        }
    }
    else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
        for (var i = 0; i < data.length && i < maxLoop; i++) {
            var item = data[i];
            var val = getDataItemValue(item);
            if (!isArray(val)) {
                return false;
            }
            if ((result = detectValue(val[dimIndex])) != null) {
                return result;
            }
        }
    }

    function detectValue(val) {
        // Consider usage convenience, '1', '2' will be treated as "number".
        // `isFinit('')` get `true`.
        if (val != null && isFinite(val) && val !== '') {
            return false;
        }
        else if (isString(val) && val !== '-') {
            return true;
        }
    }

    return false;
}
function doGuessOrdinal ( data , sourceFormat , seriesLayoutBy , dimensionsDefine , startIndex , dimIndex ) { var result ; // Experience value. var maxLoop = 5 ; if ( isTypedArray ( data ) ) { return false ; } // When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine // always exists in source. var dimName ; if ( dimensionsDefine ) { dimName = dimensionsDefine [ dimIndex ] ; dimName = isObject ( dimName ) ? dimName . name : dimName ; } if ( sourceFormat === SOURCE_FORMAT_ARRAY_ROWS ) { if ( seriesLayoutBy === SERIES_LAYOUT_BY_ROW ) { var sample = data [ dimIndex ] ; for ( var i = 0 ; i < ( sample || [ ] ) . length && i < maxLoop ; i ++ ) { if ( ( result = detectValue ( sample [ startIndex + i ] ) ) != null ) { return result ; } } } else { for ( var i = 0 ; i < data . length && i < maxLoop ; i ++ ) { var row = data [ startIndex + i ] ; if ( row && ( result = detectValue ( row [ dimIndex ] ) ) != null ) { return result ; } } } } else if ( sourceFormat === SOURCE_FORMAT_OBJECT_ROWS ) { if ( ! dimName ) { return ; } for ( var i = 0 ; i < data . length && i < maxLoop ; i ++ ) { var item = data [ i ] ; if ( item && ( result = detectValue ( item [ dimName ] ) ) != null ) { return result ; } } } else if ( sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS ) { if ( ! dimName ) { return ; } var sample = data [ dimName ] ; if ( ! sample || isTypedArray ( sample ) ) { return false ; } for ( var i = 0 ; i < sample . length && i < maxLoop ; i ++ ) { if ( ( result = detectValue ( sample [ i ] ) ) != null ) { return result ; } } } else if ( sourceFormat === SOURCE_FORMAT_ORIGINAL ) { for ( var i = 0 ; i < data . length && i < maxLoop ; i ++ ) { var item = data [ i ] ; var val = getDataItemValue ( item ) ; if ( ! isArray ( val ) ) { return false ; } if ( ( result = detectValue ( val [ dimIndex ] ) ) != null ) { return result ; } } } function detectValue ( val ) { // Consider usage convenience, '1', '2' will be treated as "number". // `isFinit('')` get `true`. if ( val != null && isFinite ( val ) && val !== '' ) { return false ; } else if ( isString ( val ) && val !== '-' ) { return true ; } } return false ; }
dimIndex may be overflow source data.
dimIndex may be overflow source data .