@visactor/vrender-components 0.22.11 → 0.22.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/cjs/animation/animate-component.d.ts +22 -0
  2. package/cjs/animation/animate-component.js +29 -0
  3. package/cjs/animation/animate-component.js.map +1 -0
  4. package/cjs/animation/axis-animate.d.ts +10 -0
  5. package/cjs/animation/axis-animate.js +71 -0
  6. package/cjs/animation/axis-animate.js.map +1 -0
  7. package/cjs/animation/label-animate.d.ts +10 -0
  8. package/cjs/animation/label-animate.js +81 -0
  9. package/cjs/animation/label-animate.js.map +1 -0
  10. package/cjs/axis/animate/config.d.ts +6 -0
  11. package/cjs/axis/animate/config.js +10 -0
  12. package/cjs/axis/animate/config.js.map +1 -0
  13. package/cjs/axis/animate/group-transition.d.ts +2 -1
  14. package/cjs/axis/animate/group-transition.js +2 -2
  15. package/cjs/axis/animate/group-transition.js.map +1 -1
  16. package/cjs/axis/base.d.ts +9 -4
  17. package/cjs/axis/base.js +70 -5
  18. package/cjs/axis/base.js.map +1 -1
  19. package/cjs/axis/line.js.map +1 -1
  20. package/cjs/axis/register.js +2 -2
  21. package/cjs/axis/register.js.map +1 -1
  22. package/cjs/axis/tick-data/continuous.js +17 -15
  23. package/cjs/axis/tick-data/continuous.js.map +1 -1
  24. package/cjs/axis/tick-data/discrete/linear.js +21 -14
  25. package/cjs/axis/tick-data/discrete/linear.js.map +1 -1
  26. package/cjs/axis/tick-data/util.js +14 -8
  27. package/cjs/axis/tick-data/util.js.map +1 -1
  28. package/cjs/axis/type.d.ts +4 -0
  29. package/cjs/axis/type.js.map +1 -1
  30. package/cjs/brush/brush.d.ts +1 -5
  31. package/cjs/brush/brush.js +11 -13
  32. package/cjs/brush/brush.js.map +1 -1
  33. package/cjs/brush/config.js +1 -2
  34. package/cjs/brush/type.js +2 -1
  35. package/cjs/core/base.d.ts +5 -1
  36. package/cjs/core/base.js +11 -0
  37. package/cjs/core/base.js.map +1 -1
  38. package/cjs/crosshair/rect.js +1 -2
  39. package/cjs/crosshair/type.js +2 -1
  40. package/cjs/data-zoom/data-zoom.d.ts +1 -5
  41. package/cjs/data-zoom/data-zoom.js +7 -8
  42. package/cjs/data-zoom/data-zoom.js.map +1 -1
  43. package/cjs/index.d.ts +1 -1
  44. package/cjs/index.js +1 -1
  45. package/cjs/index.js.map +1 -1
  46. package/cjs/indicator/register.js +1 -2
  47. package/cjs/jsx/index.js +2 -1
  48. package/cjs/label/animate/animate.d.ts +1 -12
  49. package/cjs/label/animate/animate.js +1 -84
  50. package/cjs/label/animate/animate.js.map +1 -1
  51. package/cjs/label/arc.js +6 -6
  52. package/cjs/label/arc.js.map +1 -1
  53. package/cjs/label/base.d.ts +6 -5
  54. package/cjs/label/base.js +87 -108
  55. package/cjs/label/base.js.map +1 -1
  56. package/cjs/label/index.js +1 -1
  57. package/cjs/label/line.js +1 -1
  58. package/cjs/label/polygon.js +1 -1
  59. package/cjs/label/register.d.ts +1 -0
  60. package/cjs/label/register.js +8 -4
  61. package/cjs/label/register.js.map +1 -1
  62. package/cjs/label-item/label-item.d.ts +9 -20
  63. package/cjs/label-item/label-item.js +1 -103
  64. package/cjs/label-item/label-item.js.map +1 -1
  65. package/cjs/marker/config.d.ts +0 -18
  66. package/cjs/marker/config.js +1 -19
  67. package/cjs/marker/config.js.map +1 -1
  68. package/cjs/marker/point.d.ts +0 -18
  69. package/cjs/marker/point.js +16 -19
  70. package/cjs/marker/point.js.map +1 -1
  71. package/cjs/marker/register.js +8 -7
  72. package/cjs/marker/register.js.map +1 -1
  73. package/cjs/marker/type.d.ts +4 -11
  74. package/cjs/marker/type.js.map +1 -1
  75. package/cjs/poptip/poptip.d.ts +0 -9
  76. package/cjs/poptip/poptip.js +1 -37
  77. package/cjs/poptip/poptip.js.map +1 -1
  78. package/cjs/weather/weather-box.d.ts +1 -1
  79. package/cjs/weather/weather-box.js +5 -5
  80. package/cjs/weather/weather-box.js.map +1 -1
  81. package/dist/index.es.js +4132 -2614
  82. package/es/animation/animate-component.d.ts +22 -0
  83. package/es/animation/animate-component.js +21 -0
  84. package/es/animation/animate-component.js.map +1 -0
  85. package/es/animation/axis-animate.d.ts +10 -0
  86. package/es/animation/axis-animate.js +60 -0
  87. package/es/animation/axis-animate.js.map +1 -0
  88. package/es/animation/label-animate.d.ts +10 -0
  89. package/es/animation/label-animate.js +70 -0
  90. package/es/animation/label-animate.js.map +1 -0
  91. package/es/axis/animate/config.d.ts +6 -0
  92. package/es/axis/animate/config.js +6 -0
  93. package/es/axis/animate/config.js.map +1 -0
  94. package/es/axis/animate/group-transition.d.ts +2 -1
  95. package/es/axis/animate/group-transition.js +3 -1
  96. package/es/axis/animate/group-transition.js.map +1 -1
  97. package/es/axis/base.d.ts +9 -4
  98. package/es/axis/base.js +75 -9
  99. package/es/axis/base.js.map +1 -1
  100. package/es/axis/line.js.map +1 -1
  101. package/es/axis/register.js +3 -1
  102. package/es/axis/register.js.map +1 -1
  103. package/es/axis/tick-data/continuous.js +15 -13
  104. package/es/axis/tick-data/continuous.js.map +1 -1
  105. package/es/axis/tick-data/discrete/linear.js +22 -14
  106. package/es/axis/tick-data/discrete/linear.js.map +1 -1
  107. package/es/axis/tick-data/util.js +15 -9
  108. package/es/axis/tick-data/util.js.map +1 -1
  109. package/es/axis/type.d.ts +4 -0
  110. package/es/axis/type.js.map +1 -1
  111. package/es/brush/brush.d.ts +1 -5
  112. package/es/brush/brush.js +11 -13
  113. package/es/brush/brush.js.map +1 -1
  114. package/es/brush/config.js +1 -2
  115. package/es/brush/type.js +2 -1
  116. package/es/core/base.d.ts +5 -1
  117. package/es/core/base.js +11 -0
  118. package/es/core/base.js.map +1 -1
  119. package/es/crosshair/rect.js +1 -2
  120. package/es/crosshair/type.js +2 -1
  121. package/es/data-zoom/data-zoom.d.ts +1 -5
  122. package/es/data-zoom/data-zoom.js +7 -8
  123. package/es/data-zoom/data-zoom.js.map +1 -1
  124. package/es/index.d.ts +1 -1
  125. package/es/index.js +1 -1
  126. package/es/index.js.map +1 -1
  127. package/es/indicator/register.js +1 -2
  128. package/es/jsx/index.js +2 -1
  129. package/es/label/animate/animate.d.ts +1 -12
  130. package/es/label/animate/animate.js +0 -82
  131. package/es/label/animate/animate.js.map +1 -1
  132. package/es/label/arc.js +6 -6
  133. package/es/label/arc.js.map +1 -1
  134. package/es/label/base.d.ts +6 -5
  135. package/es/label/base.js +90 -108
  136. package/es/label/base.js.map +1 -1
  137. package/es/label/index.js +1 -1
  138. package/es/label/line.js +1 -1
  139. package/es/label/polygon.js +1 -1
  140. package/es/label/register.d.ts +1 -0
  141. package/es/label/register.js +7 -1
  142. package/es/label/register.js.map +1 -1
  143. package/es/label-item/label-item.d.ts +9 -20
  144. package/es/label-item/label-item.js +0 -104
  145. package/es/label-item/label-item.js.map +1 -1
  146. package/es/marker/config.d.ts +0 -18
  147. package/es/marker/config.js +1 -19
  148. package/es/marker/config.js.map +1 -1
  149. package/es/marker/point.d.ts +0 -18
  150. package/es/marker/point.js +16 -19
  151. package/es/marker/point.js.map +1 -1
  152. package/es/marker/register.js +8 -6
  153. package/es/marker/register.js.map +1 -1
  154. package/es/marker/type.d.ts +4 -11
  155. package/es/marker/type.js.map +1 -1
  156. package/es/poptip/poptip.d.ts +0 -9
  157. package/es/poptip/poptip.js +0 -38
  158. package/es/poptip/poptip.js.map +1 -1
  159. package/es/weather/weather-box.d.ts +1 -1
  160. package/es/weather/weather-box.js +1 -1
  161. package/es/weather/weather-box.js.map +1 -1
  162. package/package.json +8 -7
