MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / setTextStyleCommon

Function setTextStyleCommon

libs/echarts/echarts-en.simple.js:17629–17699  ·  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, textStyleModel, opt, isEmphasis)

Source from the content-addressed store, hash-verified

17627 * }
17628 */
17629function setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis) {
17630 // Consider there will be abnormal when merge hover style to normal style if given default value.
17631 opt = opt || EMPTY_OBJ;
17632
17633 if (opt.isRectText) {
17634 var textPosition;
17635 if (opt.getTextPosition) {
17636 textPosition = opt.getTextPosition(textStyleModel, isEmphasis);
17637 }
17638 else {
17639 textPosition = textStyleModel.getShallow('position')
17640 || (isEmphasis ? null : 'inside');
17641 // 'outside' is not a valid zr textPostion value, but used
17642 // in bar series, and magric type should be considered.
17643 textPosition === 'outside' && (textPosition = 'top');
17644 }
17645
17646 textStyle.textPosition = textPosition;
17647 textStyle.textOffset = textStyleModel.getShallow('offset');
17648 var labelRotate = textStyleModel.getShallow('rotate');
17649 labelRotate != null && (labelRotate *= Math.PI / 180);
17650 textStyle.textRotation = labelRotate;
17651 textStyle.textDistance = retrieve2(
17652 textStyleModel.getShallow('distance'), isEmphasis ? null : 5
17653 );
17654 }
17655
17656 var ecModel = textStyleModel.ecModel;
17657 var globalTextStyle = ecModel && ecModel.option.textStyle;
17658
17659 // Consider case:
17660 // {
17661 // data: [{
17662 // value: 12,
17663 // label: {
17664 // rich: {
17665 // // no 'a' here but using parent 'a'.
17666 // }
17667 // }
17668 // }],
17669 // rich: {
17670 // a: { ... }
17671 // }
17672 // }
17673 var richItemNames = getRichItemNames(textStyleModel);
17674 var richResult;
17675 if (richItemNames) {
17676 richResult = {};
17677 for (var name in richItemNames) {
17678 if (richItemNames.hasOwnProperty(name)) {
17679 // Cascade is supported in rich.
17680 var richTextStyle = textStyleModel.getModel(['rich', name]);
17681 // In rich, never `disableBox`.
17682 // FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
17683 // the default color `'blue'` will not be adopted if no color declared in `rich`.
17684 // That might confuses users. So probably we should put `textStyleModel` as the
17685 // root ancestor of the `richTextStyle`. But that would be a break change.
17686 setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis);

Callers 2

setTextStyleFunction · 0.70
setTextFunction · 0.70

Calls 4

retrieve2Function · 0.70
getRichItemNamesFunction · 0.70
setTokenTextStyleFunction · 0.70
getModelMethod · 0.45

Tested by

no test coverage detected