function makeDefaultEncode(
    seriesModel, datasetModel, data, sourceFormat, seriesLayoutBy, completeResult
) {
    var coordSysDefine = getCoordSysDefineBySeries(seriesModel);
    var encode = {};
    // var encodeTooltip = [];
    // var encodeLabel = [];
    var encodeItemName = [];
    var encodeSeriesName = [];
    var seriesType = seriesModel.subType;

    // ??? TODO refactor: provide by series itself.
    // Consider the case: 'map' series is based on geo coordSys,
    // 'graph', 'heatmap' can be based on cartesian. But can not
    // give default rule simply here.
    var nSeriesMap = createHashMap(['pie', 'map', 'funnel']);
    var cSeriesMap = createHashMap([
        'line', 'bar', 'pictorialBar', 'scatter', 'effectScatter', 'candlestick', 'boxplot'
    ]);

    // Usually in this case series will use the first data
    // dimension as the "value" dimension, or other default
    // processes respectively.
    if (coordSysDefine && cSeriesMap.get(seriesType) != null) {
        var ecModel = seriesModel.ecModel;
        var datasetMap = inner(ecModel).datasetMap;
        var key = datasetModel.uid + '_' + seriesLayoutBy;
        var datasetRecord = datasetMap.get(key)
            || datasetMap.set(key, {categoryWayDim: 1, valueWayDim: 0});

        // TODO
        // Auto detect first time axis and do arrangement.
        each(coordSysDefine.coordSysDims, function (coordDim) {
            // In value way.
            if (coordSysDefine.firstCategoryDimIndex == null) {
                var dataDim = datasetRecord.valueWayDim++;
                encode[coordDim] = dataDim;

                // ??? TODO give a better default series name rule?
                // especially when encode x y specified.
                // consider: when mutiple series share one dimension
                // category axis, series name should better use
                // the other dimsion name. On the other hand, use
                // both dimensions name.

                encodeSeriesName.push(dataDim);
                // encodeTooltip.push(dataDim);
                // encodeLabel.push(dataDim);
            }
            // In category way, category axis.
            else if (coordSysDefine.categoryAxisMap.get(coordDim)) {
                encode[coordDim] = 0;
                encodeItemName.push(0);
            }
            // In category way, non-category axis.
            else {
                var dataDim = datasetRecord.categoryWayDim++;
                encode[coordDim] = dataDim;
                // encodeTooltip.push(dataDim);
                // encodeLabel.push(dataDim);
                encodeSeriesName.push(dataDim);
            }
        });
    }
    // Do not make a complex rule! Hard to code maintain and not necessary.
    // ??? TODO refactor: provide by series itself.
    // [{name: ..., value: ...}, ...] like:
    else if (nSeriesMap.get(seriesType) != null) {
        // Find the first not ordinal. (5 is an experience value)
        var firstNotOrdinal;
        for (var i = 0; i < 5 && firstNotOrdinal == null; i++) {
            if (!doGuessOrdinal(
                data, sourceFormat, seriesLayoutBy,
                completeResult.dimensionsDefine, completeResult.startIndex, i
            )) {
                firstNotOrdinal = i;
            }
        }
        if (firstNotOrdinal != null) {
            encode.value = firstNotOrdinal;
            var nameDimIndex = completeResult.potentialNameDimIndex
                || Math.max(firstNotOrdinal - 1, 0);
            // By default, label use itemName in charts.
            // So we dont set encodeLabel here.
            encodeSeriesName.push(nameDimIndex);
            encodeItemName.push(nameDimIndex);
            // encodeTooltip.push(firstNotOrdinal);
        }
    }

    // encodeTooltip.length && (encode.tooltip = encodeTooltip);
    // encodeLabel.length && (encode.label = encodeLabel);
    encodeItemName.length && (encode.itemName = encodeItemName);
    encodeSeriesName.length && (encode.seriesName = encodeSeriesName);

    return encode;
}
function makeDefaultEncode(
    seriesModel, datasetModel, data, sourceFormat, seriesLayoutBy, completeResult
) {
    var coordSysDefine = getCoordSysDefineBySeries(seriesModel);
    var encode = {};
    // var encodeTooltip = [];
    // var encodeLabel = [];
    var encodeItemName = [];
    var encodeSeriesName = [];
    var seriesType = seriesModel.subType;

    // ??? TODO refactor: provide by series itself.
    // Consider the case: 'map' series is based on geo coordSys,
    // 'graph', 'heatmap' can be based on cartesian. But can not
    // give default rule simply here.
    var nSeriesMap = createHashMap(['pie', 'map', 'funnel']);
    var cSeriesMap = createHashMap([
        'line', 'bar', 'pictorialBar', 'scatter', 'effectScatter', 'candlestick', 'boxplot'
    ]);

    // Usually in this case series will use the first data
    // dimension as the "value" dimension, or other default
    // processes respectively.
    if (coordSysDefine && cSeriesMap.get(seriesType) != null) {
        var ecModel = seriesModel.ecModel;
        var datasetMap = inner(ecModel).datasetMap;
        var key = datasetModel.uid + '_' + seriesLayoutBy;
        var datasetRecord = datasetMap.get(key)
            || datasetMap.set(key, {categoryWayDim: 1, valueWayDim: 0});

        // TODO
        // Auto detect first time axis and do arrangement.
        each(coordSysDefine.coordSysDims, function (coordDim) {
            // In value way.
            if (coordSysDefine.firstCategoryDimIndex == null) {
                var dataDim = datasetRecord.valueWayDim++;
                encode[coordDim] = dataDim;

                // ??? TODO give a better default series name rule?
                // especially when encode x y specified.
                // consider: when mutiple series share one dimension
                // category axis, series name should better use
                // the other dimsion name. On the other hand, use
                // both dimensions name.

                encodeSeriesName.push(dataDim);
                // encodeTooltip.push(dataDim);
                // encodeLabel.push(dataDim);
            }
            // In category way, category axis.
            else if (coordSysDefine.categoryAxisMap.get(coordDim)) {
                encode[coordDim] = 0;
                encodeItemName.push(0);
            }
            // In category way, non-category axis.
            else {
                var dataDim = datasetRecord.categoryWayDim++;
                encode[coordDim] = dataDim;
                // encodeTooltip.push(dataDim);
                // encodeLabel.push(dataDim);
                encodeSeriesName.push(dataDim);
            }
        });
    }
    // Do not make a complex rule! Hard to code maintain and not necessary.
    // ??? TODO refactor: provide by series itself.
    // [{name: ..., value: ...}, ...] like:
    else if (nSeriesMap.get(seriesType) != null) {
        // Find the first not ordinal. (5 is an experience value)
        var firstNotOrdinal;
        for (var i = 0; i < 5 && firstNotOrdinal == null; i++) {
            if (!doGuessOrdinal(
                data, sourceFormat, seriesLayoutBy,
                completeResult.dimensionsDefine, completeResult.startIndex, i
            )) {
                firstNotOrdinal = i;
            }
        }
        if (firstNotOrdinal != null) {
            encode.value = firstNotOrdinal;
            var nameDimIndex = completeResult.potentialNameDimIndex
                || Math.max(firstNotOrdinal - 1, 0);
            // By default, label use itemName in charts.
            // So we dont set encodeLabel here.
            encodeSeriesName.push(nameDimIndex);
            encodeItemName.push(nameDimIndex);
            // encodeTooltip.push(firstNotOrdinal);
        }
    }

    // encodeTooltip.length && (encode.tooltip = encodeTooltip);
    // encodeLabel.length && (encode.label = encodeLabel);
    encodeItemName.length && (encode.itemName = encodeItemName);
    encodeSeriesName.length && (encode.seriesName = encodeSeriesName);

    return encode;
}
function makeDefaultEncode ( seriesModel , datasetModel , data , sourceFormat , seriesLayoutBy , completeResult ) { var coordSysDefine = getCoordSysDefineBySeries ( seriesModel ) ; var encode = { } ; // var encodeTooltip = []; // var encodeLabel = []; var encodeItemName = [ ] ; var encodeSeriesName = [ ] ; var seriesType = seriesModel . subType ; // ??? TODO refactor: provide by series itself. // Consider the case: 'map' series is based on geo coordSys, // 'graph', 'heatmap' can be based on cartesian. But can not // give default rule simply here. var nSeriesMap = createHashMap ( [ 'pie' , 'map' , 'funnel' ] ) ; var cSeriesMap = createHashMap ( [ 'line' , 'bar' , 'pictorialBar' , 'scatter' , 'effectScatter' , 'candlestick' , 'boxplot' ] ) ; // Usually in this case series will use the first data // dimension as the "value" dimension, or other default // processes respectively. if ( coordSysDefine && cSeriesMap . get ( seriesType ) != null ) { var ecModel = seriesModel . ecModel ; var datasetMap = inner ( ecModel ) . datasetMap ; var key = datasetModel . uid + '_' + seriesLayoutBy ; var datasetRecord = datasetMap . get ( key ) || datasetMap . set ( key , { categoryWayDim : 1 , valueWayDim : 0 } ) ; // TODO // Auto detect first time axis and do arrangement. each ( coordSysDefine . coordSysDims , function ( coordDim ) { // In value way. if ( coordSysDefine . firstCategoryDimIndex == null ) { var dataDim = datasetRecord . valueWayDim ++ ; encode [ coordDim ] = dataDim ; // ??? TODO give a better default series name rule? // especially when encode x y specified. // consider: when mutiple series share one dimension // category axis, series name should better use // the other dimsion name. On the other hand, use // both dimensions name. encodeSeriesName . push ( dataDim ) ; // encodeTooltip.push(dataDim); // encodeLabel.push(dataDim); } // In category way, category axis. else if ( coordSysDefine . categoryAxisMap . get ( coordDim ) ) { encode [ coordDim ] = 0 ; encodeItemName . push ( 0 ) ; } // In category way, non-category axis. else { var dataDim = datasetRecord . categoryWayDim ++ ; encode [ coordDim ] = dataDim ; // encodeTooltip.push(dataDim); // encodeLabel.push(dataDim); encodeSeriesName . push ( dataDim ) ; } } ) ; } // Do not make a complex rule! Hard to code maintain and not necessary. // ??? TODO refactor: provide by series itself. // [{name: ..., value: ...}, ...] like: else if ( nSeriesMap . get ( seriesType ) != null ) { // Find the first not ordinal. (5 is an experience value) var firstNotOrdinal ; for ( var i = 0 ; i < 5 && firstNotOrdinal == null ; i ++ ) { if ( ! doGuessOrdinal ( data , sourceFormat , seriesLayoutBy , completeResult . dimensionsDefine , completeResult . startIndex , i ) ) { firstNotOrdinal = i ; } } if ( firstNotOrdinal != null ) { encode . value = firstNotOrdinal ; var nameDimIndex = completeResult . potentialNameDimIndex || Math . max ( firstNotOrdinal - 1 , 0 ) ; // By default, label use itemName in charts. // So we dont set encodeLabel here. encodeSeriesName . push ( nameDimIndex ) ; encodeItemName . push ( nameDimIndex ) ; // encodeTooltip.push(firstNotOrdinal); } } // encodeTooltip.length && (encode.tooltip = encodeTooltip); // encodeLabel.length && (encode.label = encodeLabel); encodeItemName . length && ( encode . itemName = encodeItemName ) ; encodeSeriesName . length && ( encode . seriesName = encodeSeriesName ) ; return encode ; }
??? TODO merge to completedimensions, where also has default encode making logic. And the default rule should depends on series? consider 'map'.
??? TODO merge to completedimensions where also has default encode making logic . And the default rule should depends on series? consider map .
This function is called by encodeSeries to create a default encode array for the series.