@visactor/vrender-components 0.23.0-alpha.3 → 1.0.0-alpha.10

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 (240) 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 +80 -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/type.d.ts +4 -0
  23. package/cjs/axis/type.js.map +1 -1
  24. package/cjs/axis/util.js +5 -5
  25. package/cjs/axis/util.js.map +1 -1
  26. package/cjs/brush/brush.d.ts +16 -10
  27. package/cjs/brush/brush.js +81 -93
  28. package/cjs/brush/brush.js.map +1 -1
  29. package/cjs/brush/config.d.ts +5 -5
  30. package/cjs/brush/config.js +6 -7
  31. package/cjs/brush/config.js.map +1 -1
  32. package/cjs/brush/type.d.ts +1 -0
  33. package/cjs/brush/type.js +3 -2
  34. package/cjs/brush/type.js.map +1 -1
  35. package/cjs/crosshair/rect.js +1 -2
  36. package/cjs/crosshair/type.js +2 -1
  37. package/cjs/data-zoom/data-zoom.d.ts +3 -0
  38. package/cjs/data-zoom/data-zoom.js +36 -19
  39. package/cjs/data-zoom/data-zoom.js.map +1 -1
  40. package/cjs/index.d.ts +1 -1
  41. package/cjs/index.js +1 -1
  42. package/cjs/index.js.map +1 -1
  43. package/cjs/indicator/register.js +1 -2
  44. package/cjs/jsx/index.js +2 -1
  45. package/cjs/label/animate/animate.d.ts +1 -12
  46. package/cjs/label/animate/animate.js +1 -78
  47. package/cjs/label/animate/animate.js.map +1 -1
  48. package/cjs/label/base.d.ts +5 -3
  49. package/cjs/label/base.js +61 -35
  50. package/cjs/label/base.js.map +1 -1
  51. package/cjs/label/dataLabel.js +1 -1
  52. package/cjs/label/overlap/scaler.js +3 -3
  53. package/cjs/label/overlap/scaler.js.map +1 -1
  54. package/cjs/label/register.d.ts +1 -0
  55. package/cjs/label/register.js +8 -4
  56. package/cjs/label/register.js.map +1 -1
  57. package/cjs/label-item/index.js +1 -1
  58. package/cjs/label-item/label-item.js +1 -1
  59. package/cjs/label-item/label-item.js.map +1 -1
  60. package/cjs/label-item/register.js +1 -1
  61. package/cjs/label-item/type.js +1 -1
  62. package/cjs/marker/animate/animate.d.ts +3 -3
  63. package/cjs/marker/animate/animate.js.map +1 -1
  64. package/cjs/marker/animate/clip-in.d.ts +1 -1
  65. package/cjs/marker/animate/clip-in.js +6 -3
  66. package/cjs/marker/animate/clip-in.js.map +1 -1
  67. package/cjs/marker/animate/fade-in.d.ts +3 -3
  68. package/cjs/marker/animate/fade-in.js +10 -4
  69. package/cjs/marker/animate/fade-in.js.map +1 -1
  70. package/cjs/marker/animate/fade-out.d.ts +3 -3
  71. package/cjs/marker/animate/fade-out.js +10 -4
  72. package/cjs/marker/animate/fade-out.js.map +1 -1
  73. package/cjs/marker/arc-area.d.ts +8 -5
  74. package/cjs/marker/arc-area.js +18 -39
  75. package/cjs/marker/arc-area.js.map +1 -1
  76. package/cjs/marker/arc-line.d.ts +6 -4
  77. package/cjs/marker/arc-line.js +12 -9
  78. package/cjs/marker/arc-line.js.map +1 -1
  79. package/cjs/marker/area.d.ts +6 -4
  80. package/cjs/marker/area.js +14 -32
  81. package/cjs/marker/area.js.map +1 -1
  82. package/cjs/marker/base.d.ts +2 -3
  83. package/cjs/marker/base.js.map +1 -1
  84. package/cjs/marker/common-line.d.ts +11 -7
  85. package/cjs/marker/common-line.js +11 -31
  86. package/cjs/marker/common-line.js.map +1 -1
  87. package/cjs/marker/config.d.ts +2 -0
  88. package/cjs/marker/config.js +2 -0
  89. package/cjs/marker/config.js.map +1 -1
  90. package/cjs/marker/line.d.ts +6 -4
  91. package/cjs/marker/line.js +10 -4
  92. package/cjs/marker/line.js.map +1 -1
  93. package/cjs/marker/mixin/label.d.ts +16 -0
  94. package/cjs/marker/mixin/label.js +57 -0
  95. package/cjs/marker/mixin/label.js.map +1 -0
  96. package/cjs/marker/type.d.ts +19 -16
  97. package/cjs/marker/type.js.map +1 -1
  98. package/cjs/poptip/contribution.js +4 -2
  99. package/cjs/poptip/contribution.js.map +1 -1
  100. package/cjs/poptip/poptip.d.ts +5 -0
  101. package/cjs/poptip/poptip.js +87 -18
  102. package/cjs/poptip/poptip.js.map +1 -1
  103. package/cjs/poptip/type.d.ts +4 -1
  104. package/cjs/poptip/type.js.map +1 -1
  105. package/cjs/scrollbar/scrollbar.d.ts +1 -0
  106. package/cjs/scrollbar/scrollbar.js +21 -12
  107. package/cjs/scrollbar/scrollbar.js.map +1 -1
  108. package/cjs/slider/slider.d.ts +3 -0
  109. package/cjs/slider/slider.js +48 -27
  110. package/cjs/slider/slider.js.map +1 -1
  111. package/cjs/switch/switch.js +2 -2
  112. package/cjs/switch/switch.js.map +1 -1
  113. package/cjs/tag/tag.js +60 -56
  114. package/cjs/tag/tag.js.map +1 -1
  115. package/cjs/util/event.d.ts +1 -0
  116. package/cjs/util/event.js +14 -0
  117. package/cjs/util/event.js.map +1 -0
  118. package/cjs/weather/weather-box.d.ts +1 -2
  119. package/cjs/weather/weather-box.js.map +1 -1
  120. package/dist/index.es.js +14149 -12832
  121. package/es/animation/animate-component.d.ts +22 -0
  122. package/es/animation/animate-component.js +21 -0
  123. package/es/animation/animate-component.js.map +1 -0
  124. package/es/animation/axis-animate.d.ts +10 -0
  125. package/es/animation/axis-animate.js +60 -0
  126. package/es/animation/axis-animate.js.map +1 -0
  127. package/es/animation/label-animate.d.ts +10 -0
  128. package/es/animation/label-animate.js +69 -0
  129. package/es/animation/label-animate.js.map +1 -0
  130. package/es/axis/animate/config.d.ts +6 -0
  131. package/es/axis/animate/config.js +6 -0
  132. package/es/axis/animate/config.js.map +1 -0
  133. package/es/axis/animate/group-transition.d.ts +2 -1
  134. package/es/axis/animate/group-transition.js +3 -1
  135. package/es/axis/animate/group-transition.js.map +1 -1
  136. package/es/axis/base.d.ts +9 -4
  137. package/es/axis/base.js +75 -9
  138. package/es/axis/base.js.map +1 -1
  139. package/es/axis/line.js.map +1 -1
  140. package/es/axis/register.js +3 -1
  141. package/es/axis/register.js.map +1 -1
  142. package/es/axis/type.d.ts +4 -0
  143. package/es/axis/type.js.map +1 -1
  144. package/es/axis/util.js +5 -6
  145. package/es/axis/util.js.map +1 -1
  146. package/es/brush/brush.d.ts +16 -10
  147. package/es/brush/brush.js +83 -95
  148. package/es/brush/brush.js.map +1 -1
  149. package/es/brush/config.d.ts +5 -5
  150. package/es/brush/config.js +6 -7
  151. package/es/brush/config.js.map +1 -1
  152. package/es/brush/type.d.ts +1 -0
  153. package/es/brush/type.js +3 -2
  154. package/es/brush/type.js.map +1 -1
  155. package/es/crosshair/rect.js +1 -2
  156. package/es/crosshair/type.js +2 -1
  157. package/es/data-zoom/data-zoom.d.ts +3 -0
  158. package/es/data-zoom/data-zoom.js +35 -16
  159. package/es/data-zoom/data-zoom.js.map +1 -1
  160. package/es/index.d.ts +1 -1
  161. package/es/index.js +1 -1
  162. package/es/index.js.map +1 -1
  163. package/es/indicator/register.js +1 -2
  164. package/es/jsx/index.js +2 -1
  165. package/es/label/animate/animate.d.ts +1 -12
  166. package/es/label/animate/animate.js +0 -76
  167. package/es/label/animate/animate.js.map +1 -1
  168. package/es/label/base.d.ts +5 -3
  169. package/es/label/base.js +63 -35
  170. package/es/label/base.js.map +1 -1
  171. package/es/label/dataLabel.js +1 -1
  172. package/es/label/overlap/scaler.js +1 -1
  173. package/es/label/overlap/scaler.js.map +1 -1
  174. package/es/label/register.d.ts +1 -0
  175. package/es/label/register.js +7 -1
  176. package/es/label/register.js.map +1 -1
  177. package/es/label-item/index.js +1 -1
  178. package/es/label-item/label-item.js +1 -1
  179. package/es/label-item/label-item.js.map +1 -1
  180. package/es/label-item/register.js +1 -1
  181. package/es/label-item/type.js +1 -1
  182. package/es/marker/animate/animate.d.ts +3 -3
  183. package/es/marker/animate/animate.js.map +1 -1
  184. package/es/marker/animate/clip-in.d.ts +1 -1
  185. package/es/marker/animate/clip-in.js +6 -2
  186. package/es/marker/animate/clip-in.js.map +1 -1
  187. package/es/marker/animate/fade-in.d.ts +3 -3
  188. package/es/marker/animate/fade-in.js +11 -3
  189. package/es/marker/animate/fade-in.js.map +1 -1
  190. package/es/marker/animate/fade-out.d.ts +3 -3
  191. package/es/marker/animate/fade-out.js +11 -3
  192. package/es/marker/animate/fade-out.js.map +1 -1
  193. package/es/marker/arc-area.d.ts +8 -5
  194. package/es/marker/arc-area.js +19 -41
  195. package/es/marker/arc-area.js.map +1 -1
  196. package/es/marker/arc-line.d.ts +6 -4
  197. package/es/marker/arc-line.js +12 -9
  198. package/es/marker/arc-line.js.map +1 -1
  199. package/es/marker/area.d.ts +6 -4
  200. package/es/marker/area.js +15 -34
  201. package/es/marker/area.js.map +1 -1
  202. package/es/marker/base.d.ts +2 -3
  203. package/es/marker/base.js.map +1 -1
  204. package/es/marker/common-line.d.ts +11 -7
  205. package/es/marker/common-line.js +14 -34
  206. package/es/marker/common-line.js.map +1 -1
  207. package/es/marker/config.d.ts +2 -0
  208. package/es/marker/config.js +2 -0
  209. package/es/marker/config.js.map +1 -1
  210. package/es/marker/line.d.ts +6 -4
  211. package/es/marker/line.js +10 -4
  212. package/es/marker/line.js.map +1 -1
  213. package/es/marker/mixin/label.d.ts +16 -0
  214. package/es/marker/mixin/label.js +45 -0
  215. package/es/marker/mixin/label.js.map +1 -0
  216. package/es/marker/type.d.ts +19 -16
  217. package/es/marker/type.js.map +1 -1
  218. package/es/poptip/contribution.js +4 -2
  219. package/es/poptip/contribution.js.map +1 -1
  220. package/es/poptip/poptip.d.ts +5 -0
  221. package/es/poptip/poptip.js +85 -19
  222. package/es/poptip/poptip.js.map +1 -1
  223. package/es/poptip/type.d.ts +4 -1
  224. package/es/poptip/type.js.map +1 -1
  225. package/es/scrollbar/scrollbar.d.ts +1 -0
  226. package/es/scrollbar/scrollbar.js +22 -11
  227. package/es/scrollbar/scrollbar.js.map +1 -1
  228. package/es/slider/slider.d.ts +3 -0
  229. package/es/slider/slider.js +49 -26
  230. package/es/slider/slider.js.map +1 -1
  231. package/es/switch/switch.js +2 -2
  232. package/es/switch/switch.js.map +1 -1
  233. package/es/tag/tag.js +59 -56
  234. package/es/tag/tag.js.map +1 -1
  235. package/es/util/event.d.ts +1 -0
  236. package/es/util/event.js +6 -0
  237. package/es/util/event.js.map +1 -0
  238. package/es/weather/weather-box.d.ts +1 -2
  239. package/es/weather/weather-box.js.map +1 -1
  240. package/package.json +7 -7
