@visactor/vrender-components 1.1.0-alpha.9 → 1.1.1-alpha.0

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 (301) hide show
  1. package/README.md +9 -1
  2. package/cjs/animation/axis-animate.d.ts +2 -1
  3. package/cjs/animation/axis-animate.js +11 -8
  4. package/cjs/animation/axis-animate.js.map +1 -1
  5. package/cjs/animation/exit-release.d.ts +13 -0
  6. package/cjs/animation/exit-release.js +39 -0
  7. package/cjs/animation/exit-release.js.map +1 -0
  8. package/cjs/animation/label-animate.d.ts +1 -1
  9. package/cjs/animation/label-animate.js +10 -20
  10. package/cjs/animation/label-animate.js.map +1 -1
  11. package/cjs/animation/static-truth.js +1 -5
  12. package/cjs/animation/static-truth.js.map +1 -1
  13. package/cjs/axis/animate/group-transition.d.ts +3 -2
  14. package/cjs/axis/animate/group-transition.js +3 -3
  15. package/cjs/axis/animate/group-transition.js.map +1 -1
  16. package/cjs/axis/base.d.ts +6 -2
  17. package/cjs/axis/base.js +62 -8
  18. package/cjs/axis/base.js.map +1 -1
  19. package/cjs/axis/circle.js +1 -1
  20. package/cjs/axis/config.js +1 -1
  21. package/cjs/axis/constant.js +1 -1
  22. package/cjs/axis/index.js +1 -1
  23. package/cjs/axis/line.d.ts +1 -1
  24. package/cjs/axis/line.js +3 -3
  25. package/cjs/axis/line.js.map +1 -1
  26. package/cjs/axis/overlap/auto-hide.d.ts +1 -1
  27. package/cjs/axis/overlap/auto-hide.js.map +1 -1
  28. package/cjs/axis/register.js +9 -8
  29. package/cjs/axis/register.js.map +1 -1
  30. package/cjs/axis/type.js +1 -1
  31. package/cjs/axis/util.js +1 -1
  32. package/cjs/brush/brush.d.ts +4 -0
  33. package/cjs/brush/brush.js +32 -14
  34. package/cjs/brush/brush.js.map +1 -1
  35. package/cjs/brush/register.js +2 -2
  36. package/cjs/brush/register.js.map +1 -1
  37. package/cjs/brush/type.js +1 -2
  38. package/cjs/checkbox/register.js +3 -3
  39. package/cjs/checkbox/register.js.map +1 -1
  40. package/cjs/core/base.d.ts +2 -2
  41. package/cjs/core/base.js +3 -3
  42. package/cjs/core/base.js.map +1 -1
  43. package/cjs/core/type.d.ts +7 -0
  44. package/cjs/core/type.js.map +1 -1
  45. package/cjs/crosshair/polygon.js +2 -1
  46. package/cjs/crosshair/register.js +7 -7
  47. package/cjs/crosshair/register.js.map +1 -1
  48. package/cjs/data-zoom/interaction.js +1 -2
  49. package/cjs/data-zoom/register.js +3 -3
  50. package/cjs/data-zoom/register.js.map +1 -1
  51. package/cjs/empty-tip/register.js +3 -2
  52. package/cjs/empty-tip/register.js.map +1 -1
  53. package/cjs/empty-tip/type.js +2 -1
  54. package/cjs/index.d.ts +1 -1
  55. package/cjs/index.js +1 -1
  56. package/cjs/index.js.map +1 -1
  57. package/cjs/indicator/register.js +3 -2
  58. package/cjs/indicator/register.js.map +1 -1
  59. package/cjs/jsx/component-type.d.ts +2 -3
  60. package/cjs/jsx/component-type.js.map +1 -1
  61. package/cjs/label/arc.js +14 -10
  62. package/cjs/label/arc.js.map +1 -1
  63. package/cjs/label/base.d.ts +12 -2
  64. package/cjs/label/base.js +114 -41
  65. package/cjs/label/base.js.map +1 -1
  66. package/cjs/label/data-label-register.js +1 -1
  67. package/cjs/label/dataLabel.d.ts +5 -1
  68. package/cjs/label/dataLabel.js +47 -2
  69. package/cjs/label/dataLabel.js.map +1 -1
  70. package/cjs/label/index.js +1 -1
  71. package/cjs/label/line.js +1 -1
  72. package/cjs/label/polygon.js +1 -1
  73. package/cjs/label/rect.js +1 -1
  74. package/cjs/label/register.js +4 -3
  75. package/cjs/label/register.js.map +1 -1
  76. package/cjs/label-item/register.js +3 -3
  77. package/cjs/label-item/register.js.map +1 -1
  78. package/cjs/legend/discrete/discrete.js +4 -2
  79. package/cjs/legend/discrete/discrete.js.map +1 -1
  80. package/cjs/legend/register.js +3 -3
  81. package/cjs/legend/register.js.map +1 -1
  82. package/cjs/link-path/register.js +2 -2
  83. package/cjs/link-path/register.js.map +1 -1
  84. package/cjs/marker/animate/animate.d.ts +1 -1
  85. package/cjs/marker/animate/animate.js.map +1 -1
  86. package/cjs/marker/animate/call-in.d.ts +2 -2
  87. package/cjs/marker/animate/call-in.js +5 -4
  88. package/cjs/marker/animate/call-in.js.map +1 -1
  89. package/cjs/marker/animate/clip-in.js +5 -4
  90. package/cjs/marker/animate/clip-in.js.map +1 -1
  91. package/cjs/marker/animate/common.d.ts +1 -0
  92. package/cjs/marker/animate/common.js +13 -8
  93. package/cjs/marker/animate/common.js.map +1 -1
  94. package/cjs/marker/animate/fade-in.d.ts +1 -1
  95. package/cjs/marker/animate/fade-in.js.map +1 -1
  96. package/cjs/marker/animate/fade-out.d.ts +1 -1
  97. package/cjs/marker/animate/fade-out.js.map +1 -1
  98. package/cjs/marker/arc-area.d.ts +1 -1
  99. package/cjs/marker/area.d.ts +1 -1
  100. package/cjs/marker/base.d.ts +6 -2
  101. package/cjs/marker/base.js +51 -9
  102. package/cjs/marker/base.js.map +1 -1
  103. package/cjs/marker/common-line.d.ts +1 -1
  104. package/cjs/marker/point.d.ts +1 -1
  105. package/cjs/marker/register.js +8 -8
  106. package/cjs/marker/register.js.map +1 -1
  107. package/cjs/marker/type.d.ts +8 -5
  108. package/cjs/marker/type.js.map +1 -1
  109. package/cjs/pager/register.js +3 -2
  110. package/cjs/pager/register.js.map +1 -1
  111. package/cjs/player/register.js +3 -3
  112. package/cjs/player/register.js.map +1 -1
  113. package/cjs/poptip/module.js +3 -1
  114. package/cjs/poptip/module.js.map +1 -1
  115. package/cjs/poptip/register.js +3 -3
  116. package/cjs/poptip/register.js.map +1 -1
  117. package/cjs/radio/register.js +3 -3
  118. package/cjs/radio/register.js.map +1 -1
  119. package/cjs/scrollbar/register.js +2 -2
  120. package/cjs/scrollbar/register.js.map +1 -1
  121. package/cjs/segment/register.js +5 -5
  122. package/cjs/segment/register.js.map +1 -1
  123. package/cjs/slider/register.js +3 -3
  124. package/cjs/slider/register.js.map +1 -1
  125. package/cjs/switch/register.js +3 -3
  126. package/cjs/switch/register.js.map +1 -1
  127. package/cjs/table-series-number/register.js +3 -2
  128. package/cjs/table-series-number/register.js.map +1 -1
  129. package/cjs/tag/register.js +4 -3
  130. package/cjs/tag/register.js.map +1 -1
  131. package/cjs/timeline/register.js +3 -3
  132. package/cjs/timeline/register.js.map +1 -1
  133. package/cjs/title/register.js +3 -2
  134. package/cjs/title/register.js.map +1 -1
  135. package/cjs/title/title.js +5 -2
  136. package/cjs/title/title.js.map +1 -1
  137. package/cjs/tooltip/register.js +3 -3
  138. package/cjs/tooltip/register.js.map +1 -1
  139. package/cjs/tooltip/tooltip.js +8 -8
  140. package/cjs/tooltip/tooltip.js.map +1 -1
  141. package/cjs/util/event.js +2 -2
  142. package/cjs/util/event.js.map +1 -1
  143. package/cjs/util/graphic-creator.js +1 -1
  144. package/cjs/util/graphic-creator.js.map +1 -1
  145. package/cjs/util/text.js +3 -3
  146. package/cjs/util/text.js.map +1 -1
  147. package/cjs/weather/register.js +2 -2
  148. package/cjs/weather/register.js.map +1 -1
  149. package/cjs/weather/weather-box.js +5 -5
  150. package/cjs/weather/weather-box.js.map +1 -1
  151. package/dist/index.es.js +6869 -6023
  152. package/es/animation/axis-animate.d.ts +2 -1
  153. package/es/animation/axis-animate.js +9 -2
  154. package/es/animation/axis-animate.js.map +1 -1
  155. package/es/animation/exit-release.d.ts +13 -0
  156. package/es/animation/exit-release.js +31 -0
  157. package/es/animation/exit-release.js.map +1 -0
  158. package/es/animation/label-animate.d.ts +1 -1
  159. package/es/animation/label-animate.js +8 -12
  160. package/es/animation/label-animate.js.map +1 -1
  161. package/es/animation/static-truth.js +1 -5
  162. package/es/animation/static-truth.js.map +1 -1
  163. package/es/axis/animate/group-transition.d.ts +3 -2
  164. package/es/axis/animate/group-transition.js +2 -2
  165. package/es/axis/animate/group-transition.js.map +1 -1
  166. package/es/axis/base.d.ts +6 -2
  167. package/es/axis/base.js +61 -6
  168. package/es/axis/base.js.map +1 -1
  169. package/es/axis/circle.js +1 -1
  170. package/es/axis/config.js +1 -1
  171. package/es/axis/constant.js +1 -1
  172. package/es/axis/index.js +1 -1
  173. package/es/axis/line.d.ts +1 -1
  174. package/es/axis/line.js +3 -3
  175. package/es/axis/line.js.map +1 -1
  176. package/es/axis/overlap/auto-hide.d.ts +1 -1
  177. package/es/axis/overlap/auto-hide.js.map +1 -1
  178. package/es/axis/register.js +14 -2
  179. package/es/axis/register.js.map +1 -1
  180. package/es/axis/type.js +1 -1
  181. package/es/axis/util.js +1 -1
  182. package/es/brush/brush.d.ts +4 -0
  183. package/es/brush/brush.js +32 -15
  184. package/es/brush/brush.js.map +1 -1
  185. package/es/brush/register.js +3 -1
  186. package/es/brush/register.js.map +1 -1
  187. package/es/brush/type.js +1 -2
  188. package/es/checkbox/register.js +7 -1
  189. package/es/checkbox/register.js.map +1 -1
  190. package/es/core/base.d.ts +2 -2
  191. package/es/core/base.js +3 -1
  192. package/es/core/base.js.map +1 -1
  193. package/es/core/type.d.ts +7 -0
  194. package/es/core/type.js.map +1 -1
  195. package/es/crosshair/polygon.js +2 -1
  196. package/es/crosshair/register.js +9 -1
  197. package/es/crosshair/register.js.map +1 -1
  198. package/es/data-zoom/interaction.js +1 -2
  199. package/es/data-zoom/register.js +7 -1
  200. package/es/data-zoom/register.js.map +1 -1
  201. package/es/empty-tip/register.js +5 -1
  202. package/es/empty-tip/register.js.map +1 -1
  203. package/es/empty-tip/type.js +2 -1
  204. package/es/index.d.ts +1 -1
  205. package/es/index.js +1 -1
  206. package/es/index.js.map +1 -1
  207. package/es/indicator/register.js +5 -1
  208. package/es/indicator/register.js.map +1 -1
  209. package/es/jsx/component-type.d.ts +2 -3
  210. package/es/jsx/component-type.js.map +1 -1
  211. package/es/label/arc.js +14 -10
  212. package/es/label/arc.js.map +1 -1
  213. package/es/label/base.d.ts +12 -2
  214. package/es/label/base.js +107 -31
  215. package/es/label/base.js.map +1 -1
  216. package/es/label/data-label-register.js +1 -1
  217. package/es/label/dataLabel.d.ts +5 -1
  218. package/es/label/dataLabel.js +47 -1
  219. package/es/label/dataLabel.js.map +1 -1
  220. package/es/label/index.js +1 -1
  221. package/es/label/line.js +1 -1
  222. package/es/label/polygon.js +1 -1
  223. package/es/label/rect.js +1 -1
  224. package/es/label/register.js +7 -1
  225. package/es/label/register.js.map +1 -1
  226. package/es/label-item/register.js +7 -1
  227. package/es/label-item/register.js.map +1 -1
  228. package/es/legend/discrete/discrete.js +4 -2
  229. package/es/legend/discrete/discrete.js.map +1 -1
  230. package/es/legend/register.js +3 -1
  231. package/es/legend/register.js.map +1 -1
  232. package/es/link-path/register.js +3 -1
  233. package/es/link-path/register.js.map +1 -1
  234. package/es/marker/animate/animate.d.ts +1 -1
  235. package/es/marker/animate/animate.js.map +1 -1
  236. package/es/marker/animate/call-in.d.ts +2 -2
  237. package/es/marker/animate/call-in.js +6 -4
  238. package/es/marker/animate/call-in.js.map +1 -1
  239. package/es/marker/animate/clip-in.js +6 -4
  240. package/es/marker/animate/clip-in.js.map +1 -1
  241. package/es/marker/animate/common.d.ts +1 -0
  242. package/es/marker/animate/common.js +9 -4
  243. package/es/marker/animate/common.js.map +1 -1
  244. package/es/marker/animate/fade-in.d.ts +1 -1
  245. package/es/marker/animate/fade-in.js.map +1 -1
  246. package/es/marker/animate/fade-out.d.ts +1 -1
  247. package/es/marker/animate/fade-out.js.map +1 -1
  248. package/es/marker/arc-area.d.ts +1 -1
  249. package/es/marker/area.d.ts +1 -1
  250. package/es/marker/base.d.ts +6 -2
  251. package/es/marker/base.js +51 -8
  252. package/es/marker/base.js.map +1 -1
  253. package/es/marker/common-line.d.ts +1 -1
  254. package/es/marker/point.d.ts +1 -1
  255. package/es/marker/register.js +12 -2
  256. package/es/marker/register.js.map +1 -1
  257. package/es/marker/type.d.ts +8 -5
  258. package/es/marker/type.js.map +1 -1
  259. package/es/pager/register.js +5 -1
  260. package/es/pager/register.js.map +1 -1
  261. package/es/player/register.js +3 -1
  262. package/es/player/register.js.map +1 -1
  263. package/es/poptip/module.js +3 -1
  264. package/es/poptip/module.js.map +1 -1
  265. package/es/poptip/register.js +7 -1
  266. package/es/poptip/register.js.map +1 -1
  267. package/es/radio/register.js +7 -1
  268. package/es/radio/register.js.map +1 -1
  269. package/es/scrollbar/register.js +3 -1
  270. package/es/scrollbar/register.js.map +1 -1
  271. package/es/segment/register.js +9 -1
  272. package/es/segment/register.js.map +1 -1
  273. package/es/slider/register.js +7 -1
  274. package/es/slider/register.js.map +1 -1
  275. package/es/switch/register.js +7 -1
  276. package/es/switch/register.js.map +1 -1
  277. package/es/table-series-number/register.js +5 -1
  278. package/es/table-series-number/register.js.map +1 -1
  279. package/es/tag/register.js +9 -1
  280. package/es/tag/register.js.map +1 -1
  281. package/es/timeline/register.js +7 -1
  282. package/es/timeline/register.js.map +1 -1
  283. package/es/title/register.js +5 -1
  284. package/es/title/register.js.map +1 -1
  285. package/es/title/title.js +5 -2
  286. package/es/title/title.js.map +1 -1
  287. package/es/tooltip/register.js +9 -1
  288. package/es/tooltip/register.js.map +1 -1
  289. package/es/tooltip/tooltip.js +3 -1
  290. package/es/tooltip/tooltip.js.map +1 -1
  291. package/es/util/event.js +1 -1
  292. package/es/util/event.js.map +1 -1
  293. package/es/util/graphic-creator.js +1 -1
  294. package/es/util/graphic-creator.js.map +1 -1
  295. package/es/util/text.js +1 -1
  296. package/es/util/text.js.map +1 -1
  297. package/es/weather/register.js +3 -1
  298. package/es/weather/register.js.map +1 -1
  299. package/es/weather/weather-box.js +3 -1
  300. package/es/weather/weather-box.js.map +1 -1
  301. package/package.json +486 -6
