src/model/Global.js
function (condition) {
        var mainType = condition.mainType;
        if (!mainType) {
            return [];
        }

        var index = condition.index;
        var id = condition.id;
        var name = condition.name;

        var cpts = this._componentsMap.get(mainType);

        if (!cpts || !cpts.length) {
            return [];
        }

        var result;

        if (index != null) {
            if (!isArray(index)) {
                index = [index];
            }
            result = filter(map(index, function (idx) {
                return cpts[idx];
            }), function (val) {
                return !!val;
            });
        }
        else if (id != null) {
            var isIdArray = isArray(id);
            result = filter(cpts, function (cpt) {
                return (isIdArray && indexOf(id, cpt.id) >= 0)
                    || (!isIdArray && cpt.id === id);
            });
        }
        else if (name != null) {
            var isNameArray = isArray(name);
            result = filter(cpts, function (cpt) {
                return (isNameArray && indexOf(name, cpt.name) >= 0)
                    || (!isNameArray && cpt.name === name);
            });
        }
        else {
            // Return all components with mainType
            result = cpts.slice();
        }

        return filterBySubType(result, condition);
    }
function (condition) {
        var mainType = condition.mainType;
        if (!mainType) {
            return [];
        }

        var index = condition.index;
        var id = condition.id;
        var name = condition.name;

        var cpts = this._componentsMap.get(mainType);

        if (!cpts || !cpts.length) {
            return [];
        }

        var result;

        if (index != null) {
            if (!isArray(index)) {
                index = [index];
            }
            result = filter(map(index, function (idx) {
                return cpts[idx];
            }), function (val) {
                return !!val;
            });
        }
        else if (id != null) {
            var isIdArray = isArray(id);
            result = filter(cpts, function (cpt) {
                return (isIdArray && indexOf(id, cpt.id) >= 0)
                    || (!isIdArray && cpt.id === id);
            });
        }
        else if (name != null) {
            var isNameArray = isArray(name);
            result = filter(cpts, function (cpt) {
                return (isNameArray && indexOf(name, cpt.name) >= 0)
                    || (!isNameArray && cpt.name === name);
            });
        }
        else {
            // Return all components with mainType
            result = cpts.slice();
        }

        return filterBySubType(result, condition);
    }
function ( condition ) { var mainType = condition . mainType ; if ( ! mainType ) { return [ ] ; } var index = condition . index ; var id = condition . id ; var name = condition . name ; var cpts = this . _componentsMap . get ( mainType ) ; if ( ! cpts || ! cpts . length ) { return [ ] ; } var result ; if ( index != null ) { if ( ! isArray ( index ) ) { index = [ index ] ; } result = filter ( map ( index , function ( idx ) { return cpts [ idx ] ; } ) , function ( val ) { return ! ! val ; } ) ; } else if ( id != null ) { var isIdArray = isArray ( id ) ; result = filter ( cpts , function ( cpt ) { return ( isIdArray && indexOf ( id , cpt . id ) >= 0 ) || ( ! isIdArray && cpt . id === id ) ; } ) ; } else if ( name != null ) { var isNameArray = isArray ( name ) ; result = filter ( cpts , function ( cpt ) { return ( isNameArray && indexOf ( name , cpt . name ) >= 0 ) || ( ! isNameArray && cpt . name === name ) ; } ) ; } else { // Return all components with mainType result = cpts . slice ( ) ; } return filterBySubType ( result , condition ) ; }
If none of index and id and name used, return all components with mainType.
@param {Object} condition
@param {string} condition.mainType
@param {string} [condition.subType] If ignore, only query by mainType
@param {number|Array.<number>} [condition.index] Either input index or id or name.
@param {string|Array.<string>} [condition.id] Either input index or id or name.
@param {string|Array.<string>} [condition.name] Either input index or id or name.
@return {Array.<module:echarts/model/Component>}
If none of index and id and name used return all components with mainType .