* @param {module:echarts/model/Global} ecModel * @param {string|Object} finder * If string, e.g., 'geo', means {geoIndex: 0}. * If Object, could contain some of these properties below: * { * seriesIndex, seriesId, seriesName, * geoIndex, geoId, geoNam
(ecModel, finder, opt)
| 12102 | * } |
| 12103 | */ |
| 12104 | function parseFinder(ecModel, finder, opt) { |
| 12105 | if (isString(finder)) { |
| 12106 | var obj = {}; |
| 12107 | obj[finder + 'Index'] = 0; |
| 12108 | finder = obj; |
| 12109 | } |
| 12110 | |
| 12111 | var defaultMainType = opt && opt.defaultMainType; |
| 12112 | if (defaultMainType |
| 12113 | && !has(finder, defaultMainType + 'Index') |
| 12114 | && !has(finder, defaultMainType + 'Id') |
| 12115 | && !has(finder, defaultMainType + 'Name') |
| 12116 | ) { |
| 12117 | finder[defaultMainType + 'Index'] = 0; |
| 12118 | } |
| 12119 | |
| 12120 | var result = {}; |
| 12121 | |
| 12122 | each$2(finder, function (value, key) { |
| 12123 | var value = finder[key]; |
| 12124 | |
| 12125 | // Exclude 'dataIndex' and other illgal keys. |
| 12126 | if (key === 'dataIndex' || key === 'dataIndexInside') { |
| 12127 | result[key] = value; |
| 12128 | return; |
| 12129 | } |
| 12130 | |
| 12131 | var parsedKey = key.match(/^(\w+)(Index|Id|Name)$/) || []; |
| 12132 | var mainType = parsedKey[1]; |
| 12133 | var queryType = (parsedKey[2] || '').toLowerCase(); |
| 12134 | |
| 12135 | if (!mainType |
| 12136 | || !queryType |
| 12137 | || value == null |
| 12138 | || (queryType === 'index' && value === 'none') |
| 12139 | || (opt && opt.includeMainTypes && indexOf(opt.includeMainTypes, mainType) < 0) |
| 12140 | ) { |
| 12141 | return; |
| 12142 | } |
| 12143 | |
| 12144 | var queryParam = {mainType: mainType}; |
| 12145 | if (queryType !== 'index' || value !== 'all') { |
| 12146 | queryParam[queryType] = value; |
| 12147 | } |
| 12148 | |
| 12149 | var models = ecModel.queryComponents(queryParam); |
| 12150 | result[mainType + 'Models'] = models; |
| 12151 | result[mainType + 'Model'] = models[0]; |
| 12152 | }); |
| 12153 | |
| 12154 | return result; |
| 12155 | } |
| 12156 | |
| 12157 | function has(obj, prop) { |
| 12158 | return obj && obj.hasOwnProperty(prop); |
no test coverage detected