@@ -1,6 +1,6 @@
1
1
  import type { IGroup, IGraphic, IText, ILine, IRichText } from '@visactor/vrender-core';
2
2
  import type { IAABBBounds, IBoundsLike, IPointLike } from '@visactor/vutils';
3
- import type { PointLocationCfg } from '../core/type';
3
+ import type { ComponentExitReleaseOptions, PointLocationCfg } from '../core/type';
4
4
  import type { Bitmap, BitmapTool } from './overlap';
5
5
  import { bitmapTool } from './overlap';
6
6
  import type { BaseLabelAttrs, OverlapAttrs, LabelItem, ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation, LabelContent } from './type';
@@ -26,6 +26,8 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AnimateComponen
26
26
  private _lastHover;
27
27
  private _lastSelect;
28
28
  private _enableAnimation;
29
+ private _exitReleaseState?;
30
+ private _finalLayoutBoundsCache?;
29
31
  constructor(attributes: BaseLabelAttrs, options?: ComponentOptions);
30
32
  protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: BaseLabelAttrs['position'], offset?: number): {
31
33
  x: number;
@@ -36,6 +38,9 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AnimateComponen
36
38
  y: number;
37
39
  }[];
38
40
  protected _createLabelLine(text: IText | IRichText, baseMark?: IGraphic): ILine | undefined;
