code: function (mainType, cb, context) {
          var componentsMap = this._componentsMap;
  
          if (typeof mainType === 'function') {
              context = cb;
              cb = mainType;
              componentsMap.each(function (components, componentType) {
                  each(components, function (component, index) {
                      cb.call(context, componentType, component, index);
                  });
              });
          }
          else if (isString(mainType)) {
              each(componentsMap.get(mainType), cb, context);
          }
          else if (isObject(mainType)) {
              var queryResult = this.findComponents(mainType);
              each(queryResult, cb, context);
          }
      }
docs: @usage
  eachComponent('legend', function (legendModel, index) {
  ...
  });
  eachComponent(function (componentType, model, index) {
  // componentType does not include subType
  // (componentType is 'xxx' but not 'xxx.aa')
  });
  eachComponent(
  {mainType: 'dataZoom', query: {dataZoomId: 'abc'}},
  function (model, index) {...}
  );
  eachComponent(
  {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}},
  function (model, index) {...}
  );
  
  @param {string|Object=} mainType When mainType is object, the definition
  is the same as the method 'findComponents'.
  @param {Function} cb
  @param {*} context