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

Method _updateElements

src/component/graphic/GraphicView.ts:111–275  ·  view source on GitHub ↗

* Update graphic elements.

(graphicModel: GraphicComponentModel)

Source from the content-addressed store, hash-verified

109 * Update graphic elements.
110 */
111 private _updateElements(graphicModel: GraphicComponentModel): void {
112 const elOptionsToUpdate = graphicModel.useElOptionsToUpdate();
113
114 if (!elOptionsToUpdate) {
115 return;
116 }
117
118 const elMap = this._elMap;
119 const rootGroup = this.group;
120
121 const globalZ = graphicModel.get('z');
122 const globalZLevel = graphicModel.get('zlevel');
123
124 // Top-down tranverse to assign graphic settings to each elements.
125 zrUtil.each(elOptionsToUpdate, function (elOption) {
126 const id = modelUtil.convertOptionIdName(elOption.id, null);
127 const elExisting = id != null ? elMap.get(id) : null;
128 const parentId = modelUtil.convertOptionIdName(elOption.parentId, null);
129 const targetElParent = (parentId != null ? elMap.get(parentId) : rootGroup) as graphicUtil.Group;
130
131 const elType = elOption.type;
132 const elOptionStyle = (elOption as GraphicComponentDisplayableOption).style;
133 if (elType === 'text' && elOptionStyle) {
134 // In top/bottom mode, textVerticalAlign should not be used, which cause
135 // inaccurately locating.
136 if (elOption.hv && elOption.hv[1]) {
137 (elOptionStyle as any).textVerticalAlign =
138 (elOptionStyle as any).textBaseline =
139 (elOptionStyle as TextStyleProps).verticalAlign =
140 (elOptionStyle as TextStyleProps).align = null;
141 }
142 }
143
144 let textContentOption = (elOption as GraphicComponentZRPathOption).textContent;
145 let textConfig = (elOption as GraphicComponentZRPathOption).textConfig;
146 if (elOptionStyle
147 && isEC4CompatibleStyle(elOptionStyle, elType, !!textConfig, !!textContentOption)) {
148 const convertResult =
149 convertFromEC4CompatibleStyle(elOptionStyle, elType, true) as GraphicComponentZRPathOption;
150 if (!textConfig && convertResult.textConfig) {
151 textConfig = (elOption as GraphicComponentZRPathOption).textConfig = convertResult.textConfig;
152 }
153 if (!textContentOption && convertResult.textContent) {
154 textContentOption = convertResult.textContent;
155 }
156 }
157
158 // Remove unnecessary props to avoid potential problems.
159 const elOptionCleaned = getCleanedElOption(elOption);
160
161
162 // For simple, do not support parent change, otherwise reorder is needed.
163 if (__DEV__) {
164 elExisting && zrUtil.assert(
165 targetElParent === elExisting.parent,
166 'Changing parent is not supported.'
167 );
168 }

Callers 1

renderMethod · 0.95

Calls 15

isEC4CompatibleStyleFunction · 0.90
applyUpdateTransitionFunction · 0.90
updateLeaveToFunction · 0.90
applyKeyframeAnimationFunction · 0.90
getCleanedElOptionFunction · 0.85
innerFunction · 0.85
updateCommonAttrsFunction · 0.85
newElFunction · 0.85
setEventDataFunction · 0.85
useElOptionsToUpdateMethod · 0.80

Tested by

no test coverage detected