package/es/label/base.js CHANGED
@@ -8,12 +8,10 @@ var __rest = this && this.__rest || function(s, e) {
8
8
  return t;
9
9
  };
10
10
 
11
- import { graphicCreator, AttributeUpdateType, IContainPointMode, CustomPath2D } from "@visactor/vrender-core";
11
+ import { graphicCreator, AttributeUpdateType, CustomPath2D } from "@visactor/vrender-core";
12
12
 
13
13
  import { isFunction, isEmpty, isValid, isString, merge, isRectIntersect, isNil, isArray, isObject, pointInRect } from "@visactor/vutils";
14
14
 
15
- import { AbstractComponent } from "../core/base";
16
-
17
15
  import { labelSmartInvert, contrastAccessibilityChecker, smartInvertStrategy } from "../util/label-smartInvert";
18
16
 
19
17
  import { createTextGraphicByType, getMarksByName, getNoneGroupMarksByName, traverseGroup } from "../util";
@@ -22,7 +20,7 @@ import { StateValue } from "../constant";
22
20
 
23
21
  import { bitmapTool, boundToRange, canPlace, clampText, place } from "./overlap";
24
22
 
25
- import { DefaultLabelAnimation, getAnimationAttributes, updateAnimation } from "./animate/animate";
23
+ import { DefaultLabelAnimation } from "./animate/animate";
26
24
 
