diff --git a/src/label/LabelManager.ts b/src/label/LabelManager.ts index cce12b4202c..38a65bea905 100644 --- a/src/label/LabelManager.ts +++ b/src/label/LabelManager.ts @@ -55,6 +55,7 @@ import Model from '../model/Model'; import { prepareLayoutList, hideOverlap, shiftLayoutOnX, shiftLayoutOnY } from './labelLayoutHelper'; import { labelInner, animateLabelValue } from './labelStyle'; import { normalizeRadian } from 'zrender/src/contain/util'; +import { TextProps, TextState } from 'zrender'; interface LabelDesc { label: ZRText @@ -313,6 +314,14 @@ class LabelManager { }); } + updateLabelStatusStyle( + labelState:TextState, + key:T, + val: TextState['style'][T]) { + labelState.style = labelState.style || {}; + labelState.style[key] = val; + } + updateLayoutConfig(api: ExtensionAPI) { const width = api.getWidth(); const height = api.getHeight(); @@ -378,6 +387,12 @@ class LabelManager { label.setStyle('y', defaultLabelAttr.style.y); } + label.rotation = layoutOption.rotate != null + ? layoutOption.rotate * degreeToRadian : defaultLabelAttr.rotation; + + label.scaleX = defaultLabelAttr.scaleX; + label.scaleY = defaultLabelAttr.scaleY; + if (layoutOption.labelLinePoints) { const guideLine = hostEl.getTextGuideLine(); if (guideLine) { @@ -400,25 +415,17 @@ class LabelManager { labelState.y = parsePercent(layoutOption.y, height); } - if (layoutOption.align != null) { - labelState.style = labelState.style || {}; - labelState.style.align = layoutOption.align; - } - - if (layoutOption.verticalAlign != null) { - labelState.style = labelState.style || {}; - labelState.style.verticalAlign = layoutOption.verticalAlign; - } - - labelState.rotation = layoutOption.rotate != null - ? layoutOption.rotate * degreeToRadian : defaultLabelAttr.rotation; - - labelState.scaleX = defaultLabelAttr.scaleX; - labelState.scaleY = defaultLabelAttr.scaleY; for (let k = 0; k < LABEL_OPTION_TO_STYLE_KEYS.length; k++) { const key = LABEL_OPTION_TO_STYLE_KEYS[k]; - label.setStyle(key, layoutOption[key] != null ? layoutOption[key] : defaultLabelAttr.style[key]); + const val = layoutOption[key]; + if (isNormal) { + label.setStyle(key, val != null ? val : defaultLabelAttr.style[key]); + } + else if (val != null) { + labelState.style = labelState.style || {}; + (labelState.style[key] as TextProps['style'][typeof key]) = val; + } }