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

Function setTextStyleCommon

src/label/labelStyle.ts:394–485  ·  view source on GitHub ↗

* The uniform entry of set text style, that is, retrieve style definitions * from `model` and set to `textStyle` object. * * Never in merge mode, but in overwrite mode, that is, all of the text style * properties will be set. (Consider the states of normal and emphasis and * default value can b

(
    textStyle: TextStyleProps,
    textStyleModel: LabelCommonModel<TNuance>,
    opt?: Pick<
        TextCommonParams,
        'inheritColor' | 'defaultOpacity' | 'disableBox' | 'defaultTextMargin'
    >,
    isNotNormal?: boolean,
    isAttached?: boolean
)

Source from the content-addressed store, hash-verified

392 * to manage.)
393 */
394function setTextStyleCommon<
395 TNuance extends TextCommonOptionNuanceBase = TextCommonOptionNuanceDefault
396>(
397 textStyle: TextStyleProps,
398 textStyleModel: LabelCommonModel<TNuance>,
399 opt?: Pick<
400 TextCommonParams,
401 'inheritColor' | 'defaultOpacity' | 'disableBox' | 'defaultTextMargin'
402 >,
403 isNotNormal?: boolean,
404 isAttached?: boolean
405) {
406 // Consider there will be abnormal when merge hover style to normal style if given default value.
407 opt = opt || EMPTY_OBJ;
408 const ecModel = textStyleModel.ecModel;
409 const globalTextStyle = ecModel && ecModel.option.textStyle;
410 // Consider case:
411 // {
412 // data: [{
413 // value: 12,
414 // label: {
415 // rich: {
416 // // no 'a' here but using parent 'a'.
417 // }
418 // }
419 // }],
420 // rich: {
421 // a: { ... }
422 // }
423 // }
424 const richItemNames = getRichItemNames<TNuance>(textStyleModel);
425 let richResult: TextStyleProps['rich'];
426 if (richItemNames) {
427 richResult = {};
428 const richInheritPlainLabelOptionName = 'richInheritPlainLabel' as const;
429 const richInheritPlainLabel: boolean = retrieve2(
430 textStyleModel.get(richInheritPlainLabelOptionName as any),
431 ecModel ? ecModel.get(richInheritPlainLabelOptionName) : undefined
432 );
433 for (const name in richItemNames) {
434 if (richItemNames.hasOwnProperty(name)) {
435 // Cascade is supported in rich.
436 const richTextStyle = textStyleModel.getModel(['rich', name]) as LabelCommonModel<TNuance>;
437 // In rich, never `disableBox`.
438 // consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
439 // the default color `'blue'` will not be adopted if no color declared in `rich`.
440 // That might confuses users. So probably we should put `textStyleModel` as the
441 // root ancestor of the `richTextStyle`. But that would be a break change.
442 // Since v6, the rich style inherits plain label by default
443 // but this behavior can be disabled by setting `richInheritPlainLabel` to `false`.
444 setTokenTextStyle<TNuance>(
445 richResult[name] = {}, richTextStyle, globalTextStyle, textStyleModel, richInheritPlainLabel,
446 opt, isNotNormal, isAttached, false, true
447 );
448 }
449 }
450 }
451 if (richResult) {

Callers 1

createTextStyleFunction · 0.85

Calls 5

getRichItemNamesFunction · 0.85
setTokenTextStyleFunction · 0.85
isNumberFunction · 0.85
getMethod · 0.45
getModelMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…