@@ -1,13 +1,2 @@
1
- import type { IText, ITextGraphicAttribute, EasingType } from '@visactor/vrender-core';
2
- import type { ILabelAnimation, ILabelUpdateAnimation, ILabelUpdateChannelAnimation, LabelContent } from '../type';
3
- export declare function getAnimationAttributes(textAttribute: ITextGraphicAttribute, type: 'fadeIn' | 'fadeOut'): {
4
- from: any;
5
- to: any;
6
- };
7
- export declare function updateAnimation(prev: LabelContent['text'], next: LabelContent['text'], animationConfig: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[]): void;
8
- export declare const update: (prev: LabelContent['text'], next: LabelContent['text'], channel?: string[], options?: ILabelUpdateChannelAnimation['options']) => {
9
- from: Partial<ITextGraphicAttribute> | Partial<import("@visactor/vrender-core").IRichTextGraphicAttribute>;
10
- to: Partial<ITextGraphicAttribute> | Partial<import("@visactor/vrender-core").IRichTextGraphicAttribute>;
11
- };
12
- export declare function playIncreaseCount(prev: IText, next: IText, duration: number, easing: EasingType): void;
1
+ import type { ILabelAnimation } from '../type';
13
2
  export declare const DefaultLabelAnimation: ILabelAnimation;
