@@ -55,6 +55,7 @@ import Model from '../model/Model';
55
55
import { prepareLayoutList , hideOverlap , shiftLayoutOnX , shiftLayoutOnY } from './labelLayoutHelper' ;
56
56
import { labelInner , animateLabelValue } from './labelStyle' ;
57
57
import { normalizeRadian } from 'zrender/src/contain/util' ;
58
+ import { TextProps } from 'zrender' ;
58
59
59
60
interface LabelDesc {
60
61
label : ZRText
@@ -389,6 +390,13 @@ class LabelManager {
389
390
390
391
const labelLayoutStore = labelLayoutInnerStore ( label ) ;
391
392
labelLayoutStore . needsUpdateLabelLine = needsUpdateLabelLine ;
393
+
394
+ label . rotation = layoutOption . rotate != null
395
+ ? layoutOption . rotate * degreeToRadian : defaultLabelAttr . rotation ;
396
+
397
+ label . scaleX = defaultLabelAttr . scaleX ;
398
+ label . scaleY = defaultLabelAttr . scaleY ;
399
+
392
400
for ( const state of DISPLAY_STATES ) {
393
401
const isNormal = state === 'normal' ;
394
402
const labelState = isNormal ? label : label . ensureState ( state ) ;
@@ -400,25 +408,17 @@ class LabelManager {
400
408
labelState . y = parsePercent ( layoutOption . y , height ) ;
401
409
}
402
410
403
- if ( layoutOption . align != null ) {
404
- labelState . style = labelState . style || { } ;
405
- labelState . style . align = layoutOption . align ;
406
- }
407
-
408
- if ( layoutOption . verticalAlign != null ) {
409
- labelState . style = labelState . style || { } ;
410
- labelState . style . verticalAlign = layoutOption . verticalAlign ;
411
- }
412
-
413
- labelState . rotation = layoutOption . rotate != null
414
- ? layoutOption . rotate * degreeToRadian : defaultLabelAttr . rotation ;
415
-
416
- labelState . scaleX = defaultLabelAttr . scaleX ;
417
- labelState . scaleY = defaultLabelAttr . scaleY ;
418
411
419
412
for ( let k = 0 ; k < LABEL_OPTION_TO_STYLE_KEYS . length ; k ++ ) {
420
413
const key = LABEL_OPTION_TO_STYLE_KEYS [ k ] ;
421
- label . setStyle ( key , layoutOption [ key ] != null ? layoutOption [ key ] : defaultLabelAttr . style [ key ] ) ;
414
+ const val = layoutOption [ key ] ;
415
+ if ( isNormal ) {
416
+ label . setStyle ( key , val != null ? val : defaultLabelAttr . style [ key ] ) ;
417
+ }
418
+ else if ( val != null ) {
419
+ labelState . style = labelState . style || { } ;
420
+ ( labelState . style [ key ] as TextProps [ 'style' ] [ typeof key ] ) = val ;
421
+ }
422
422
}
423
423
424
424
0 commit comments