src/util/graphic.js
function setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis) {
    // Consider there will be abnormal when merge hover style to normal style if given default value.
    opt = opt || EMPTY_OBJ;

    if (opt.isRectText) {
        var textPosition = textStyleModel.getShallow('position')
            || (isEmphasis ? null : 'inside');
        // 'outside' is not a valid zr textPostion value, but used
        // in bar series, and magric type should be considered.
        textPosition === 'outside' && (textPosition = 'top');
        textStyle.textPosition = textPosition;
        textStyle.textOffset = textStyleModel.getShallow('offset');
        var labelRotate = textStyleModel.getShallow('rotate');
        labelRotate != null && (labelRotate *= Math.PI / 180);
        textStyle.textRotation = labelRotate;
        textStyle.textDistance = zrUtil.retrieve2(
            textStyleModel.getShallow('distance'), isEmphasis ? null : 5
        );
    }

    var ecModel = textStyleModel.ecModel;
    var globalTextStyle = ecModel && ecModel.option.textStyle;

    // Consider case:
    // {
    //     data: [{
    //         value: 12,
    //         label: {
    //             rich: {
    //                 // no 'a' here but using parent 'a'.
    //             }
    //         }
    //     }],
    //     rich: {
    //         a: { ... }
    //     }
    // }
    var richItemNames = getRichItemNames(textStyleModel);
    var richResult;
    if (richItemNames) {
        richResult = {};
        for (var name in richItemNames) {
            if (richItemNames.hasOwnProperty(name)) {
                // Cascade is supported in rich.
                var richTextStyle = textStyleModel.getModel(['rich', name]);
                // In rich, never `disableBox`.
                // FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
                // the default color `'blue'` will not be adopted if no color declared in `rich`.
                // That might confuses users. So probably we should put `textStyleModel` as the
                // root ancestor of the `richTextStyle`. But that would be a break change.
                setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis);
            }
        }
    }
    textStyle.rich = richResult;

    setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, true);

    if (opt.forceRich && !opt.textStyle) {
        opt.textStyle = {};
    }

    return textStyle;
}
function setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis) {
    // Consider there will be abnormal when merge hover style to normal style if given default value.
    opt = opt || EMPTY_OBJ;

    if (opt.isRectText) {
        var textPosition = textStyleModel.getShallow('position')
            || (isEmphasis ? null : 'inside');
        // 'outside' is not a valid zr textPostion value, but used
        // in bar series, and magric type should be considered.
        textPosition === 'outside' && (textPosition = 'top');
        textStyle.textPosition = textPosition;
        textStyle.textOffset = textStyleModel.getShallow('offset');
        var labelRotate = textStyleModel.getShallow('rotate');
        labelRotate != null && (labelRotate *= Math.PI / 180);
        textStyle.textRotation = labelRotate;
        textStyle.textDistance = zrUtil.retrieve2(
            textStyleModel.getShallow('distance'), isEmphasis ? null : 5
        );
    }

    var ecModel = textStyleModel.ecModel;
    var globalTextStyle = ecModel && ecModel.option.textStyle;

    // Consider case:
    // {
    //     data: [{
    //         value: 12,
    //         label: {
    //             rich: {
    //                 // no 'a' here but using parent 'a'.
    //             }
    //         }
    //     }],
    //     rich: {
    //         a: { ... }
    //     }
    // }
    var richItemNames = getRichItemNames(textStyleModel);
    var richResult;
    if (richItemNames) {
        richResult = {};
        for (var name in richItemNames) {
            if (richItemNames.hasOwnProperty(name)) {
                // Cascade is supported in rich.
                var richTextStyle = textStyleModel.getModel(['rich', name]);
                // In rich, never `disableBox`.
                // FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
                // the default color `'blue'` will not be adopted if no color declared in `rich`.
                // That might confuses users. So probably we should put `textStyleModel` as the
                // root ancestor of the `richTextStyle`. But that would be a break change.
                setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis);
            }
        }
    }
    textStyle.rich = richResult;

    setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, true);

    if (opt.forceRich && !opt.textStyle) {
        opt.textStyle = {};
    }

    return textStyle;
}
function setTextStyleCommon ( textStyle , textStyleModel , opt , isEmphasis ) { // Consider there will be abnormal when merge hover style to normal style if given default value. opt = opt || EMPTY_OBJ ; if ( opt . isRectText ) { var textPosition = textStyleModel . getShallow ( 'position' ) || ( isEmphasis ? null : 'inside' ) ; // 'outside' is not a valid zr textPostion value, but used // in bar series, and magric type should be considered. textPosition === 'outside' && ( textPosition = 'top' ) ; textStyle . textPosition = textPosition ; textStyle . textOffset = textStyleModel . getShallow ( 'offset' ) ; var labelRotate = textStyleModel . getShallow ( 'rotate' ) ; labelRotate != null && ( labelRotate *= Math . PI / 180 ) ; textStyle . textRotation = labelRotate ; textStyle . textDistance = zrUtil . retrieve2 ( textStyleModel . getShallow ( 'distance' ) , isEmphasis ? null : 5 ) ; } var ecModel = textStyleModel . ecModel ; var globalTextStyle = ecModel && ecModel . option . textStyle ; // Consider case: // { //     data: [{ //         value: 12, //         label: { //             rich: { //                 // no 'a' here but using parent 'a'. //             } //         } //     }], //     rich: { //         a: { ... } //     } // } var richItemNames = getRichItemNames ( textStyleModel ) ; var richResult ; if ( richItemNames ) { richResult = { } ; for ( var name in richItemNames ) { if ( richItemNames . hasOwnProperty ( name ) ) { // Cascade is supported in rich. var richTextStyle = textStyleModel . getModel ( [ 'rich' , name ] ) ; // In rich, never `disableBox`. // FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`, // the default color `'blue'` will not be adopted if no color declared in `rich`. // That might confuses users. So probably we should put `textStyleModel` as the // root ancestor of the `richTextStyle`. But that would be a break change. setTokenTextStyle ( richResult [ name ] = { } , richTextStyle , globalTextStyle , opt , isEmphasis ) ; } } } textStyle . rich = richResult ; setTokenTextStyle ( textStyle , textStyleModel , globalTextStyle , opt , isEmphasis , true ) ; if ( opt . forceRich && ! opt . textStyle ) { opt . textStyle = { } ; } return textStyle ; }
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 be adopted, merge would make the logic too complicated
to manage.)

The `textStyle` object can either be a plain object or an instance of
`zrender/src/graphic/Style`, and either be the style of normal or emphasis.
After this mothod called, the `textStyle` object can then be used in
`el.setStyle(textStyle)` or `el.hoverStyle = textStyle`.

Default value will be adopted and `insideRollbackOpt` will be created.
See `applyDefaultTextStyle` `rollbackDefaultTextStyle` for more details.

opt: {
disableBox: boolean, Whether diable drawing box of block (outer most).
isRectText: boolean,
autoColor: string, specify a color when color is 'auto',
for textFill, textStroke, textBackgroundColor, and textBorderColor.
If autoColor specified, it is used as default textFill.
useInsideStyle:
`true`: Use inside style (textFill, textStroke, textStrokeWidth)
if `textFill` is not specified.
`false`: Do not use inside style.
`null/undefined`: use inside style if `isRectText` is true and
`textFill` is not specified and textPosition contains `'inside'`.
forceRich: boolean
}
The uniform entry of set text style that is retrieve style definitions from model and set to textStyle object .