27
25
  import { connectLineBetweenBounds, getPointsOfLineArea } from "./util";
28
26
 
@@ -30,9 +28,11 @@ import { loadLabelComponent } from "./register";
30
28
 
31
29
  import { shiftY } from "./overlap/shiftY";
32
30
 
31
+ import { AnimateComponent } from "../animation/animate-component";
32
+
33
33
  loadLabelComponent();
34
34
 
35
- export class LabelBase extends AbstractComponent {
35
+ export class LabelBase extends AnimateComponent {
36
36
  setBitmap(bitmap) {
37
37
  this._bitmap = bitmap;
38
38
  }
@@ -88,13 +88,17 @@ export class LabelBase extends AbstractComponent {
88
88
  baseMark: baseMark
89
89
  }, attrs, new CustomPath2D);
90
90
  }
91
- return baseMark && baseMark.attribute.fill && lineGraphic.setAttribute("stroke", baseMark.attribute.fill),
91
+ return baseMark && baseMark.getAttributes(!0).fill && lineGraphic.setAttribute("stroke", baseMark.getAttributes(!0).fill),
92
92
  this.attribute.line && !isEmpty(this.attribute.line.style) && lineGraphic.setAttributes(this.attribute.line.style),
93
93
  this._setStatesOfLabelLine(lineGraphic), lineGraphic;
94
94
  }
95
95
  }