41
+ private _finalizeExitRelease;
42
+ private _runExitAnimationBeforeRelease;
43
+ releaseWithExitAnimation(options?: ComponentExitReleaseOptions): boolean;
39
44
  protected render(): void;
40
45
  private _bindEvent;
41
46
  private _setStatesOfText;
@@ -46,6 +51,10 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AnimateComponen
46
51
  protected _createLabelText(attributes: LabelItem): IRichText | IText;
47
52
  private _prepare;
48
53
  protected getRelatedGraphic(item: LabelItem): IGraphic<Partial<import("@visactor/vrender-core").IGraphicAttribute>>;
54
+ protected getGraphicFinalLayoutAttributes<TAttrs extends Record<string, any> = Record<string, any>>(graphic: IGraphic): TAttrs;
55
+ protected hasGraphicContextFinalLayoutAttributes(graphic?: IGraphic): boolean;
56
+ protected shouldUseGraphicFinalLayoutAttributes(graphic?: IGraphic): boolean;
57
+ protected getGraphicFinalLayoutBounds(graphic?: IGraphic): IAABBBounds | undefined;
49
58
  protected _initText(data?: LabelItem[]): (IText | IRichText)[];
50
59
  protected _layout(texts: (IText | IRichText)[]): (IText | IRichText)[];
