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

Method queryComponents

src/model/Global.ts:592–627  ·  view source on GitHub ↗

* @return Never be null/undefined.

(condition: QueryConditionKindB)

Source from the content-addressed store, hash-verified

590 * @return Never be null/undefined.
591 */
592 queryComponents(condition: QueryConditionKindB): ComponentModel[] {
593 const mainType = condition.mainType;
594 if (!mainType) {
595 return [];
596 }
597
598 const index = condition.index;
599 const id = condition.id;
600 const name = condition.name;
601 const cmpts = this._componentsMap.get(mainType);
602
603 if (!cmpts || !cmpts.length) {
604 return [];
605 }
606
607 let result: ComponentModel[];
608
609 if (index != null) {
610 result = [];
611 each(modelUtil.normalizeToArray(index), function (idx) {
612 cmpts[idx] && result.push(cmpts[idx]);
613 });
614 }
615 else if (id != null) {
616 result = queryByIdOrName('id', id, cmpts);
617 }
618 else if (name != null) {
619 result = queryByIdOrName('name', name, cmpts);
620 }
621 else {
622 // Return all non-empty components in that mainType
623 result = filter(cmpts, cmpt => !!cmpt);
624 }
625
626 return filterBySubType(result, condition);
627 }
628
629 /**
630 * The interface is different from queryComponents,

Callers 5

findComponentsMethod · 0.95
getTargetMethod · 0.80
pushFunction · 0.80
_initDimensionsMethod · 0.80
queryReferringComponentsFunction · 0.80

Calls 4

queryByIdOrNameFunction · 0.85
filterBySubTypeFunction · 0.85
eachFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected