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

Function doCreateOrUpdateAttachedTx

src/chart/custom/CustomView.ts:1183–1247  ·  view source on GitHub ↗
(
    el: Element,
    dataIndex: number,
    elOption: CustomElementOption,
    seriesModel: CustomSeriesModel,
    isInit: boolean,
    attachedTxInfo: AttachedTxInfo
)

Source from the content-addressed store, hash-verified

1181}
1182
1183function doCreateOrUpdateAttachedTx(
1184 el: Element,
1185 dataIndex: number,
1186 elOption: CustomElementOption,
1187 seriesModel: CustomSeriesModel,
1188 isInit: boolean,
1189 attachedTxInfo: AttachedTxInfo
1190): void {
1191 // Group does not support textContent temporarily until necessary.
1192 if (el.isGroup || el.type === 'compoundPath') {
1193 return;
1194 }
1195
1196 // Normal must be called before emphasis, for `isLegacy` detection.
1197 processTxInfo(elOption, null, attachedTxInfo);
1198 processTxInfo(elOption, EMPHASIS, attachedTxInfo);
1199
1200 // If `elOption.textConfig` or `elOption.textContent` is null/undefined, it does not make sense.
1201 // So for simplicity, if "elOption hasOwnProperty of them but be null/undefined", we do not
1202 // trade them as set to null to el.
1203 // Especially:
1204 // `elOption.textContent: false` means remove textContent.
1205 // `elOption.textContent.emphasis.style: false` means remove the style from emphasis state.
1206 let txConOptNormal = attachedTxInfo.normal.conOpt as CustomElementOption | false;
1207 const txConOptEmphasis = attachedTxInfo.emphasis.conOpt as CustomElementOptionOnState;
1208 const txConOptBlur = attachedTxInfo.blur.conOpt as CustomElementOptionOnState;
1209 const txConOptSelect = attachedTxInfo.select.conOpt as CustomElementOptionOnState;
1210
1211 if (txConOptNormal != null || txConOptEmphasis != null || txConOptSelect != null || txConOptBlur != null) {
1212 let textContent = el.getTextContent();
1213 if (txConOptNormal === false) {
1214 textContent && el.removeTextContent();
1215 }
1216 else {
1217 txConOptNormal = attachedTxInfo.normal.conOpt = txConOptNormal || {type: 'text'};
1218 if (!textContent) {
1219 textContent = createEl(txConOptNormal) as graphicUtil.Text;
1220 el.setTextContent(textContent);
1221 }
1222 else {
1223 // If in some case the performance issue arised, consider
1224 // do not clearState but update cached normal state directly.
1225 textContent.clearStates();
1226 }
1227
1228 updateElNormal(null, textContent, dataIndex, txConOptNormal, null, seriesModel, isInit);
1229 const txConStlOptNormal = txConOptNormal && (txConOptNormal as CustomDisplayableOption).style;
1230 for (let i = 0; i < STATES.length; i++) {
1231 const stateName = STATES[i];
1232 if (stateName !== NORMAL) {
1233 const txConOptOtherState = attachedTxInfo[stateName].conOpt as CustomElementOptionOnState;
1234 updateElOnState(
1235 stateName,
1236 textContent,
1237 txConOptOtherState,
1238 retrieveStyleOptionOnState(txConOptNormal, txConOptOtherState, stateName),
1239 null
1240 );

Callers 1

doCreateOrUpdateElFunction · 0.85

Calls 7

processTxInfoFunction · 0.85
updateElNormalFunction · 0.85
updateElOnStateFunction · 0.85
clearStatesMethod · 0.80
createElFunction · 0.70
dirtyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…