51
60
  protected _overlapping(labels: (IText | IRichText)[]): (IRichText | IText)[];
@@ -66,7 +75,8 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AnimateComponen
66
75
  private updateStatesOfLabels;
67
76
  protected _handleRelatedGraphicSetState: (e: any) => void;
68
77
  protected _smartInvert(labels: (IText | IRichText)[]): void;
69
- protected _canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds): boolean;
78
+ protected _canPlaceInside(textBound: IBoundsLike, shapeBound?: IAABBBounds): boolean;
79
+ release(all?: boolean): void;
70
80
  setLocation(point: PointLocationCfg): void;
71
81
  disableAnimation(): void;
72
82
  enableAnimation(): void;
package/cjs/label/base.js CHANGED
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", {
14
14
  value: !0
15
15
  }), exports.LabelBase = void 0;
16
16
 
17
- const vrender_core_1 = require("@visactor/vrender-core"), graphic_creator_1 = require("../util/graphic-creator"), vutils_1 = require("@visactor/vutils"), label_smartInvert_1 = require("../util/label-smartInvert"), util_1 = require("../util"), constant_1 = require("../constant"), overlap_1 = require("./overlap"), animate_1 = require("./animate/animate"), util_2 = require("./util"), register_1 = require("./register"), shiftY_1 = require("./overlap/shiftY"), animate_component_1 = require("../animation/animate-component"), static_truth_1 = require("../animation/static-truth");
17
+ const constant_1 = require("@visactor/vrender-core/event/constant"), path_1 = require("@visactor/vrender-core/path"), graphic_creator_1 = require("../util/graphic-creator"), vutils_1 = require("@visactor/vutils"), label_smartInvert_1 = require("../util/label-smartInvert"), util_1 = require("../util"), constant_2 = require("../constant"), overlap_1 = require("./overlap"), animate_1 = require("./animate/animate"), util_2 = require("./util"), register_1 = require("./register"), shiftY_1 = require("./overlap/shiftY"), animate_component_1 = require("../animation/animate-component"), static_truth_1 = require("../animation/static-truth"), exit_release_1 = require("../animation/exit-release");
18
18
 
19
19
  (0, register_1.loadLabelComponent)();
20
20
 
@@ -32,29 +32,29 @@ class LabelBase extends animate_component_1.AnimateComponent {
32
32
  }, (0, vutils_1.merge)({}, LabelBase.defaultAttributes, restAttributes))), this.name = "label",
33
33
  this._onHover = e => {
34
34
  const target = e.target;
35
- target === this._lastHover || (0, vutils_1.isEmpty)(target.states) || (target.addState(constant_1.StateValue.hover, !0),
35
+ target === this._lastHover || (0, vutils_1.isEmpty)(target.states) || (target.addState(constant_2.StateValue.hover, !0),
36
36
  (0, util_1.traverseGroup)(this, (node => {
37
- node === target || (0, vutils_1.isEmpty)(node.states) || node.addState(constant_1.StateValue.hoverReverse, !0);
37
+ node === target || (0, vutils_1.isEmpty)(node.states) || node.addState(constant_2.StateValue.hoverReverse, !0);
38
38
  })), this._lastHover = target);
39
39
  }, this._onUnHover = e => {
40
40
  this._lastHover && ((0, util_1.traverseGroup)(this, (node => {
41
- (0, vutils_1.isEmpty)(node.states) || (node.removeState(constant_1.StateValue.hoverReverse),
42
- node.removeState(constant_1.StateValue.hover));
41
+ (0, vutils_1.isEmpty)(node.states) || (node.removeState(constant_2.StateValue.hoverReverse),
42
+ node.removeState(constant_2.StateValue.hover));
43
43
  })), this._lastHover = null);
44
44
  }, this._onClick = e => {
45
45
  const target = e.target;
46
46
  if (this._lastSelect === target && target.hasState("selected")) return this._lastSelect = null,
47
47
  void (0, util_1.traverseGroup)(this, (node => {
48
- (0, vutils_1.isEmpty)(node.states) || (node.removeState(constant_1.StateValue.selectedReverse),
49
- node.removeState(constant_1.StateValue.selected));
48
+ (0, vutils_1.isEmpty)(node.states) || (node.removeState(constant_2.StateValue.selectedReverse),
49
+ node.removeState(constant_2.StateValue.selected));
50
50
  }));
51
- (0, vutils_1.isEmpty)(target.states) || (target.addState(constant_1.StateValue.selected, !0),
51
+ (0, vutils_1.isEmpty)(target.states) || (target.addState(constant_2.StateValue.selected, !0),
52
52
  (0, util_1.traverseGroup)(this, (node => {
53
- node === target || (0, vutils_1.isEmpty)(node.states) || node.addState(constant_1.StateValue.selectedReverse, !0);
53
+ node === target || (0, vutils_1.isEmpty)(node.states) || node.addState(constant_2.StateValue.selectedReverse, !0);
54
54
  })), this._lastSelect = target);
55
55
  }, this._handleRelatedGraphicSetState = e => {
56
56
  var _a, _b, _c, _d, _e;
57
- if ((null === (_a = e.detail) || void 0 === _a ? void 0 : _a.type) === vrender_core_1.AttributeUpdateType.STATE || (null === (_b = e.detail) || void 0 === _b ? void 0 : _b.type) === vrender_core_1.AttributeUpdateType.ANIMATE_UPDATE && (null === (_c = e.detail.animationState) || void 0 === _c ? void 0 : _c.isFirstFrameOfStep)) {
57
+ if ((null === (_a = e.detail) || void 0 === _a ? void 0 : _a.type) === constant_1.AttributeUpdateType.STATE || (null === (_b = e.detail) || void 0 === _b ? void 0 : _b.type) === constant_1.AttributeUpdateType.ANIMATE_UPDATE && (null === (_c = e.detail.animationState) || void 0 === _c ? void 0 : _c.isFirstFrameOfStep)) {
58
58
  const currentStates = null !== (_e = null === (_d = e.target) || void 0 === _d ? void 0 : _d.currentStates) && void 0 !== _e ? _e : [], labels = this._isCollectionBase ? [ ...this._graphicToText.values() ] : [ this._graphicToText.get(e.target) ];
59
59
  this.updateStatesOfLabels(labels, currentStates);
60
60
  }
@@ -62,7 +62,7 @@ class LabelBase extends animate_component_1.AnimateComponent {
62
62
  }
63
63
  labeling(textBounds, graphicBounds, position, offset) {}
64
64
  _getLabelLinePoints(text, baseMark) {
65
- return (0, util_2.connectLineBetweenBounds)(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds);
65
+ return (0, util_2.connectLineBetweenBounds)(text.AABBBounds, this.getGraphicFinalLayoutBounds(baseMark));
66
66
  }
67
67
  _createLabelLine(text, baseMark) {
68
68
  const points = this._getLabelLinePoints(text, baseMark);
@@ -75,20 +75,67 @@ class LabelBase extends animate_component_1.AnimateComponent {
75
75
  lineGraphic.pathProxy = attrs => customShape({
76
76
  text: text,
77
77
  baseMark: baseMark
78
- }, attrs, new vrender_core_1.CustomPath2D);
78
+ }, attrs, new path_1.CustomPath2D);
79
79
  }
80
- return baseMark && baseMark.getAttributes(!0).fill && lineGraphic.setAttribute("stroke", baseMark.getAttributes(!0).fill),
80
+ const baseMarkAttrs = baseMark && this.getGraphicFinalLayoutAttributes(baseMark);
81
+ return (null == baseMarkAttrs ? void 0 : baseMarkAttrs.fill) && lineGraphic.setAttribute("stroke", baseMarkAttrs.fill),
81
82
  this.attribute.line && !(0, vutils_1.isEmpty)(this.attribute.line.style) && lineGraphic.setAttributes(this.attribute.line.style),
82
83
  this._setStatesOfLabelLine(lineGraphic), lineGraphic;
83
84
  }
84
85
  }
86
+ _finalizeExitRelease() {
87
+ var _a, _b, _c, _d;
88
+ const state = this._exitReleaseState;
89
+ if (null == state ? void 0 : state.finalized) return;
90
+ state && (state.finalized = !0);
91
+ const parent = this.parent, removeFromParent = !!(null == state ? void 0 : state.removeFromParent), callbacks = null !== (_a = null == state ? void 0 : state.onComplete) && void 0 !== _a ? _a : [];
92
+ this._exitReleaseState = void 0, this._graphicToText = new Map, null === (_b = this._idToGraphic) || void 0 === _b || _b.clear(),
93
+ null === (_c = this._idToPoint) || void 0 === _c || _c.clear(), this._baseMarks = void 0,
94
+ this.removeAllChild(!0), super.release(!0), removeFromParent && (null === (_d = null != parent ? parent : this.parent) || void 0 === _d || _d.removeChild(this)),
95
+ (0, exit_release_1.runExitReleaseCallbacks)(callbacks);
96
+ }
97
+ _runExitAnimationBeforeRelease(options = {}) {
98
+ var _a, _b;
99
+ if (this._exitReleaseState && !this._exitReleaseState.finalized) return this._exitReleaseState.removeFromParent = this._exitReleaseState.removeFromParent || !!options.removeFromParent,
100
+ (0, exit_release_1.appendExitReleaseCallback)(this._exitReleaseState, options.onComplete),
101
+ !0;
102
+ if (!this.stage || !1 === this.attribute.animation || !1 === this.attribute.animationExit || !(null === (_a = this._graphicToText) || void 0 === _a ? void 0 : _a.size)) return !1;
103
+ if (this._prepareAnimate(animate_1.DefaultLabelAnimation), !(null === (_b = this._animationConfig) || void 0 === _b ? void 0 : _b.exit)) return !1;
104
+ const exitTargets = new Set;
105
+ if (this._graphicToText.forEach((label => {
106
+ (null == label ? void 0 : label.text) && exitTargets.add(label.text), (null == label ? void 0 : label.labelLine) && exitTargets.add(label.labelLine);
107
+ })), !exitTargets.size) return !1;
108
+ const existingAnimates = (0, exit_release_1.collectTrackedAnimates)(this);
109
+ exitTargets.forEach((target => {
110
+ var _a;
111
+ target.applyAnimationState([ "exit" ], [ {
112
+ name: "exit",
113
+ animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
114
+ type: null !== (_a = this._animationConfig.exit.type) && void 0 !== _a ? _a : "fadeOut",
115
+ selfOnly: !0
116
+ })
117
+ } ]);
118
+ }));
119
+ const exitAnimates = (0, exit_release_1.collectTrackedAnimates)(this).filter((animate => !existingAnimates.includes(animate)));
120
+ if (!exitAnimates.length) return !1;
121
+ this.setAttribute("childrenPickable", !1), this.releaseStatus = "willRelease";
122
+ const pendingAnimates = new Set(exitAnimates);
123
+ return this._exitReleaseState = {
124
+ pendingAnimates: pendingAnimates,
125
+ finalized: !1,
126
+ removeFromParent: !!options.removeFromParent,
127
+ onComplete: options.onComplete ? [ options.onComplete ] : []
128
+ }, (0, exit_release_1.bindExitReleaseAnimates)(exitAnimates, (() => this._exitReleaseState), (() => this._finalizeExitRelease())),
129
+ !0;
130
+ }
131
+ releaseWithExitAnimation(options = {}) {
132
+ return "released" !== this.releaseStatus && this._runExitAnimationBeforeRelease(options);
133
+ }
85
134
  render() {
86
- if (this._prepare(), (0, vutils_1.isNil)(this._idToGraphic) || this._isCollectionBase && (0,
135
+ if (this._exitReleaseState) return;
136
+ if (this._finalLayoutBoundsCache = void 0, this._prepare(), (0, vutils_1.isNil)(this._idToGraphic) || this._isCollectionBase && (0,
87
137
  vutils_1.isNil)(this._idToPoint)) return;
88
- const markAttributeList = [];
89
- !1 !== this._enableAnimation && this._baseMarks.forEach((mark => {
90
- markAttributeList.push(mark.attribute), mark.initAttributes(mark.getAttributes(!0));
91
- }));
138
+ this._finalLayoutBoundsCache = new Map;
92
139
  const {overlap: overlap, smartInvert: smartInvert, dataFilter: dataFilter, customLayoutFunc: customLayoutFunc, customOverlapFunc: customOverlapFunc} = this.attribute;
93
140
  let data = this.attribute.data;
94
141
  if ((0, vutils_1.isFunction)(dataFilter) && (data = dataFilter(data)), data && data.length) {
@@ -109,9 +156,7 @@ class LabelBase extends animate_component_1.AnimateComponent {
109
156
  labels && labels.length && labels.forEach((label => {
110
157
  this._bindEvent(label), this._setStatesOfText(label);
111
158
  })), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels),
112
- !1 !== this._enableAnimation && this._baseMarks.forEach(((mark, index) => {
113
- mark.initAttributes(markAttributeList[index]);
114
- }));
159
+ this._finalLayoutBoundsCache = void 0;
115
160
  }
116
161
  _bindEvent(target) {
117
162
  if (this.attribute.disableTriggerEvent) return;
@@ -170,12 +215,38 @@ class LabelBase extends animate_component_1.AnimateComponent {
170
215
  getRelatedGraphic(item) {
171
216
  return this._idToGraphic.get(item.id);
172
217
  }
218
+ getGraphicFinalLayoutAttributes(graphic) {
219
+ var _a, _b;
220
+ return null !== (_b = null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.finalAttrs) && void 0 !== _b ? _b : graphic.getAttributes(!0);
221
+ }
222
+ hasGraphicContextFinalLayoutAttributes(graphic) {
223
+ var _a;
224
+ return !!(null === (_a = null == graphic ? void 0 : graphic.context) || void 0 === _a ? void 0 : _a.finalAttrs);
225
+ }
226
+ shouldUseGraphicFinalLayoutAttributes(graphic) {
227
+ var _a;
228
+ return !!graphic && (!!(null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) || this.hasGraphicContextFinalLayoutAttributes(graphic));
229
+ }
230
+ getGraphicFinalLayoutBounds(graphic) {
231
+ var _a, _b;
232
+ if (!graphic) return;
233
+ const useFinalAttrs = this.shouldUseGraphicFinalLayoutAttributes(graphic), graphicAttrs = useFinalAttrs ? this.getGraphicFinalLayoutAttributes(graphic) : graphic.attribute;
234
+ if (!1 === (null == graphicAttrs ? void 0 : graphicAttrs.visible)) return;
235
+ if (!useFinalAttrs) return graphic.AABBBounds;
236
+ const cachedBounds = null === (_a = this._finalLayoutBoundsCache) || void 0 === _a ? void 0 : _a.get(graphic);
237
+ if (cachedBounds) return cachedBounds;
238
+ const clonedGraphic = graphic.clone();
239
+ clonedGraphic.initAttributes(Object.assign(Object.assign({}, clonedGraphic.attribute), graphicAttrs));
240
+ const bounds = clonedGraphic.AABBBounds;
241
+ return null === (_b = this._finalLayoutBoundsCache) || void 0 === _b || _b.set(graphic, bounds),
242
+ bounds;
243
+ }
173
244
  _initText(data = []) {
174
245
  const {textStyle: textStyle = {}} = this.attribute, labels = [];
175
246
  for (let i = 0; i < data.length; i++) {
176
247
  const textData = data[i], baseMark = this.getRelatedGraphic(textData);
177
248
  if (!baseMark) continue;
178
- const graphicAttribute = baseMark.getAttributes(!0), labelAttribute = Object.assign(Object.assign({
249
+ const graphicAttribute = this.getGraphicFinalLayoutAttributes(baseMark), labelAttribute = Object.assign(Object.assign({
179
250
  fill: this._isCollectionBase ? (0, vutils_1.isArray)(graphicAttribute.stroke) ? graphicAttribute.stroke.find((entry => !!entry && !0 !== entry)) : graphicAttribute.stroke : graphicAttribute.fill
180
251
  }, textStyle), textData), text = this._createLabelText(labelAttribute);
181
252
  labels.push(text);
@@ -273,7 +344,8 @@ class LabelBase extends animate_component_1.AnimateComponent {
273
344
  var _a;
274
345
  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));
275
346
  avoidBaseMark && (null === (_a = this._baseMarks) || void 0 === _a || _a.forEach((mark => {
276
- mark.AABBBounds && bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, mark.AABBBounds, !0));
347
+ const markBounds = this.getGraphicFinalLayoutBounds(mark);
348
+ markBounds && bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, markBounds, !0));
277
349
  }))), avoidMarks.length > 0 && avoidMarks.forEach((avoid => {
278
350
  (0, vutils_1.isString)(avoid) ? (0, util_1.getNoneGroupMarksByName)(this.getRootNode(), avoid).forEach((avoidMark => {
279
351
  avoidMark.AABBBounds && bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, avoidMark.AABBBounds, !0));
@@ -288,7 +360,7 @@ class LabelBase extends animate_component_1.AnimateComponent {
288
360
  bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, text.AABBBounds, !0)), result.push(text);
289
361
  continue;
290
362
  }
291
- if (checkBounds && baseMark && baseMark.AABBBounds && this._canPlaceInside(text.AABBBounds, baseMark.AABBBounds)) {
363
+ if (checkBounds && baseMark && this._canPlaceInside(text.AABBBounds, this.getGraphicFinalLayoutBounds(baseMark))) {
292
364
  bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, text.AABBBounds, !0)), result.push(text);
293
365
  continue;
294
366
  }
@@ -314,14 +386,15 @@ class LabelBase extends animate_component_1.AnimateComponent {
314
386
  return result;
315
387
  }
316
388
  isMarkInsideRect(baseMark, bmpTool) {
389
+ if (!baseMark) return !1;
317
390
  const {left: left, right: right, top: top, bottom: bottom} = bmpTool.padding, rect = {
318
391
  x1: -left,
319
392
  x2: bmpTool.width + right,
320
393
  y1: -top,
321
394
  y2: bmpTool.height + bottom
322
- }, bounds = baseMark.AABBBounds;
323
- if (0 !== bounds.width() && 0 !== bounds.height()) return (0, vutils_1.isRectIntersect)(baseMark.AABBBounds, rect, !0);
324
- const {attribute: attribute} = baseMark;
395
+ }, bounds = this.getGraphicFinalLayoutBounds(baseMark);
396
+ if (bounds && 0 !== bounds.width() && 0 !== bounds.height()) return (0, vutils_1.isRectIntersect)(bounds, rect, !0);
397
+ const attribute = this.shouldUseGraphicFinalLayoutAttributes(baseMark) ? this.getGraphicFinalLayoutAttributes(baseMark) : baseMark.attribute;
325
398
  if ("rect" === baseMark.type) {
326
399
  const {x: x, x1: x1, y: y, y1: y1} = attribute;
327
400
  return (0, vutils_1.pointInRect)({
@@ -339,16 +412,10 @@ class LabelBase extends animate_component_1.AnimateComponent {
339
412
  if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
340
413
  }
341
414
  getGraphicBounds(graphic, point = {}, position) {
342
- var _a;
343
415
  if (graphic) {
344
- if (!1 !== graphic.attribute.visible) {
345
- if (null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) {
346
- const clonedGraphic = graphic.clone();
347
- return Object.assign(clonedGraphic.attribute, graphic.getAttributes(!0)), clonedGraphic.AABBBounds;
348
- }
349
- return graphic.AABBBounds;
350
- }
351
- const {x: x, y: y} = graphic.attribute;
416
+ const graphicAttrs = this.shouldUseGraphicFinalLayoutAttributes(graphic) ? this.getGraphicFinalLayoutAttributes(graphic) : graphic.attribute;
417
+ if (!1 !== graphicAttrs.visible) return this.getGraphicFinalLayoutBounds(graphic);
418
+ const {x: x, y: y} = graphicAttrs;
352
419
  return {
353
420
  x1: x,
354
421
  x2: x,
@@ -481,16 +548,16 @@ class LabelBase extends animate_component_1.AnimateComponent {
481
548
  if ("null" !== fillStrategy || "null" !== strokeStrategy) for (let i = 0; i < labels.length; i++) {
482
549
  const label = labels[i];
483
550
  if (!label) continue;
484
- const baseMark = this.getRelatedGraphic(label.attribute);
485
- let backgroundColor = baseMark.getAttributes(!0).fill;
486
- const backgroundOpacity = baseMark.getAttributes(!0).fillOpacity;
551
+ const baseMark = this.getRelatedGraphic(label.attribute), baseMarkAttrs = this.getGraphicFinalLayoutAttributes(baseMark);
552
+ let backgroundColor = baseMarkAttrs.fill;
553
+ const backgroundOpacity = baseMarkAttrs.fillOpacity;
487
554
  let foregroundColor = label.attribute.fill;
488
555
  if ((0, vutils_1.isObject)(backgroundColor) && backgroundColor.gradient) {
489
556
  const firstStopColor = null === (_g = null === (_f = backgroundColor.stops) || void 0 === _f ? void 0 : _f[0]) || void 0 === _g ? void 0 : _g.color;
490
557
  firstStopColor && (backgroundColor = firstStopColor, foregroundColor = firstStopColor);
491
558
  }
492
559
  const invertColor = (0, label_smartInvert_1.labelSmartInvert)(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode), similarColor = (0,
493
- label_smartInvert_1.contrastAccessibilityChecker)(invertColor, brightColor) ? brightColor : darkColor, isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds), isIntersect = !isInside && label.AABBBounds && baseMark.AABBBounds && baseMark.AABBBounds.intersects(label.AABBBounds);
560
+ label_smartInvert_1.contrastAccessibilityChecker)(invertColor, brightColor) ? brightColor : darkColor, baseMarkBounds = this.getGraphicFinalLayoutBounds(baseMark), isInside = this._canPlaceInside(label.AABBBounds, baseMarkBounds), isIntersect = !isInside && label.AABBBounds && baseMarkBounds && baseMarkBounds.intersects(label.AABBBounds);
494
561
  if (isInside || outsideEnable || isIntersect && "inside" === interactInvertType) {
495
562
  const fill = (0, label_smartInvert_1.smartInvertStrategy)(fillStrategy, backgroundColor, invertColor, similarColor);
496
563
  if (fill && label.setAttributes({
@@ -540,6 +607,12 @@ class LabelBase extends animate_component_1.AnimateComponent {
540
607
  _canPlaceInside(textBound, shapeBound) {
541
608
  return !(!textBound || !shapeBound) && shapeBound.encloses(textBound);
542
609
  }
610
+ release(all) {
611
+ var _a, _b;
612
+ this._exitReleaseState ? this._finalizeExitRelease() : (all && this.removeAllChild(!0),
613
+ super.release(all), this._graphicToText = new Map, null === (_a = this._idToGraphic) || void 0 === _a || _a.clear(),
614
+ null === (_b = this._idToPoint) || void 0 === _b || _b.clear(), this._baseMarks = void 0);
615
+ }
543
616
  setLocation(point) {
544
617
  this.translateTo(point.x, point.y);
545
618
  }
@@ -561,4 +634,4 @@ exports.LabelBase = LabelBase, LabelBase.defaultAttributes = {
561
634
  offset: 0,
562
635
  pickable: !1
563
636
  };
564
- //# sourceMappingURL=base.js.map
637
+ //# sourceMappingURL=base.js.map