@visactor/vrender-components 0.22.15-alpha.1 → 0.22.16

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 (140) hide show
  1. package/cjs/axis/animate/group-transition.d.ts +1 -2
  2. package/cjs/axis/animate/group-transition.js +2 -2
  3. package/cjs/axis/animate/group-transition.js.map +1 -1
  4. package/cjs/axis/base.d.ts +4 -9
  5. package/cjs/axis/base.js +5 -70
  6. package/cjs/axis/base.js.map +1 -1
  7. package/cjs/axis/line.js.map +1 -1
  8. package/cjs/axis/register.js +2 -2
  9. package/cjs/axis/register.js.map +1 -1
  10. package/cjs/axis/type.d.ts +0 -4
  11. package/cjs/axis/type.js.map +1 -1
  12. package/cjs/axis/util.js +1 -2
  13. package/cjs/brush/brush.js.map +1 -1
  14. package/cjs/brush/config.js +2 -1
  15. package/cjs/crosshair/polygon-sector.js +1 -2
  16. package/cjs/crosshair/rect.js +2 -1
  17. package/cjs/data-zoom/data-zoom.js.map +1 -1
  18. package/cjs/index.d.ts +1 -1
  19. package/cjs/index.js +1 -1
  20. package/cjs/index.js.map +1 -1
  21. package/cjs/indicator/register.js +2 -1
  22. package/cjs/jsx/index.js +1 -2
  23. package/cjs/label/animate/animate.d.ts +12 -1
  24. package/cjs/label/animate/animate.js +84 -1
  25. package/cjs/label/animate/animate.js.map +1 -1
  26. package/cjs/label/arc.js +6 -6
  27. package/cjs/label/arc.js.map +1 -1
  28. package/cjs/label/base.d.ts +6 -6
  29. package/cjs/label/base.js +132 -102
  30. package/cjs/label/base.js.map +1 -1
  31. package/cjs/label/index.js +1 -1
  32. package/cjs/label/line.js +1 -1
  33. package/cjs/label/polygon.js +1 -1
  34. package/cjs/label/register.d.ts +0 -1
  35. package/cjs/label/register.js +4 -8
  36. package/cjs/label/register.js.map +1 -1
  37. package/cjs/label/type.d.ts +1 -0
  38. package/cjs/label/type.js.map +1 -1
  39. package/cjs/label-item/label-item.d.ts +20 -9
  40. package/cjs/label-item/label-item.js +103 -1
  41. package/cjs/label-item/label-item.js.map +1 -1
  42. package/cjs/marker/config.d.ts +18 -0
  43. package/cjs/marker/config.js +19 -1
  44. package/cjs/marker/config.js.map +1 -1
  45. package/cjs/marker/point.d.ts +18 -0
  46. package/cjs/marker/point.js +19 -16
  47. package/cjs/marker/point.js.map +1 -1
  48. package/cjs/marker/register.js +7 -8
  49. package/cjs/marker/register.js.map +1 -1
  50. package/cjs/marker/type.d.ts +11 -4
  51. package/cjs/marker/type.js.map +1 -1
  52. package/cjs/poptip/poptip.d.ts +9 -0
  53. package/cjs/poptip/poptip.js +37 -1
  54. package/cjs/poptip/poptip.js.map +1 -1
  55. package/cjs/weather/weather-box.d.ts +1 -1
  56. package/cjs/weather/weather-box.js +5 -5
  57. package/cjs/weather/weather-box.js.map +1 -1
  58. package/dist/index.es.js +13414 -14743
  59. package/es/axis/animate/group-transition.d.ts +1 -2
  60. package/es/axis/animate/group-transition.js +1 -3
  61. package/es/axis/animate/group-transition.js.map +1 -1
  62. package/es/axis/base.d.ts +4 -9
  63. package/es/axis/base.js +9 -75
  64. package/es/axis/base.js.map +1 -1
  65. package/es/axis/line.js.map +1 -1
  66. package/es/axis/register.js +1 -3
  67. package/es/axis/register.js.map +1 -1
  68. package/es/axis/type.d.ts +0 -4
  69. package/es/axis/type.js.map +1 -1
  70. package/es/axis/util.js +1 -2
  71. package/es/brush/brush.js.map +1 -1
  72. package/es/brush/config.js +2 -1
  73. package/es/crosshair/polygon-sector.js +1 -2
  74. package/es/crosshair/rect.js +2 -1
  75. package/es/data-zoom/data-zoom.js.map +1 -1
  76. package/es/index.d.ts +1 -1
  77. package/es/index.js +1 -1
  78. package/es/index.js.map +1 -1
  79. package/es/indicator/register.js +2 -1
  80. package/es/jsx/index.js +1 -2
  81. package/es/label/animate/animate.d.ts +12 -1
  82. package/es/label/animate/animate.js +82 -0
  83. package/es/label/animate/animate.js.map +1 -1
  84. package/es/label/arc.js +6 -6
  85. package/es/label/arc.js.map +1 -1
  86. package/es/label/base.d.ts +6 -6
  87. package/es/label/base.js +132 -105
  88. package/es/label/base.js.map +1 -1
  89. package/es/label/index.js +1 -1
  90. package/es/label/line.js +1 -1
  91. package/es/label/polygon.js +1 -1
  92. package/es/label/register.d.ts +0 -1
  93. package/es/label/register.js +1 -7
  94. package/es/label/register.js.map +1 -1
  95. package/es/label/type.d.ts +1 -0
  96. package/es/label/type.js.map +1 -1
  97. package/es/label-item/label-item.d.ts +20 -9
  98. package/es/label-item/label-item.js +104 -0
  99. package/es/label-item/label-item.js.map +1 -1
  100. package/es/marker/config.d.ts +18 -0
  101. package/es/marker/config.js +19 -1
  102. package/es/marker/config.js.map +1 -1
  103. package/es/marker/point.d.ts +18 -0
  104. package/es/marker/point.js +19 -16
  105. package/es/marker/point.js.map +1 -1
  106. package/es/marker/register.js +6 -8
  107. package/es/marker/register.js.map +1 -1
  108. package/es/marker/type.d.ts +11 -4
  109. package/es/marker/type.js.map +1 -1
  110. package/es/poptip/poptip.d.ts +9 -0
  111. package/es/poptip/poptip.js +38 -0
  112. package/es/poptip/poptip.js.map +1 -1
  113. package/es/weather/weather-box.d.ts +1 -1
  114. package/es/weather/weather-box.js +1 -1
  115. package/es/weather/weather-box.js.map +1 -1
  116. package/package.json +8 -9
  117. package/cjs/animation/animate-component.d.ts +0 -22
  118. package/cjs/animation/animate-component.js +0 -29
  119. package/cjs/animation/animate-component.js.map +0 -1
  120. package/cjs/animation/axis-animate.d.ts +0 -10
  121. package/cjs/animation/axis-animate.js +0 -71
  122. package/cjs/animation/axis-animate.js.map +0 -1
  123. package/cjs/animation/label-animate.d.ts +0 -10
  124. package/cjs/animation/label-animate.js +0 -81
  125. package/cjs/animation/label-animate.js.map +0 -1
  126. package/cjs/axis/animate/config.d.ts +0 -6
  127. package/cjs/axis/animate/config.js +0 -10
  128. package/cjs/axis/animate/config.js.map +0 -1
  129. package/es/animation/animate-component.d.ts +0 -22
  130. package/es/animation/animate-component.js +0 -21
  131. package/es/animation/animate-component.js.map +0 -1
  132. package/es/animation/axis-animate.d.ts +0 -10
  133. package/es/animation/axis-animate.js +0 -60
  134. package/es/animation/axis-animate.js.map +0 -1
  135. package/es/animation/label-animate.d.ts +0 -10
  136. package/es/animation/label-animate.js +0 -70
  137. package/es/animation/label-animate.js.map +0 -1
  138. package/es/axis/animate/config.d.ts +0 -6
  139. package/es/axis/animate/config.js +0 -6
  140. package/es/axis/animate/config.js.map +0 -1
