MCPcopy
hub / github.com/apache/echarts / findComponents

Method findComponents

src/model/Global.ts:646–682  ·  view source on GitHub ↗

* The interface is different from queryComponents, * which is convenient for inner usage. * * @usage * let result = findComponents( * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}} * ); * let result = findComponents( * {mainType: 'series', subType:

(condition: QueryConditionKindA)

Source from the content-addressed store, hash-verified

644 * // result like [component0, component1, ...]
645 */
646 findComponents(condition: QueryConditionKindA): ComponentModel[] {
647 const query = condition.query;
648 const mainType = condition.mainType;
649
650 const queryCond = getQueryCond(query);
651 const result = queryCond
652 ? this.queryComponents(queryCond)
653 // Retrieve all non-empty components.
654 : filter(this._componentsMap.get(mainType), cmpt => !!cmpt);
655
656 return doFilter(filterBySubType(result, condition));
657
658 function getQueryCond(q: QueryConditionKindA['query']): QueryConditionKindB {
659 const indexAttr = mainType + 'Index';
660 const idAttr = mainType + 'Id';
661 const nameAttr = mainType + 'Name';
662 return q && (
663 q[indexAttr] != null
664 || q[idAttr] != null
665 || q[nameAttr] != null
666 )
667 ? {
668 mainType: mainType,
669 // subType will be filtered finally.
670 index: q[indexAttr] as (number | number[]),
671 id: q[idAttr] as (OptionId | OptionId[]),
672 name: q[nameAttr] as (OptionName | OptionName[])
673 }
674 : null;
675 }
676
677 function doFilter(res: ComponentModel[]) {
678 return condition.filter
679 ? filter(res, condition.filter)
680 : res;
681 }
682 }
683
684 /**
685 * Travel components (before filtered).

Callers 7

eachComponentMethod · 0.95
categoryFilterFunction · 0.80
renderMethod · 0.80
legendFilterFunction · 0.80
fromAxisAreaSelectFunction · 0.80
dataFilterFunction · 0.80

Calls 3

queryComponentsMethod · 0.95
filterBySubTypeFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected