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

Function doCreateOrUpdateEl

src/chart/custom/CustomView.ts:997–1109  ·  view source on GitHub ↗
(
    api: ExtensionAPI,
    existsEl: Element,
    dataIndex: number,
    elOption: CustomElementOption,
    seriesModel: CustomSeriesModel,
    group: ViewRootGroup
)

Source from the content-addressed store, hash-verified

995}
996
997function doCreateOrUpdateEl(
998 api: ExtensionAPI,
999 existsEl: Element,
1000 dataIndex: number,
1001 elOption: CustomElementOption,
1002 seriesModel: CustomSeriesModel,
1003 group: ViewRootGroup
1004): Element {
1005
1006 if (__DEV__) {
1007 assert(elOption, 'should not have an null/undefined element setting');
1008 }
1009
1010 let toBeReplacedIdx = -1;
1011 const oldEl = existsEl;
1012 if (
1013 existsEl && (
1014 doesElNeedRecreate(existsEl, elOption, seriesModel)
1015 // || (
1016 // // PENDING: even in one-to-one mapping case, if el is marked as morph,
1017 // // do not sure whether the el will be mapped to another el with different
1018 // // hierarchy in Group tree. So always recreate el rather than reuse the el.
1019 // morphHelper && morphHelper.isOneToOneFrom(el)
1020 // )
1021 )
1022 ) {
1023 // Should keep at the original index, otherwise "merge by index" will be incorrect.
1024 toBeReplacedIdx = indexOf(group.childrenRef(), existsEl);
1025 existsEl = null;
1026 }
1027
1028 const isInit = !existsEl;
1029 let el = existsEl;
1030
1031 if (!el) {
1032 el = createEl(elOption);
1033 if (oldEl) {
1034 copyElement(oldEl, el);
1035 }
1036 }
1037 else {
1038 // FIMXE:NEXT unified clearState?
1039 // If in some case the performance issue arised, consider
1040 // do not clearState but update cached normal state directly.
1041 el.clearStates();
1042 }
1043
1044 // Need to set morph: false explictly to disable automatically morphing.
1045 if ((elOption as CustomBaseZRPathOption).morph === false) {
1046 (el as ECElement).disableMorphing = true;
1047 }
1048 else if ((el as ECElement).disableMorphing) {
1049 (el as ECElement).disableMorphing = false;
1050 }
1051 if (elOption.tooltipDisabled) {
1052 (el as ECElement).tooltipDisabled = true;
1053 }
1054

Callers 3

createOrUpdateItemFunction · 0.85
mergeChildrenFunction · 0.85
processAddUpdateFunction · 0.85

Calls 15

doesElNeedRecreateFunction · 0.85
copyElementFunction · 0.85
doCreateOrUpdateClipPathFunction · 0.85
updateElNormalFunction · 0.85
retrieveStateOptionFunction · 0.85
updateElOnStateFunction · 0.85
mergeChildrenFunction · 0.85
clearStatesMethod · 0.80
createElFunction · 0.70
updateZFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…