package/es/label/base.js CHANGED
@@ -8,10 +8,12 @@ var __rest = this && this.__rest || function(s, e) {
8
8
  return t;
9
9
  };
10
10
 
11
- import { graphicCreator, AttributeUpdateType, CustomPath2D } from "@visactor/vrender-core";
11
+ import { graphicCreator, AttributeUpdateType, IContainPointMode, 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
+
15
17
  import { labelSmartInvert, contrastAccessibilityChecker, smartInvertStrategy } from "../util/label-smartInvert";
16
18
 
17
19
  import { createTextGraphicByType, getMarksByName, getNoneGroupMarksByName, traverseGroup } from "../util";
@@ -20,7 +22,7 @@ import { StateValue } from "../constant";
20
22
 
21
23
  import { bitmapTool, boundToRange, canPlace, clampText, place } from "./overlap";
22
24
 
23
- import { DefaultLabelAnimation } from "./animate/animate";
25
+ import { DefaultLabelAnimation, getAnimationAttributes, updateAnimation } from "./animate/animate";
24
26
 
25
27
  import { connectLineBetweenBounds, getPointsOfLineArea } from "./util";
26
28
 
@@ -28,11 +30,9 @@ import { loadLabelComponent } from "./register";
28
30
 
29
31
  import { shiftY } from "./overlap/shiftY";
30
32
 
31
- import { AnimateComponent } from "../animation/animate-component";
32
-
33
33
  loadLabelComponent();
34
34
 
35
- export class LabelBase extends AnimateComponent {
35
+ export class LabelBase extends AbstractComponent {
36
36
  setBitmap(bitmap) {
37
37
  this._bitmap = bitmap;
38
38
  }
@@ -88,17 +88,13 @@ export class LabelBase extends AnimateComponent {
88
88
  baseMark: baseMark
89
89
  }, attrs, new CustomPath2D);
90
90
  }
91
- return baseMark && baseMark.getAttributes(!0).fill && lineGraphic.setAttribute("stroke", baseMark.getAttributes(!0).fill),
91
+ return baseMark && baseMark.attribute.fill && lineGraphic.setAttribute("stroke", baseMark.attribute.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
- }));
102
98
  const {overlap: overlap, smartInvert: smartInvert, dataFilter: dataFilter, customLayoutFunc: customLayoutFunc, customOverlapFunc: customOverlapFunc} = this.attribute;
