@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,79 +1,3 @@
1
- import { IncreaseCount } from "@visactor/vrender-animate";
2
-
3
- import { array, isArray, isEmpty, isValidNumber } from "@visactor/vutils";
4
-
5
- const fadeIn = (textAttribute = {}) => {
6
- var _a, _b, _c;
7
- return {
8
- from: {
9
- opacity: 0,
10
- fillOpacity: 0,
11
- strokeOpacity: 0
12
- },
13
- to: {
14
- opacity: null !== (_a = textAttribute.opacity) && void 0 !== _a ? _a : 1,
15
- fillOpacity: null !== (_b = textAttribute.fillOpacity) && void 0 !== _b ? _b : 1,
16
- strokeOpacity: null !== (_c = textAttribute.strokeOpacity) && void 0 !== _c ? _c : 1
17
- }
18
- };
19
- }, fadeOut = (textAttribute = {}) => {
20
- var _a, _b, _c;
21
- return {
22
- from: {
23
- opacity: null !== (_a = textAttribute.opacity) && void 0 !== _a ? _a : 1,
24
- fillOpacity: null !== (_b = textAttribute.fillOpacity) && void 0 !== _b ? _b : 1,
25
- strokeOpacity: null !== (_c = textAttribute.strokeOpacity) && void 0 !== _c ? _c : 1
26
- },
27
- to: {
28
- opacity: 0,
29
- fillOpacity: 0,
30
- strokeOpacity: 0
31
- }
32
- };
33
- }, animationEffects = {
34
- fadeIn: fadeIn,
35
- fadeOut: fadeOut
36
- };
37
-
38
- export function getAnimationAttributes(textAttribute, type) {
39
- var _a, _b;
40
- return null !== (_b = null === (_a = animationEffects[type]) || void 0 === _a ? void 0 : _a.call(animationEffects, textAttribute)) && void 0 !== _b ? _b : {
41
- from: {},
42
- to: {}
43
- };
44
- }
45
-
46
- export function updateAnimation(prev, next, animationConfig) {
47
- if (!isArray(animationConfig)) {
48
- const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0} = animationConfig;
49
- return prev.animate().to(next.attribute, duration, easing), void (increaseEffect && "text" === prev.type && "text" === next.type && playIncreaseCount(prev, next, duration, easing));
50
- }
51
- animationConfig.forEach((cfg => {
52
- const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0, channel: channel} = cfg, {to: to} = update(prev, next, channel, cfg.options);
53
- isEmpty(to) || prev.animate().to(to, duration, easing), increaseEffect && "text" === prev.type && "text" === next.type && playIncreaseCount(prev, next, duration, easing);
54
- }));
55
- }
56
-
57
- export const update = (prev, next, channel, options) => {
58
- const from = Object.assign({}, prev.attribute), to = Object.assign({}, next.attribute);
59
- return array(null == options ? void 0 : options.excludeChannels).forEach((key => {
60
- delete to[key];
61
- })), Object.keys(to).forEach((key => {
62
- channel && !channel.includes(key) && delete to[key];
63
- })), {
64
- from: from,
65
- to: to
66
- };
67
- };
68
-
69
- export function playIncreaseCount(prev, next, duration, easing) {
70
- prev.attribute.text !== next.attribute.text && isValidNumber(Number(prev.attribute.text) * Number(next.attribute.text)) && prev.animate().play(new IncreaseCount({
71
- text: prev.attribute.text
72
- }, {
73
- text: next.attribute.text
74
- }, duration, easing));
75
- }
76
-
77
1
  export const DefaultLabelAnimation = {
78
2
  mode: "same-time",
79
3
  duration: 300,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/label/animate/animate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE1E,MAAM,MAAM,GAAG,CAAC,gBAAuC,EAAE,EAAE,EAAE;;IAC3D,OAAO;QACL,IAAI,EAAE;YACJ,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,CAAC;SACjB;QACD,EAAE,EAAE;YACF,OAAO,EAAE,MAAA,aAAa,CAAC,OAAO,mCAAI,CAAC;YACnC,WAAW,EAAE,MAAA,aAAa,CAAC,WAAW,mCAAI,CAAC;YAC3C,aAAa,EAAE,MAAA,aAAa,CAAC,aAAa,mCAAI,CAAC;SAChD;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,gBAAuC,EAAE,EAAE,EAAE;;IAC5D,OAAO;QACL,IAAI,EAAE;YACJ,OAAO,EAAE,MAAA,aAAa,CAAC,OAAO,mCAAI,CAAC;YACnC,WAAW,EAAE,MAAA,aAAa,CAAC,WAAW,mCAAI,CAAC;YAC3C,aAAa,EAAE,MAAA,aAAa,CAAC,aAAa,mCAAI,CAAC;SAChD;QACD,EAAE,EAAE;YACF,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,CAAC;SACjB;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAE7C,MAAM,UAAU,sBAAsB,CACpC,aAAoC,EACpC,IAA0B;;IAK1B,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EACvC,QAAQ,EACR,MAAM,CACA,CACT,CAAC;KACL;AACH,CAAC;AAED,MAAM,CAAC,MAAM,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,MAAM,CAAC,MAAM,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/es/label/base.js CHANGED
@@ -10,9 +10,7 @@ var __rest = this && this.__rest || function(s, e) {
10
10
 
11
11
  import { graphicCreator, AttributeUpdateType, CustomPath2D } from "@visactor/vrender-core";
12
12
 
13
- import { isFunction, isEmpty, isValid, isString, merge, isRectIntersect, isNil, isArray, isObject } from "@visactor/vutils";
14
-
15
- import { AbstractComponent } from "../core/base";
13
+ import { isFunction, isEmpty, isValid, isString, merge, isRectIntersect, isNil, isArray, isObject, pointInRect } from "@visactor/vutils";
16
14
 
17
15
  import { labelSmartInvert, contrastAccessibilityChecker, smartInvertStrategy } from "../util/label-smartInvert";
18
16
 
@@ -30,9 +28,11 @@ import { loadLabelComponent } from "./register";
30
28
 
31
29
  import { shiftY } from "./overlap/shiftY";
32
30
 
31
+ import { AnimateComponent } from "../animation/animate-component";
32
+
33
33
  loadLabelComponent();
34
34
 
35
- export class LabelBase extends AbstractComponent {
35
+ export class LabelBase extends AnimateComponent {
36
36
  setBitmap(bitmap) {
37
37
  this._bitmap = bitmap;
38
38
  }
@@ -95,6 +95,10 @@ export class LabelBase extends AbstractComponent {
95
95
  }
96
96
  render() {
97
97
  if (this._prepare(), isNil(this._idToGraphic) || this._isCollectionBase && isNil(this._idToPoint)) return;
98
+ const markAttributeList = [];
99
+ !1 !== this._enableAnimation && this._baseMarks.forEach((mark => {
100
+ markAttributeList.push(mark.attribute), mark.initAttributes(mark.getAttributes(!0));
101
+ }));
98
102
  const {overlap: overlap, smartInvert: smartInvert, dataFilter: dataFilter, customLayoutFunc: customLayoutFunc, customOverlapFunc: customOverlapFunc} = this.attribute;
99
103
  let data = this.attribute.data;
100
104
  if (isFunction(dataFilter) && (data = dataFilter(data)), data && data.length) {
@@ -107,7 +111,10 @@ export class LabelBase extends AbstractComponent {
107
111
  isFunction(this.attribute.onAfterOverlapping) && this.attribute.onAfterOverlapping(labels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null, this),
108
112
  labels && labels.length && labels.forEach((label => {
109
113
  this._bindEvent(label), this._setStatesOfText(label);
110
- })), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels);
114
+ })), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels),
115
+ !1 !== this._enableAnimation && this._baseMarks.forEach(((mark, index) => {
116
+ mark.initAttributes(markAttributeList[index]);
117
+ }));
111
118
  }
112
119
  _bindEvent(target) {
113
120
  if (this.attribute.disableTriggerEvent) return;
@@ -160,18 +167,7 @@ export class LabelBase extends AbstractComponent {
160
167
  textData && baseMark && (isValid(textData.id) || (textData.id = `vrender-component-${this.name}-${i}`),
161
168
  this._idToGraphic.set(textData.id, baseMark));
162
169
  }
163
- if (!1 !== this.attribute.animation) {
164
- const {animation: animation, animationEnter: animationEnter, animationExit: animationExit, animationUpdate: animationUpdate} = this.attribute, animationCfg = isObject(animation) ? animation : {};
165
- this._animationConfig = {
166
- enter: !1 !== animationEnter && merge({}, DefaultLabelAnimation, animationCfg, null != animationEnter ? animationEnter : {}),
167
- exit: !1 !== animationExit && merge({}, DefaultLabelAnimation, animationCfg, null != animationExit ? animationExit : {}),
168
- update: !1 !== animationUpdate && (isArray(animationUpdate) ? animationUpdate : merge({}, DefaultLabelAnimation, animationCfg, null != animationUpdate ? animationUpdate : {}))
169
- };
170
- } else this._animationConfig = {
171
- enter: !1,
172
- exit: !1,
173
- update: !1
174
- };
170
+ this._prepareAnimate(DefaultLabelAnimation);
175
171
  }
176
172
  }