@@ -2,84 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.DefaultLabelAnimation = exports.playIncreaseCount = exports.update = exports.updateAnimation = exports.getAnimationAttributes = void 0;
6
-
7
- const vrender_animate_1 = require("@visactor/vrender-animate"), vutils_1 = require("@visactor/vutils"), fadeIn = (textAttribute = {}) => {
8
- var _a, _b, _c;
9
- return {
10
- from: {
11
- opacity: 0,
12
- fillOpacity: 0,
13
- strokeOpacity: 0
14
- },
15
- to: {
16
- opacity: null !== (_a = textAttribute.opacity) && void 0 !== _a ? _a : 1,
17
- fillOpacity: null !== (_b = textAttribute.fillOpacity) && void 0 !== _b ? _b : 1,
18
- strokeOpacity: null !== (_c = textAttribute.strokeOpacity) && void 0 !== _c ? _c : 1
19
- }
20
- };
21
- }, fadeOut = (textAttribute = {}) => {
22
- var _a, _b, _c;
23
- return {
24
- from: {
25
- opacity: null !== (_a = textAttribute.opacity) && void 0 !== _a ? _a : 1,
26
- fillOpacity: null !== (_b = textAttribute.fillOpacity) && void 0 !== _b ? _b : 1,
27
- strokeOpacity: null !== (_c = textAttribute.strokeOpacity) && void 0 !== _c ? _c : 1
28
- },
29
- to: {
30
- opacity: 0,
31
- fillOpacity: 0,
32
- strokeOpacity: 0
33
- }
34
- };
35
- }, animationEffects = {
36
- fadeIn: fadeIn,
37
- fadeOut: fadeOut
38
- };
39
-
40
- function getAnimationAttributes(textAttribute, type) {
41
- var _a, _b;
42
- return null !== (_b = null === (_a = animationEffects[type]) || void 0 === _a ? void 0 : _a.call(animationEffects, textAttribute)) && void 0 !== _b ? _b : {
43
- from: {},
44
- to: {}
45
- };
46
- }
47
-
48
- function updateAnimation(prev, next, animationConfig) {
49
- if (!(0, vutils_1.isArray)(animationConfig)) {
50
- const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0} = animationConfig;
51
- return prev.animate().to(next.attribute, duration, easing), void (increaseEffect && "text" === prev.type && "text" === next.type && playIncreaseCount(prev, next, duration, easing));
52
- }
53
- animationConfig.forEach((cfg => {
54
- const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0, channel: channel} = cfg, {to: to} = (0,
55
- exports.update)(prev, next, channel, cfg.options);
56
- (0, vutils_1.isEmpty)(to) || prev.animate().to(to, duration, easing), increaseEffect && "text" === prev.type && "text" === next.type && playIncreaseCount(prev, next, duration, easing);
57
- }));
58
- }
59
-
60
- exports.getAnimationAttributes = getAnimationAttributes, exports.updateAnimation = updateAnimation;
61
-
62
- const update = (prev, next, channel, options) => {
63
- const from = Object.assign({}, prev.attribute), to = Object.assign({}, next.attribute);
64
- return (0, vutils_1.array)(null == options ? void 0 : options.excludeChannels).forEach((key => {
65
- delete to[key];
66
- })), Object.keys(to).forEach((key => {
67
- channel && !channel.includes(key) && delete to[key];
68
- })), {
69
- from: from,
70
- to: to
71
- };
72
- };
73
-
74
- function playIncreaseCount(prev, next, duration, easing) {
75
- prev.attribute.text !== next.attribute.text && (0, vutils_1.isValidNumber)(Number(prev.attribute.text) * Number(next.attribute.text)) && prev.animate().play(new vrender_animate_1.IncreaseCount({
76
- text: prev.attribute.text
77
- }, {
78
- text: next.attribute.text
79
- }, duration, easing));
80
- }
81
-
82
- exports.update = update, exports.playIncreaseCount = playIncreaseCount, exports.DefaultLabelAnimation = {
5
+ }), exports.DefaultLabelAnimation = void 0, exports.DefaultLabelAnimation = {
83
6
  mode: "same-time",
84
7
  duration: 300,
85
8
  easing: "linear"
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/label/animate/animate.ts"],"names":[],"mappings":";;;AACA,+DAA0D;AAE1D,6CAA0E;AAE1E,MAAM,MAAM,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OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC5C,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC5B,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACrC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;SAChB;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACtB,CAAC,CAAC;AAjBW,QAAA,MAAM,UAiBjB;AAEF,SAAgB,iBAAiB,CAAC,IAAW,EAAE,IAAW,EAAE,QAAgB,EAAE,MAAkB;IAC9F,IACE,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI;QAC3C,IAAA,sBAAa,EAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EACxE;QACA,IAAI;aACD,OAAO,EAAE;aACT,IAAI,CACH,IAAI,+BAAa,CACf,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAc,EAAE,EACvC,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAc,EAAE,EACvC,QAAQ,EACR,MAAM,CACA,CACT,CAAC;KACL;AACH,CAAC;AAhBD,8CAgBC;AAEY,QAAA,qBAAqB,GAAoB;IACpD,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,GAAG;IACb,MAAM,EAAE,QAAsB;CAC/B,CAAC","file":"animate.js","sourcesContent":["import type { IText, ITextGraphicAttribute, EasingType } from '@visactor/vrender-core';\nimport { IncreaseCount } from '@visactor/vrender-animate';\nimport type { ILabelAnimation, ILabelUpdateAnimation, ILabelUpdateChannelAnimation, LabelContent } from '../type';\nimport { array, isArray, isEmpty, isValidNumber } from '@visactor/vutils';\n\nconst fadeIn = (textAttribute: ITextGraphicAttribute = {}) => {\n return {\n from: {\n opacity: 0,\n fillOpacity: 0,\n strokeOpacity: 0\n },\n to: {\n opacity: textAttribute.opacity ?? 1,\n fillOpacity: textAttribute.fillOpacity ?? 1,\n strokeOpacity: textAttribute.strokeOpacity ?? 1\n }\n };\n};\n\nconst fadeOut = (textAttribute: ITextGraphicAttribute = {}) => {\n return {\n from: {\n opacity: textAttribute.opacity ?? 1,\n fillOpacity: textAttribute.fillOpacity ?? 1,\n strokeOpacity: textAttribute.strokeOpacity ?? 1\n },\n to: {\n opacity: 0,\n fillOpacity: 0,\n strokeOpacity: 0\n }\n };\n};\n\nconst animationEffects = { fadeIn, fadeOut };\n\nexport function getAnimationAttributes(\n textAttribute: ITextGraphicAttribute,\n type: 'fadeIn' | 'fadeOut'\n): {\n from: any;\n to: any;\n} {\n return animationEffects[type]?.(textAttribute) ?? { from: {}, to: {} };\n}\n\nexport function updateAnimation(\n prev: LabelContent['text'],\n next: LabelContent['text'],\n animationConfig: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[]\n) {\n if (!isArray(animationConfig)) {\n const { duration, easing, increaseEffect = true } = animationConfig;\n prev.animate().to(next.attribute, duration, easing);\n if (increaseEffect && prev.type === 'text' && next.type === 'text') {\n playIncreaseCount(prev as IText, next as IText, duration, easing);\n }\n return;\n }\n\n animationConfig.forEach(cfg => {\n const { duration, easing, increaseEffect = true, channel } = cfg;\n const { to } = update(prev, next, channel, cfg.options);\n if (!isEmpty(to)) {\n prev.animate().to(to, duration, easing);\n }\n\n if (increaseEffect && prev.type === 'text' && next.type === 'text') {\n playIncreaseCount(prev as IText, next as IText, duration, easing);\n }\n });\n}\n\nexport const update = (\n prev: LabelContent['text'],\n next: LabelContent['text'],\n channel?: string[],\n options?: ILabelUpdateChannelAnimation['options']\n) => {\n const from = Object.assign({}, prev.attribute);\n const to = Object.assign({}, next.attribute);\n array(options?.excludeChannels).forEach(key => {\n delete to[key];\n });\n Object.keys(to).forEach(key => {\n if (channel && !channel.includes(key)) {\n delete to[key];\n }\n });\n return { from, to };\n};\n\nexport function playIncreaseCount(prev: IText, next: IText, duration: number, easing: EasingType) {\n if (\n prev.attribute.text !== next.attribute.text &&\n isValidNumber(Number(prev.attribute.text) * Number(next.attribute.text))\n ) {\n prev\n .animate()\n .play(\n new IncreaseCount(\n { text: prev.attribute.text as string },\n { text: next.attribute.text as string },\n duration,\n easing\n ) as any\n );\n }\n}\n\nexport const DefaultLabelAnimation: ILabelAnimation = {\n mode: 'same-time',\n duration: 300,\n easing: 'linear' as EasingType\n};\n"]}
1
+ {"version":3,"sources":["../src/label/animate/animate.ts"],"names":[],"mappings":";;;AAGa,QAAA,qBAAqB,GAAoB;IACpD,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,GAAG;IACb,MAAM,EAAE,QAAsB;CAC/B,CAAC","file":"animate.js","sourcesContent":["import type { EasingType } from '@visactor/vrender-core';\nimport type { ILabelAnimation } from '../type';\n\nexport const DefaultLabelAnimation: ILabelAnimation = {\n mode: 'same-time',\n duration: 300,\n easing: 'linear' as EasingType\n};\n"]}
@@ -1,12 +1,12 @@
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 { AbstractComponent } from '../core/base';
4
3
  import type { PointLocationCfg } from '../core/type';
5
4
  import type { Bitmap, BitmapTool } from './overlap';
6
5
  import { bitmapTool } from './overlap';
7
6
  import type { BaseLabelAttrs, OverlapAttrs, LabelItem, ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation, LabelContent } from './type';
8
7
  import type { ComponentOptions } from '../interface';
9
- export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {
8
+ import { AnimateComponent } from '../animation/animate-component';
9
+ export declare class LabelBase<T extends BaseLabelAttrs> extends AnimateComponent<T> {
10
10
  name: string;
11
11
  protected _baseMarks?: IGraphic[];
12
12
  protected _isCollectionBase: boolean;
@@ -52,11 +52,13 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractCompone
52
52
  protected _overlapGlobal(labels: (IText | IRichText)[], option: OverlapAttrs, bmpTool: BitmapTool, bitmap: Bitmap): (IRichText | IText)[];
53
53
  protected _processClampForce(text: IText, bmpTool: BitmapTool, bitmap: Bitmap, overlapPadding?: number): boolean;
54
54
  protected _overlapByStrategy(labels: (IText | IRichText)[], option: OverlapAttrs, bmpTool: BitmapTool, bitmap: Bitmap): (IRichText | IText)[];
55
+ protected isMarkInsideRect(baseMark: IGraphic, bmpTool: BitmapTool): boolean;
55
56
  protected getBaseMarkGroup(): IGroup;
56
57
  protected getGraphicBounds(graphic?: IGraphic, point?: Partial<PointLocationCfg>, position?: string): IBoundsLike;
57
58
  protected _renderLabels(labels: (IText | IRichText)[]): void;
58
- protected runEnterAnimation(text: IText | IRichText): void;
59
+ protected runEnterAnimation(text: IText | IRichText, labelLine?: ILine): void;
59
60
  protected _runUpdateAnimation(prevLabel: LabelContent, currentLabel: LabelContent): void;
61
+ protected _syncStateWithRelatedGraphic(relatedGraphic: IGraphic): void;
60
62
  protected _addLabel(label: LabelContent, texts?: LabelContent['text'][], labelLines?: LabelContent['labelLine'][], index?: number): void;
61
63
  protected _updateLabel(prevLabel: LabelContent, currentLabel: LabelContent): void;
62
64
  protected _removeLabel(textMap: Map<any, LabelContent>): void;
package/cjs/label/base.js CHANGED
@@ -14,11 +14,11 @@ 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"), vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), 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");
17
+ const vrender_core_1 = require("@visactor/vrender-core"), 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");
18
18
 
19
19
  (0, register_1.loadLabelComponent)();
20
20
 
21
- class LabelBase extends base_1.AbstractComponent {
21
+ class LabelBase extends animate_component_1.AnimateComponent {
22
22
  setBitmap(bitmap) {
23
23
  this._bitmap = bitmap;
24
24
  }
@@ -85,6 +85,10 @@ class LabelBase extends base_1.AbstractComponent {
85
85
  render() {
86
86
  if (this._prepare(), (0, vutils_1.isNil)(this._idToGraphic) || this._isCollectionBase && (0,
87
87
  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
+ }));
88
92
  const {overlap: overlap, smartInvert: smartInvert, dataFilter: dataFilter, customLayoutFunc: customLayoutFunc, customOverlapFunc: customOverlapFunc} = this.attribute;
89
93
  let data = this.attribute.data;
90
94
  if ((0, vutils_1.isFunction)(dataFilter) && (data = dataFilter(data)), data && data.length) {
@@ -97,7 +101,10 @@ class LabelBase extends base_1.AbstractComponent {
97
101
  (0, vutils_1.isFunction)(this.attribute.onAfterOverlapping) && this.attribute.onAfterOverlapping(labels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null, this),
98
102
  labels && labels.length && labels.forEach((label => {
99
103
  this._bindEvent(label), this._setStatesOfText(label);
100
- })), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels);
104
+ })), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels),
105
+ !1 !== this._enableAnimation && this._baseMarks.forEach(((mark, index) => {
106
+ mark.initAttributes(markAttributeList[index]);
107
+ }));
101
108
  }
102
109
  _bindEvent(target) {
103
110
  if (this.attribute.disableTriggerEvent) return;
@@ -150,20 +157,7 @@ class LabelBase extends base_1.AbstractComponent {
150
157
  textData && baseMark && ((0, vutils_1.isValid)(textData.id) || (textData.id = `vrender-component-${this.name}-${i}`),
151
158
  this._idToGraphic.set(textData.id, baseMark));
152
159
  }
153
- if (!1 !== this.attribute.animation) {
154
- const {animation: animation, animationEnter: animationEnter, animationExit: animationExit, animationUpdate: animationUpdate} = this.attribute, animationCfg = (0,
155
- vutils_1.isObject)(animation) ? animation : {};
156
- this._animationConfig = {
157
- enter: !1 !== animationEnter && (0, vutils_1.merge)({}, animate_1.DefaultLabelAnimation, animationCfg, null != animationEnter ? animationEnter : {}),
158
- exit: !1 !== animationExit && (0, vutils_1.merge)({}, animate_1.DefaultLabelAnimation, animationCfg, null != animationExit ? animationExit : {}),
159
- update: !1 !== animationUpdate && ((0, vutils_1.isArray)(animationUpdate) ? animationUpdate : (0,
160
- vutils_1.merge)({}, animate_1.DefaultLabelAnimation, animationCfg, null != animationUpdate ? animationUpdate : {}))
161
- };
162
- } else this._animationConfig = {
163
- enter: !1,
164
- exit: !1,
165
- update: !1
166
- };
160
+ this._prepareAnimate(animate_1.DefaultLabelAnimation);
167
161
  }
168
162
  }