96
96
  render() {
97
97
  if (this._prepare(), isNil(this._idToGraphic) || this._isCollectionBase && isNil(this._idToPoint)) return;
98
+ const markAttributeList = [];
99
+ !1 !== this._enableAnimation && this._baseMarks.forEach((mark => {
100
+ markAttributeList.push(mark.attribute), mark.initAttributes(mark.getAttributes(!0));
101
+ }));
98
102
  const {overlap: overlap, smartInvert: smartInvert, dataFilter: dataFilter, customLayoutFunc: customLayoutFunc, customOverlapFunc: customOverlapFunc} = this.attribute;
99
103
  let data = this.attribute.data;
100
104
  if (isFunction(dataFilter) && (data = dataFilter(data)), data && data.length) {
@@ -107,7 +111,10 @@ export class LabelBase extends AbstractComponent {
107
111
  isFunction(this.attribute.onAfterOverlapping) && this.attribute.onAfterOverlapping(labels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null, this),
108
112
  labels && labels.length && labels.forEach((label => {
109
113
  this._bindEvent(label), this._setStatesOfText(label);
110
- })), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels);
114
+ })), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels),
115
+ !1 !== this._enableAnimation && this._baseMarks.forEach(((mark, index) => {
116
+ mark.initAttributes(markAttributeList[index]);
117
+ }));
111
118
  }
112
119
  _bindEvent(target) {
113
120
  if (this.attribute.disableTriggerEvent) return;
@@ -160,18 +167,7 @@ export class LabelBase extends AbstractComponent {
160
167
  textData && baseMark && (isValid(textData.id) || (textData.id = `vrender-component-${this.name}-${i}`),
161
168
  this._idToGraphic.set(textData.id, baseMark));
162
169
  }
163
- if (!1 !== this.attribute.animation) {
164
- const {animation: animation, animationEnter: animationEnter, animationExit: animationExit, animationUpdate: animationUpdate} = this.attribute, animationCfg = isObject(animation) ? animation : {};
165
- this._animationConfig = {
166
- enter: !1 !== animationEnter && merge({}, DefaultLabelAnimation, animationCfg, null != animationEnter ? animationEnter : {}),
167
- exit: !1 !== animationExit && merge({}, DefaultLabelAnimation, animationCfg, null != animationExit ? animationExit : {}),
168
- update: !1 !== animationUpdate && (isArray(animationUpdate) ? animationUpdate : merge({}, DefaultLabelAnimation, animationCfg, null != animationUpdate ? animationUpdate : {}))
169
- };
170
- } else this._animationConfig = {
171
- enter: !1,
172
- exit: !1,
173
- update: !1
174
- };
170
+ this._prepareAnimate(DefaultLabelAnimation);
175
171
  }
176
172
  }