177
173
  getRelatedGraphic(item) {
@@ -220,7 +216,7 @@ export class LabelBase extends AbstractComponent {
220
216
  "shiftY" === (null == strategy ? void 0 : strategy.type) ? this._overlapGlobal(labels, option, bmpTool, bitmap) : this._overlapByStrategy(labels, option, bmpTool, bitmap);
221
217
  }
222
218
  _overlapGlobal(labels, option, bmpTool, bitmap) {
223
- let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity));
219
+ let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity && this.isMarkInsideRect(this.getRelatedGraphic(label.attribute), bmpTool)));
224
220
  const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, overlapPadding: overlapPadding, strategy: strategy} = option;
225
221
  if (clampForce) for (let i = 0; i < result.length; i++) {
226
222
  const text = labels[i], {dx: dx = 0, dy: dy = 0} = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
@@ -279,12 +275,7 @@ export class LabelBase extends AbstractComponent {
279
275
  for (let i = 0; i < labels.length; i++) {
280
276
  if (!1 === labels[i].attribute.visible) continue;
281
277
  const text = labels[i], baseMark = this.getRelatedGraphic(text.attribute);
282
- if (text.update(), !isRectIntersect(baseMark.AABBBounds, {
283
- x1: 0,
284
- x2: bmpTool.width,
285
- y1: 0,
286
- y2: bmpTool.height
287
- }, !0)) continue;
278
+ if (text.update(), !this.isMarkInsideRect(baseMark, bmpTool)) continue;
288
279
  if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {
289
280
  if (!checkBounds) {
290
281
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
@@ -314,13 +305,41 @@ export class LabelBase extends AbstractComponent {
314
305
  }
315
306
  return result;
316
307
  }
308
+ isMarkInsideRect(baseMark, bmpTool) {
309
+ const {left: left, right: right, top: top, bottom: bottom} = bmpTool.padding, rect = {
310
+ x1: -left,
311
+ x2: bmpTool.width + right,
312
+ y1: -top,
313
+ y2: bmpTool.height + bottom
314
+ }, bounds = baseMark.AABBBounds;
315
+ if (0 !== bounds.width() && 0 !== bounds.height()) return isRectIntersect(baseMark.AABBBounds, rect, !0);
316
+ const {attribute: attribute} = baseMark;
317
+ if ("rect" === baseMark.type) {
318
+ const {x: x, x1: x1, y: y, y1: y1} = attribute;
319
+ return pointInRect({
320
+ x: null != x ? x : x1,
321
+ y: null != y ? y : y1
322
+ }, rect, !0);
323
+ }
324
+ return "x" in attribute && "y" in attribute && pointInRect({
325
+ x: attribute.x,
326
+ y: attribute.y
327
+ }, rect, !0);
328
+ }
317
329
  getBaseMarkGroup() {
318
330
  const {baseMarkGroupName: baseMarkGroupName} = this.attribute;
319
331
  if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
320
332
  }
321
333
  getGraphicBounds(graphic, point = {}, position) {
334
+ var _a;
322
335
  if (graphic) {
323
- if (!1 !== graphic.attribute.visible) return graphic.AABBBounds;
336
+ if (!1 !== graphic.attribute.visible) {
337
+ if (null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) {
338
+ const clonedGraphic = graphic.clone();
339
+ return Object.assign(clonedGraphic.attribute, graphic.getAttributes(!0)), clonedGraphic.AABBBounds;
340
+ }
341
+ return graphic.AABBBounds;
342
+ }
324
343
  const {x: x, y: y} = graphic.attribute;
325
344
  return {
326
345
  x1: x,
@@ -377,18 +396,23 @@ export class LabelBase extends AbstractComponent {
377
396
  }
378
397
  })), this._removeLabel(prevTextMap), this._graphicToText = currentTextMap;
379
398
  }
380
- runEnterAnimation(text) {
399
+ runEnterAnimation(text, labelLine) {
381
400
  if (!1 === this._enableAnimation || !this._animationConfig.enter) return;
382
401
  const relatedGraphic = this.getRelatedGraphic(text.attribute), {enter: enter} = this._animationConfig;
383
- text.applyAnimationState([ "enter" ], [ {
402
+ [ text, labelLine ].filter(Boolean).forEach((item => item.applyAnimationState([ "enter" ], [ {
384
403
  name: "enter",
385
404
  animation: Object.assign(Object.assign({}, enter), {
405
+ type: "labelEnter",
386
406
  selfOnly: !0,
387
407
  customParameters: {
388
- relatedGraphic: relatedGraphic
408
+ relatedGraphic: relatedGraphic,
409
+ relatedGraphics: this._idToGraphic,
410
+ config: Object.assign(Object.assign({}, enter), {
411
+ type: item === text ? enter.type : "fadeIn"
412
+ })
389
413
  }
390
414
  })
391
- } ]);
415
+ } ])));
392
416
  }
393
417
  _runUpdateAnimation(prevLabel, currentLabel) {
394
418
  if (!1 === this._enableAnimation || !this._animationConfig.update) return;
@@ -408,9 +432,13 @@ export class LabelBase extends AbstractComponent {
408
432
  }
409
433
  } ]);
410
434
  }
435
+ _syncStateWithRelatedGraphic(relatedGraphic) {
436
+ this.attribute.syncState && relatedGraphic && relatedGraphic.on("afterStateUpdate", this._handleRelatedGraphicSetState);
437
+ }
411
438
  _addLabel(label, texts, labelLines, index) {
412
- const {text: text, labelLine: labelLine} = label;
413
- text && this.add(text), labelLine && this.add(labelLine), this.runEnterAnimation(text);
439
+ const {text: text, labelLine: labelLine} = label, relatedGraphic = this.getRelatedGraphic(text.attribute);
440
+ this._syncStateWithRelatedGraphic(relatedGraphic), text && this.add(text), labelLine && this.add(labelLine),
441
+ this.runEnterAnimation(text, labelLine);
414
442
  }
415
443
  _updateLabel(prevLabel, currentLabel) {
416
444
  const {text: prevText, labelLine: prevLabelLine} = prevLabel, {text: curText, labelLine: curLabelLine} = currentLabel;
@@ -425,16 +453,16 @@ export class LabelBase extends AbstractComponent {
425
453
  var _a;
426
454
  label.text.applyAnimationState([ "exit" ], [ {
427
455
  name: "exit",
428
- animation: Object.assign({
456
+ animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
429
457
  type: "fadeOut"
430
- }, this._animationConfig.exit)
458
+ })
431
459
  } ], (() => {
432
460
  removeLabelAndLine(label);
433
461
  })), null === (_a = label.labelLine) || void 0 === _a || _a.applyAnimationState([ "exit" ], [ {
434
462
  name: "exit",
435
- animation: Object.assign({
463
+ animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
436
464
  type: "fadeOut"
437
- }, this._animationConfig.exit)
465
+ })
438
466
  } ], (() => {}));
439
467
  })) : textMap.forEach((label => {
440
468
  removeLabelAndLine(label);