103
99
  let data = this.attribute.data;
104
100
  if (isFunction(dataFilter) && (data = dataFilter(data)), data && data.length) {
@@ -111,10 +107,7 @@ export class LabelBase extends AnimateComponent {
111
107
  isFunction(this.attribute.onAfterOverlapping) && this.attribute.onAfterOverlapping(labels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null, this),
112
108
  labels && labels.length && labels.forEach((label => {
113
109
  this._bindEvent(label), this._setStatesOfText(label);
114
- })), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels),
115
- !1 !== this._enableAnimation && this._baseMarks.forEach(((mark, index) => {
116
- mark.initAttributes(markAttributeList[index]);
117
- }));
110
+ })), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels);
118
111
  }
119
112
  _bindEvent(target) {
120
113
  if (this.attribute.disableTriggerEvent) return;
@@ -167,7 +160,18 @@ export class LabelBase extends AnimateComponent {
167
160
  textData && baseMark && (isValid(textData.id) || (textData.id = `vrender-component-${this.name}-${i}`),
168
161
  this._idToGraphic.set(textData.id, baseMark));
169
162
  }
170
- this._prepareAnimate(DefaultLabelAnimation);
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
+ };
171
175
  }
172
176
  }
173
177
  getRelatedGraphic(item) {
@@ -178,8 +182,8 @@ export class LabelBase extends AnimateComponent {
178
182
  for (let i = 0; i < data.length; i++) {
179
183
  const textData = data[i], baseMark = this.getRelatedGraphic(textData);
180
184
  if (!baseMark) continue;
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
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
183
187
  }, textStyle), textData), text = this._createLabelText(labelAttribute);
184
188
  labels.push(text);
185
189
  }
@@ -217,13 +221,15 @@ export class LabelBase extends AnimateComponent {
217
221
  }
218
222
  _overlapGlobal(labels, option, bmpTool, bitmap) {
219
223
  let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity && this.isMarkInsideRect(this.getRelatedGraphic(label.attribute), bmpTool)));
220
- const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, overlapPadding: overlapPadding, strategy: strategy} = option;
221
- if (clampForce) for (let i = 0; i < result.length; i++) {
224
+ const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, hideOnOverflow: hideOnOverflow = !1, overlapPadding: overlapPadding, strategy: strategy} = option;
225
+ if (clampForce || hideOnOverflow) for (let i = 0; i < result.length; i++) {
222
226
  const text = labels[i], {dx: dx = 0, dy: dy = 0} = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
223
- 0 === dx && 0 === dy || (text.setAttributes({
227
+ 0 === dx && 0 === dy || (hideOnOverflow ? text.setAttributes({
228
+ visible: !1
229
+ }) : (text.setAttributes({
224
230
  x: text.attribute.x + dx,
225
231
  y: text.attribute.y + dy
226
- }), text._isClamped = !0);
232
+ }), text._isClamped = !0));
227
233
  }
