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

Function processTxInfo

src/chart/custom/CustomView.ts:1249–1300  ·  view source on GitHub ↗
(
    elOption: CustomElementOption,
    state: DisplayStateNonNormal,
    attachedTxInfo: AttachedTxInfo
)

Source from the content-addressed store, hash-verified

1247}
1248
1249function processTxInfo(
1250 elOption: CustomElementOption,
1251 state: DisplayStateNonNormal,
1252 attachedTxInfo: AttachedTxInfo
1253): void {
1254 const stateOpt = !state ? elOption : retrieveStateOption(elOption, state);
1255 const styleOpt = !state
1256 ? (elOption as CustomDisplayableOption).style
1257 : retrieveStyleOptionOnState(elOption, stateOpt, EMPHASIS);
1258
1259 const elType = elOption.type;
1260 let txCfg = stateOpt ? stateOpt.textConfig : null;
1261 const txConOptNormal = elOption.textContent;
1262 let txConOpt: CustomElementOption | CustomElementOptionOnState =
1263 !txConOptNormal ? null : !state ? txConOptNormal : retrieveStateOption(txConOptNormal, state);
1264
1265 if (styleOpt && (
1266 // Because emphasis style has little info to detect legacy,
1267 // if normal is legacy, emphasis is trade as legacy.
1268 attachedTxInfo.isLegacy
1269 || isEC4CompatibleStyle(styleOpt, elType, !!txCfg, !!txConOpt)
1270 )) {
1271 attachedTxInfo.isLegacy = true;
1272 const convertResult = convertFromEC4CompatibleStyle(styleOpt, elType, !state);
1273 // Explicitly specified `textConfig` and `textContent` has higher priority than
1274 // the ones generated by legacy style. Otherwise if users use them and `api.style`
1275 // at the same time, they not both work and hardly to known why.
1276 if (!txCfg && convertResult.textConfig) {
1277 txCfg = convertResult.textConfig;
1278 }
1279 if (!txConOpt && convertResult.textContent) {
1280 txConOpt = convertResult.textContent;
1281 }
1282 }
1283
1284 if (!state && txConOpt) {
1285 const txConOptNormal = txConOpt as CustomElementOption;
1286 // `textContent: {type: 'text'}`, the "type" is easy to be missing. So we tolerate it.
1287 !txConOptNormal.type && (txConOptNormal.type = 'text');
1288 if (__DEV__) {
1289 // Do not tolerate incorrcet type for forward compat.
1290 assert(
1291 txConOptNormal.type === 'text',
1292 'textContent.type must be "text"'
1293 );
1294 }
1295 }
1296
1297 const info = !state ? attachedTxInfo.normal : attachedTxInfo[state];
1298 info.cfg = txCfg;
1299 info.conOpt = txConOpt;
1300}
1301
1302function retrieveStateOption(
1303 elOption: CustomElementOption, state: DisplayStateNonNormal

Callers 1

Calls 5

isEC4CompatibleStyleFunction · 0.90
retrieveStateOptionFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…