169
163
  getRelatedGraphic(item) {
@@ -213,7 +207,7 @@ class LabelBase extends base_1.AbstractComponent {
213
207
  "shiftY" === (null == strategy ? void 0 : strategy.type) ? this._overlapGlobal(labels, option, bmpTool, bitmap) : this._overlapByStrategy(labels, option, bmpTool, bitmap);
214
208
  }
215
209
  _overlapGlobal(labels, option, bmpTool, bitmap) {
216
- let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity));
210
+ let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity && this.isMarkInsideRect(this.getRelatedGraphic(label.attribute), bmpTool)));
217
211
  const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, overlapPadding: overlapPadding, strategy: strategy} = option;
218
212
  if (clampForce) for (let i = 0; i < result.length; i++) {
219
213
  const text = labels[i], {dx: dx = 0, dy: dy = 0} = (0, overlap_1.clampText)(text, bmpTool.width, bmpTool.height, bmpTool.padding);
@@ -273,12 +267,7 @@ class LabelBase extends base_1.AbstractComponent {
273
267
  for (let i = 0; i < labels.length; i++) {
274
268
  if (!1 === labels[i].attribute.visible) continue;
275
269
  const text = labels[i], baseMark = this.getRelatedGraphic(text.attribute);
276
- if (text.update(), !(0, vutils_1.isRectIntersect)(baseMark.AABBBounds, {
277
- x1: 0,
278
- x2: bmpTool.width,
279
- y1: 0,
280
- y2: bmpTool.height
281
- }, !0)) continue;
270
+ if (text.update(), !this.isMarkInsideRect(baseMark, bmpTool)) continue;
282
271
  if ((0, overlap_1.canPlace)(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {
283
272
  if (!checkBounds) {
284
273
  bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, text.AABBBounds, !0)), result.push(text);
@@ -308,13 +297,41 @@ class LabelBase extends base_1.AbstractComponent {
308
297
  }
309
298
  return result;
310
299
  }
300
+ isMarkInsideRect(baseMark, bmpTool) {
301
+ const {left: left, right: right, top: top, bottom: bottom} = bmpTool.padding, rect = {
302
+ x1: -left,
303
+ x2: bmpTool.width + right,
304
+ y1: -top,
305
+ y2: bmpTool.height + bottom
306
+ }, bounds = baseMark.AABBBounds;
307
+ if (0 !== bounds.width() && 0 !== bounds.height()) return (0, vutils_1.isRectIntersect)(baseMark.AABBBounds, rect, !0);
308
+ const {attribute: attribute} = baseMark;
309
+ if ("rect" === baseMark.type) {
310
+ const {x: x, x1: x1, y: y, y1: y1} = attribute;
311
+ return (0, vutils_1.pointInRect)({
312
+ x: null != x ? x : x1,
313
+ y: null != y ? y : y1
314
+ }, rect, !0);
315
+ }
316
+ return "x" in attribute && "y" in attribute && (0, vutils_1.pointInRect)({
317
+ x: attribute.x,
318
+ y: attribute.y
319
+ }, rect, !0);
320
+ }
311
321
  getBaseMarkGroup() {
312
322
  const {baseMarkGroupName: baseMarkGroupName} = this.attribute;
313
323
  if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
314
324
  }
315
325
  getGraphicBounds(graphic, point = {}, position) {
326
+ var _a;
316
327
  if (graphic) {
317
- if (!1 !== graphic.attribute.visible) return graphic.AABBBounds;
328
+ if (!1 !== graphic.attribute.visible) {
329
+ if (null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) {
330
+ const clonedGraphic = graphic.clone();
331
+ return Object.assign(clonedGraphic.attribute, graphic.getAttributes(!0)), clonedGraphic.AABBBounds;
332
+ }
333
+ return graphic.AABBBounds;
334
+ }
318
335
  const {x: x, y: y} = graphic.attribute;
319
336
  return {
320
337
  x1: x,
@@ -371,18 +388,23 @@ class LabelBase extends base_1.AbstractComponent {
371
388
  }
372
389
  })), this._removeLabel(prevTextMap), this._graphicToText = currentTextMap;
373
390
  }
374
- runEnterAnimation(text) {
391
+ runEnterAnimation(text, labelLine) {
375
392
  if (!1 === this._enableAnimation || !this._animationConfig.enter) return;
376
393
  const relatedGraphic = this.getRelatedGraphic(text.attribute), {enter: enter} = this._animationConfig;
377
- text.applyAnimationState([ "enter" ], [ {
394
+ [ text, labelLine ].filter(Boolean).forEach((item => item.applyAnimationState([ "enter" ], [ {
378
395
  name: "enter",
379
396
  animation: Object.assign(Object.assign({}, enter), {
397
+ type: "labelEnter",
380
398
  selfOnly: !0,
381
399
  customParameters: {
382
- relatedGraphic: relatedGraphic
400
+ relatedGraphic: relatedGraphic,
401
+ relatedGraphics: this._idToGraphic,
402
+ config: Object.assign(Object.assign({}, enter), {
403
+ type: item === text ? enter.type : "fadeIn"
404
+ })
383
405
  }
384
406
  })
385
- } ]);
407
+ } ])));
386
408
  }
387
409
  _runUpdateAnimation(prevLabel, currentLabel) {
388
410
  if (!1 === this._enableAnimation || !this._animationConfig.update) return;
@@ -402,9 +424,13 @@ class LabelBase extends base_1.AbstractComponent {
402
424
  }
403
425
  } ]);
404
426
  }
427
+ _syncStateWithRelatedGraphic(relatedGraphic) {
428
+ this.attribute.syncState && relatedGraphic && relatedGraphic.on("afterStateUpdate", this._handleRelatedGraphicSetState);
429
+ }
405
430
  _addLabel(label, texts, labelLines, index) {
406
- const {text: text, labelLine: labelLine} = label;
407
- text && this.add(text), labelLine && this.add(labelLine), this.runEnterAnimation(text);
431
+ const {text: text, labelLine: labelLine} = label, relatedGraphic = this.getRelatedGraphic(text.attribute);
432
+ this._syncStateWithRelatedGraphic(relatedGraphic), text && this.add(text), labelLine && this.add(labelLine),
433
+ this.runEnterAnimation(text, labelLine);
408
434
  }
409
435
  _updateLabel(prevLabel, currentLabel) {
410
436
  const {text: prevText, labelLine: prevLabelLine} = prevLabel, {text: curText, labelLine: curLabelLine} = currentLabel;
@@ -419,16 +445,16 @@ class LabelBase extends base_1.AbstractComponent {
419
445
  var _a;
420
446
  label.text.applyAnimationState([ "exit" ], [ {
421
447
  name: "exit",
422
- animation: Object.assign({
448
+ animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
423
449
  type: "fadeOut"
424
- }, this._animationConfig.exit)
450
+ })
425
451
  } ], (() => {
426
452
  removeLabelAndLine(label);
427
453
  })), null === (_a = label.labelLine) || void 0 === _a || _a.applyAnimationState([ "exit" ], [ {
428
454
  name: "exit",
429
- animation: Object.assign({
455
+ animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
430
456
  type: "fadeOut"
431
- }, this._animationConfig.exit)
457
+ })
432
458
  } ], (() => {}));
433
459
  })) : textMap.forEach((label => {
434
460
  removeLabelAndLine(label);