177
173
  getRelatedGraphic(item) {
@@ -182,8 +178,8 @@ export class LabelBase extends AbstractComponent {
182
178
  for (let i = 0; i < data.length; i++) {
183
179
  const textData = data[i], baseMark = this.getRelatedGraphic(textData);
184
180
  if (!baseMark) continue;
185
- const labelAttribute = Object.assign(Object.assign({
186
- fill: this._isCollectionBase ? isArray(baseMark.attribute.stroke) ? baseMark.attribute.stroke.find((entry => !!entry && !0 !== entry)) : baseMark.attribute.stroke : baseMark.attribute.fill
181
+ const graphicAttribute = baseMark.getAttributes(!0), labelAttribute = Object.assign(Object.assign({
182
+ fill: this._isCollectionBase ? isArray(graphicAttribute.stroke) ? graphicAttribute.stroke.find((entry => !!entry && !0 !== entry)) : graphicAttribute.stroke : graphicAttribute.fill
187
183
  }, textStyle), textData), text = this._createLabelText(labelAttribute);
188
184
  labels.push(text);
189
185
  }
@@ -335,8 +331,15 @@ export class LabelBase extends AbstractComponent {
335
331
  if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
336
332
  }
337
333
  getGraphicBounds(graphic, point = {}, position) {
334
+ var _a;
338
335
  if (graphic) {
339
- if (!1 !== graphic.attribute.visible) return graphic.AABBBounds;
336
+ if (!1 !== graphic.attribute.visible) {
337
+ if (null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) {
338
+ const clonedGraphic = graphic.clone();
339
+ return Object.assign(clonedGraphic.attribute, graphic.getAttributes(!0)), clonedGraphic.AABBBounds;
340
+ }
341
+ return graphic.AABBBounds;
342
+ }
340
343
  const {x: x, y: y} = graphic.attribute;
341
344
  return {
342
345
  x1: x,
@@ -369,64 +372,88 @@ export class LabelBase extends AbstractComponent {
369
372
  var _a;
370
373
  const relatedGraphic = this.getRelatedGraphic(text.attribute), textKey = this._isCollectionBase ? text.attribute.id : relatedGraphic, state = (null == prevTextMap ? void 0 : prevTextMap.get(textKey)) ? "update" : "enter";
371
374
  let labelLine;
372
- if (showLabelLine && (labelLine = this._createLabelLine(text, relatedGraphic)),
373
- syncState && this.updateStatesOfLabels([ labelLine ? {
374
- text: text,
375
- labelLine: labelLine
376
- } : {
377
- text: text
378
- } ], null !== (_a = relatedGraphic.currentStates) && void 0 !== _a ? _a : []), "enter" === state) texts.push(text),
379
- currentTextMap.set(textKey, labelLine ? {
375
+ showLabelLine && (labelLine = this._createLabelLine(text, relatedGraphic));
376
+ const currentLabel = labelLine ? {
380
377
  text: text,
381
378
  labelLine: labelLine
382
379
  } : {
383
380
  text: text
384
- }), this._addLabel({
385
- text: text,
386
- labelLine: labelLine
387
- }, texts, labelLines, index); else if ("update" === state) {
381
+ };
382
+ if (syncState && this.updateStatesOfLabels([ currentLabel ], null !== (_a = relatedGraphic.currentStates) && void 0 !== _a ? _a : []),
383
+ "enter" === state) texts.push(text), currentTextMap.set(textKey, currentLabel),
384
+ this._addLabel(currentLabel, texts, labelLines, index); else if ("update" === state) {
388
385
  const prevLabel = prevTextMap.get(textKey);
389
- prevTextMap.delete(textKey), currentTextMap.set(textKey, prevLabel), this._updateLabel(prevLabel, {
390
- text: text,
391
- labelLine: labelLine
392
- });
386
+ prevTextMap.delete(textKey), currentTextMap.set(textKey, prevLabel), this._updateLabel(prevLabel, currentLabel);
393
387
  }
394
388
  })), this._removeLabel(prevTextMap), this._graphicToText = currentTextMap;
395
389
  }
390
+ runEnterAnimation(text, labelLine) {
391
+ if (!1 === this._enableAnimation || !this._animationConfig.enter) return;
392
+ const relatedGraphic = this.getRelatedGraphic(text.attribute), {enter: enter} = this._animationConfig;
393
+ [ text, labelLine ].filter(Boolean).forEach((item => item.applyAnimationState([ "enter" ], [ {
394
+ name: "enter",
395
+ animation: Object.assign(Object.assign({}, enter), {
396
+ type: "labelEnter",
397
+ selfOnly: !0,
398
+ customParameters: {
399
+ relatedGraphic: relatedGraphic,
400
+ relatedGraphics: this._idToGraphic,
401
+ config: Object.assign(Object.assign({}, enter), {
402
+ type: item === text ? enter.type : "fadeIn"
403
+ })
404
+ }
405
+ })
406
+ } ])));
407
+ }
408
+ _runUpdateAnimation(prevLabel, currentLabel) {
409
+ const {text: prevText, labelLine: prevLabelLine} = prevLabel, {text: curText, labelLine: curLabelLine} = currentLabel;
410
+ prevText.applyAnimationState([ "update" ], [ {
411
+ name: "update",
412
+ animation: Object.assign(Object.assign({
413
+ type: "labelUpdate"
414
+ }, this._animationConfig.update), {
415
+ customParameters: {
416
+ prevText: prevText,
417
+ curText: curText,
418
+ prevLabelLine: prevLabelLine,
419
+ curLabelLine: curLabelLine
420
+ }
421
+ })
422
+ } ]);
423
+ }
424
+ _syncStateWithRelatedGraphic(relatedGraphic) {
425
+ this.attribute.syncState && relatedGraphic && relatedGraphic.on("afterStateUpdate", this._handleRelatedGraphicSetState);
426
+ }
396
427
  _addLabel(label, texts, labelLines, index) {
397
428
  const {text: text, labelLine: labelLine} = label, relatedGraphic = this.getRelatedGraphic(text.attribute);
398
- if (this._syncStateWithRelatedGraphic(relatedGraphic), !1 !== this._enableAnimation && !1 !== this._animationConfig.enter) {
399
- if (relatedGraphic) {
400
- const {from: from, to: to} = getAnimationAttributes(text.attribute, "fadeIn");
401
- text && this.add(text), labelLine && (labelLines.push(labelLine), this.add(labelLine)),
402
- this._animationConfig.enter.duration > 0 && relatedGraphic.once("animate-bind", (a => {
403
- text.setAttributes(from), labelLine && labelLine.setAttributes(from);
404
- const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, labelLine, labelLines, index, relatedGraphic, to, this._animationConfig.enter);
405
- relatedGraphic.on("afterAttributeUpdate", listener);
406
- }));
407
- }
408
- } else text && this.add(text), labelLine && this.add(labelLine);
429
+ this._syncStateWithRelatedGraphic(relatedGraphic), text && this.add(text), labelLine && this.add(labelLine),
430
+ this.runEnterAnimation(text, labelLine);
409
431
  }
410
432
  _updateLabel(prevLabel, currentLabel) {
411
433
  const {text: prevText, labelLine: prevLabelLine} = prevLabel, {text: curText, labelLine: curLabelLine} = currentLabel;
412
- if (!1 !== this._enableAnimation && !1 !== this._animationConfig.update) {
413
- const {duration: duration, easing: easing} = this._animationConfig.update;
414
- updateAnimation(prevText, curText, this._animationConfig.update), prevLabelLine && curLabelLine && prevLabel.labelLine.animate().to(curLabelLine.attribute, duration, easing);
415
- } else prevLabel.text.setAttributes(curText.attribute), prevLabelLine && curLabelLine && prevLabel.labelLine.setAttributes(curLabelLine.attribute);
434
+ !1 === this._enableAnimation || !1 === this._animationConfig.update ? (prevLabel.text.setAttributes(curText.attribute),
435
+ prevLabelLine && curLabelLine && prevLabel.labelLine.setAttributes(curLabelLine.attribute)) : this._runUpdateAnimation(prevLabel, currentLabel);
416
436
  }
417
437
  _removeLabel(textMap) {
418
438
  const removeLabelAndLine = label => {
419
439
  this.removeChild(label.text), label.labelLine && this.removeChild(label.labelLine);
420
440
  };
421
- if (!1 !== this._enableAnimation && !1 !== this._animationConfig.exit) {
422
- const {duration: duration, easing: easing} = this._animationConfig.exit;
423
- textMap.forEach((label => {
424
- var _a;
425
- null === (_a = label.text) || void 0 === _a || _a.animate().to(getAnimationAttributes(label.text.attribute, "fadeOut").to, duration, easing).onEnd((() => {
426
- removeLabelAndLine(label);
427
- }));
428
- }));
429
- } else textMap.forEach((label => {
441
+ !1 !== this._enableAnimation && !1 !== this._animationConfig.exit ? textMap.forEach((label => {
442
+ var _a;
443
+ label.text.applyAnimationState([ "exit" ], [ {
444
+ name: "exit",
445
+ animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
446
+ type: "fadeOut"
447
+ })
448
+ } ], (() => {
449
+ removeLabelAndLine(label);
450
+ })), null === (_a = label.labelLine) || void 0 === _a || _a.applyAnimationState([ "exit" ], [ {
451
+ name: "exit",
452
+ animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
453
+ type: "fadeOut"
454
+ })
455
+ } ], (() => {}));
456
+ })) : textMap.forEach((label => {
430
457
  removeLabelAndLine(label);
431
458
  }));
432
459
  }
@@ -435,51 +462,6 @@ export class LabelBase extends AbstractComponent {
435
462
  label && (label.text && label.text.useStates(currentStates), label.labelLine && label.labelLine.useStates(currentStates));
436
463
  }));
437
464
  }
438
- _syncStateWithRelatedGraphic(relatedGraphic) {
439
- this.attribute.syncState && relatedGraphic && relatedGraphic.on("afterAttributeUpdate", this._handleRelatedGraphicSetState);
440
- }
441
- _afterRelatedGraphicAttributeUpdate(text, texts, labelLine, labelLines, index, relatedGraphic, to, {mode: mode, duration: duration, easing: easing, delay: delay}) {
442
- const listener = event => {
443
- var _a, _b, _c;
444
- const {detail: detail} = event;
445
- if (!detail) return {};
446
- const step = null === (_a = detail.animationState) || void 0 === _a ? void 0 : _a.step;
447
- if (!(detail.type === AttributeUpdateType.ANIMATE_UPDATE && step && !("wait" === step.type && null == (null === (_b = step.prev) || void 0 === _b ? void 0 : _b.type)))) return {};
448
- if (detail.type === AttributeUpdateType.ANIMATE_END) return text.setAttributes(to),
449
- void (labelLine && labelLine.setAttributes(to));
450
- const onStart = () => {
451
- relatedGraphic && (relatedGraphic.onAnimateBind = void 0, relatedGraphic.removeEventListener("afterAttributeUpdate", listener));
452
- };
453
- switch (mode) {
454
- case "after":
455
- detail.animationState.end && (text.animate({
456
- onStart: onStart
457
- }).wait(delay).to(to, duration, easing), labelLine && labelLine.animate().wait(delay).to(to, duration, easing));
458
- break;
459
-
460
- case "after-all":
461
- index === texts.length - 1 && detail.animationState.end && (texts.forEach((t => {
462
- t.animate({
463
- onStart: onStart
464
- }).wait(delay).to(to, duration, easing);
465
- })), labelLines.forEach((t => {
466
- t.animate().wait(delay).to(to, duration, easing);
467
- })));
468
- break;
469
-
470
- default:
471
- if (this._isCollectionBase) {
472
- const point = this._idToPoint.get(text.attribute.id);
473
- !point || text.animates && text.animates.has("label-animate") || !relatedGraphic.containsPoint(point.x, point.y, IContainPointMode.LOCAL, null === (_c = this.stage) || void 0 === _c ? void 0 : _c.getPickerService()) || (text.animate({
474
- onStart: onStart
475
- }).wait(delay).to(to, duration, easing), labelLine && labelLine.animate().wait(delay).to(to, duration, easing));
476
- } else detail.animationState.isFirstFrameOfStep && (text.animate({
477
- onStart: onStart
478
- }).wait(delay).to(to, duration, easing), labelLine && labelLine.animate().wait(delay).to(to, duration, easing));
479
- }
480
- };
481
- return listener;
482
- }
483
465
  _smartInvert(labels) {
484
466
  var _a, _b, _c, _d, _e, _f, _g;
485
467
  const option = isObject(this.attribute.smartInvert) ? this.attribute.smartInvert : {}, {textType: textType, contrastRatiosThreshold: contrastRatiosThreshold, alternativeColors: alternativeColors, mode: mode, interactInvertType: interactInvertType} = option, fillStrategy = null !== (_a = option.fillStrategy) && void 0 !== _a ? _a : "invertBase", strokeStrategy = null !== (_b = option.strokeStrategy) && void 0 !== _b ? _b : "base", brightColor = null !== (_c = option.brightColor) && void 0 !== _c ? _c : "#ffffff", darkColor = null !== (_d = option.darkColor) && void 0 !== _d ? _d : "#000000", outsideEnable = null !== (_e = option.outsideEnable) && void 0 !== _e && _e;
@@ -487,7 +469,7 @@ export class LabelBase extends AbstractComponent {
487
469
  const label = labels[i];
488
470
  if (!label) continue;
489
471
  const baseMark = this.getRelatedGraphic(label.attribute);
490
- let backgroundColor = baseMark.attribute.fill, foregroundColor = label.attribute.fill;
472
+ let backgroundColor = baseMark.getAttributes(!0).fill, foregroundColor = label.attribute.fill;
491
473
  if (isObject(backgroundColor) && backgroundColor.gradient) {
492
474
  const firstStopColor = null === (_g = null === (_f = backgroundColor.stops) || void 0 === _f ? void 0 : _f[0]) || void 0 === _g ? void 0 : _g.color;
493
475
  firstStopColor && (backgroundColor = firstStopColor, foregroundColor = firstStopColor);