228
234
  result = shiftY(result, Object.assign(Object.assign({
229
235
  maxY: bmpTool.height
@@ -236,9 +242,9 @@ export class LabelBase extends AnimateComponent {
236
242
  for (let i = 0; i < result.length; i++) {
237
243
  const text = result[i], bounds = text.AABBBounds, range = boundToRange(bmpTool, bounds, !0);
238
244
  if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) bitmap.setRange(range); else {
239
- if (clampForce) {
240
- if (this._processClampForce(text, bmpTool, bitmap, overlapPadding)) continue;
241
- }
245
+ if (hideOnOverflow) {
246
+ if (this._processHideOnOverflow(text, bmpTool)) continue;
247
+ } else if (clampForce && this._processClampForce(text, bmpTool, bitmap, overlapPadding)) continue;
242
248
  hideOnHit ? text.setAttributes({
243
249
  visible: !1
244
250
  }) : bitmap.setRange(range);
@@ -246,6 +252,12 @@ export class LabelBase extends AnimateComponent {
246
252
  }
247
253
  return result;
248
254
  }
255
+ _processHideOnOverflow(text, bmpTool) {
256
+ const {dy: dy = 0, dx: dx = 0} = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
257
+ return 0 === dx && 0 === dy || (text.setAttributes({
258
+ visible: !1
259
+ }), !1);
260
+ }
249
261
  _processClampForce(text, bmpTool, bitmap, overlapPadding = 0) {
250
262
  const {dy: dy = 0, dx: dx = 0} = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
251
263
  if (0 === dx && 0 === dy) {
@@ -264,7 +276,7 @@ export class LabelBase extends AnimateComponent {
264
276
  }
265
277
  _overlapByStrategy(labels, option, bmpTool, bitmap) {
266
278
  var _a;
267
- const {avoidBaseMark: avoidBaseMark, strategy: strategy = [], hideOnHit: hideOnHit = !0, clampForce: clampForce = !0, avoidMarks: avoidMarks = [], overlapPadding: overlapPadding} = option, result = [], checkBounds = strategy.some((s => "bound" === s.type));
279
+ const {avoidBaseMark: avoidBaseMark, strategy: strategy = [], hideOnHit: hideOnHit = !0, clampForce: clampForce = !0, avoidMarks: avoidMarks = [], overlapPadding: overlapPadding, hideOnOverflow: hideOnOverflow = !1} = option, result = [], checkBounds = strategy.some((s => "bound" === s.type));
268
280
  avoidBaseMark && (null === (_a = this._baseMarks) || void 0 === _a || _a.forEach((mark => {
269
281
  mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, !0));
270
282
  }))), avoidMarks.length > 0 && avoidMarks.forEach((avoid => {
@@ -288,15 +300,16 @@ export class LabelBase extends AnimateComponent {
288
300
  }
289
301
  let hasPlace = !1;
290
302
  for (let j = 0; j < strategy.length; j++) if (hasPlace = place(bmpTool, bitmap, strategy[j], this.attribute, text, this._isCollectionBase ? this.getGraphicBounds(null, this._idToPoint.get(labels[i].attribute.id)) : this.getGraphicBounds(baseMark, labels[i].attribute), this.labeling),
291
- !1 !== hasPlace) {
292
- text.setAttributes({
293
- x: hasPlace.x,
294
- y: hasPlace.y
295
- }), result.push(text);
303
+ !1 !== hasPlace && (text.setAttributes({
304
+ x: hasPlace.x,
305
+ y: hasPlace.y
306
+ }), !hideOnOverflow || this._processHideOnOverflow(text, bmpTool))) {
307
+ result.push(text);
296
308
  break;
297
309
  }
298
- if (!hasPlace && clampForce) {
299
- if (this._processClampForce(text, bmpTool, bitmap, overlapPadding)) {
310
+ if (!hasPlace) {
311
+ if (hideOnOverflow && !this._processHideOnOverflow(text, bmpTool)) continue;
312
+ if (clampForce && this._processClampForce(text, bmpTool, bitmap, overlapPadding)) {
300
313
  result.push(text);
301
314
  continue;
302
315
  }
@@ -331,15 +344,8 @@ export class LabelBase extends AnimateComponent {
331
344
  if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
332
345
  }
333
346
  getGraphicBounds(graphic, point = {}, position) {
334
- var _a;
335
347
  if (graphic) {
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
- }
348
+ if (!1 !== graphic.attribute.visible) return graphic.AABBBounds;
343
349
  const {x: x, y: y} = graphic.attribute;
344
350
  return {
345
351
  x1: x,
@@ -372,88 +378,64 @@ export class LabelBase extends AnimateComponent {
372
378
  var _a;
373
379
  const relatedGraphic = this.getRelatedGraphic(text.attribute), textKey = this._isCollectionBase ? text.attribute.id : relatedGraphic, state = (null == prevTextMap ? void 0 : prevTextMap.get(textKey)) ? "update" : "enter";
374
380
  let labelLine;
375
- showLabelLine && (labelLine = this._createLabelLine(text, relatedGraphic));
376
- const currentLabel = labelLine ? {
381
+ if (showLabelLine && (labelLine = this._createLabelLine(text, relatedGraphic)),
382
+ syncState && this.updateStatesOfLabels([ labelLine ? {
377
383
  text: text,
378
384
  labelLine: labelLine
379
385
  } : {
380
386
  text: text
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) {
387
+ } ], null !== (_a = relatedGraphic.currentStates) && void 0 !== _a ? _a : []), "enter" === state) texts.push(text),
388
+ currentTextMap.set(textKey, labelLine ? {
389
+ text: text,
390
+ labelLine: labelLine
391
+ } : {
392
+ text: text
393
+ }), this._addLabel({
394
+ text: text,
395
+ labelLine: labelLine
396
+ }, texts, labelLines, index); else if ("update" === state) {
385
397
  const prevLabel = prevTextMap.get(textKey);
386
- prevTextMap.delete(textKey), currentTextMap.set(textKey, prevLabel), this._updateLabel(prevLabel, currentLabel);
398
+ prevTextMap.delete(textKey), currentTextMap.set(textKey, prevLabel), this._updateLabel(prevLabel, {
399
+ text: text,
400
+ labelLine: labelLine
401
+ });
387
402
  }
388
403
  })), this._removeLabel(prevTextMap), this._graphicToText = currentTextMap;
389
404
  }
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
- }
427
405
  _addLabel(label, texts, labelLines, index) {
428
406
  const {text: text, labelLine: labelLine} = label, relatedGraphic = this.getRelatedGraphic(text.attribute);
429
- this._syncStateWithRelatedGraphic(relatedGraphic), text && this.add(text), labelLine && this.add(labelLine),
430
- this.runEnterAnimation(text, labelLine);
407
+ if (this._syncStateWithRelatedGraphic(relatedGraphic), !1 !== this._enableAnimation && !1 !== this._animationConfig.enter) {
408
+ if (relatedGraphic) {
409
+ const {from: from, to: to} = getAnimationAttributes(text.attribute, "fadeIn");
410
+ text && this.add(text), labelLine && (labelLines.push(labelLine), this.add(labelLine)),
411
+ this._animationConfig.enter.duration > 0 && relatedGraphic.once("animate-bind", (a => {
412
+ text.setAttributes(from), labelLine && labelLine.setAttributes(from);
413
+ const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, labelLine, labelLines, index, relatedGraphic, to, this._animationConfig.enter);
414
+ relatedGraphic.on("afterAttributeUpdate", listener);
415
+ }));
416
+ }
417
+ } else text && this.add(text), labelLine && this.add(labelLine);
431
418
  }
432
419
  _updateLabel(prevLabel, currentLabel) {
433
420
  const {text: prevText, labelLine: prevLabelLine} = prevLabel, {text: curText, labelLine: curLabelLine} = currentLabel;
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);
421
+ if (!1 !== this._enableAnimation && !1 !== this._animationConfig.update) {
422
+ const {duration: duration, easing: easing} = this._animationConfig.update;
423
+ updateAnimation(prevText, curText, this._animationConfig.update), prevLabelLine && curLabelLine && prevLabel.labelLine.animate().to(curLabelLine.attribute, duration, easing);
424
+ } else prevLabel.text.setAttributes(curText.attribute), prevLabelLine && curLabelLine && prevLabel.labelLine.setAttributes(curLabelLine.attribute);
436
425
  }
437
426
  _removeLabel(textMap) {
438
427
  const removeLabelAndLine = label => {
439
428
  this.removeChild(label.text), label.labelLine && this.removeChild(label.labelLine);
440
429
  };
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
+ if (!1 !== this._enableAnimation && !1 !== this._animationConfig.exit) {
431
+ const {duration: duration, easing: easing} = this._animationConfig.exit;
432
+ textMap.forEach((label => {
433
+ var _a;
434
+ null === (_a = label.text) || void 0 === _a || _a.animate().to(getAnimationAttributes(label.text.attribute, "fadeOut").to, duration, easing).onEnd((() => {
435
+ removeLabelAndLine(label);
436
+ }));
437
+ }));
438
+ } else textMap.forEach((label => {
457
439
  removeLabelAndLine(label);
458
440
  }));
459
441
  }
@@ -462,6 +444,51 @@ export class LabelBase extends AnimateComponent {
462
444
  label && (label.text && label.text.useStates(currentStates), label.labelLine && label.labelLine.useStates(currentStates));
463
445
  }));
464
446
  }
447
+ _syncStateWithRelatedGraphic(relatedGraphic) {
448
+ this.attribute.syncState && relatedGraphic && relatedGraphic.on("afterAttributeUpdate", this._handleRelatedGraphicSetState);
449
+ }
450
+ _afterRelatedGraphicAttributeUpdate(text, texts, labelLine, labelLines, index, relatedGraphic, to, {mode: mode, duration: duration, easing: easing, delay: delay}) {
451
+ const listener = event => {
452
+ var _a, _b, _c;
453
+ const {detail: detail} = event;
454
+ if (!detail) return {};
455
+ const step = null === (_a = detail.animationState) || void 0 === _a ? void 0 : _a.step;
456
+ if (!(detail.type === AttributeUpdateType.ANIMATE_UPDATE && step && !("wait" === step.type && null == (null === (_b = step.prev) || void 0 === _b ? void 0 : _b.type)))) return {};
457
+ if (detail.type === AttributeUpdateType.ANIMATE_END) return text.setAttributes(to),
458
+ void (labelLine && labelLine.setAttributes(to));
459
+ const onStart = () => {
460
+ relatedGraphic && (relatedGraphic.onAnimateBind = void 0, relatedGraphic.removeEventListener("afterAttributeUpdate", listener));
461
+ };
462
+ switch (mode) {
463
+ case "after":
464
+ detail.animationState.end && (text.animate({
465
+ onStart: onStart
466
+ }).wait(delay).to(to, duration, easing), labelLine && labelLine.animate().wait(delay).to(to, duration, easing));
467
+ break;
468
+
469
+ case "after-all":
470
+ index === texts.length - 1 && detail.animationState.end && (texts.forEach((t => {
471
+ t.animate({
472
+ onStart: onStart
473
+ }).wait(delay).to(to, duration, easing);
474
+ })), labelLines.forEach((t => {
475
+ t.animate().wait(delay).to(to, duration, easing);
476
+ })));
477
+ break;
478
+
479
+ default:
480
+ if (this._isCollectionBase) {
481
+ const point = this._idToPoint.get(text.attribute.id);
482
+ !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({
483
+ onStart: onStart
484
+ }).wait(delay).to(to, duration, easing), labelLine && labelLine.animate().wait(delay).to(to, duration, easing));
485
+ } else detail.animationState.isFirstFrameOfStep && (text.animate({
486
+ onStart: onStart
487
+ }).wait(delay).to(to, duration, easing), labelLine && labelLine.animate().wait(delay).to(to, duration, easing));
488
+ }
489
+ };
490
+ return listener;
491
+ }
465
492
  _smartInvert(labels) {
466
493
  var _a, _b, _c, _d, _e, _f, _g;
467
494
  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;
@@ -469,7 +496,7 @@ export class LabelBase extends AnimateComponent {
469
496
  const label = labels[i];
470
497
  if (!label) continue;
471
498
  const baseMark = this.getRelatedGraphic(label.attribute);
472
- let backgroundColor = baseMark.getAttributes(!0).fill, foregroundColor = label.attribute.fill;
499
+ let backgroundColor = baseMark.attribute.fill, foregroundColor = label.attribute.fill;
473
500
  if (isObject(backgroundColor) && backgroundColor.gradient) {
474
501
  const firstStopColor = null === (_g = null === (_f = backgroundColor.stops) || void 0 === _f ? void 0 : _f[0]) || void 0 === _g ? void 0 : _g.color;
475
502
  firstStopColor && (backgroundColor = firstStopColor, foregroundColor = firstStopColor);