@antv/component 2.1.1-alpha.1 → 2.1.1-alpha.3

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 (516) hide show
  1. package/dist/component.min.js +1 -1
  2. package/esm/animation/fadeIn.d.ts +1 -1
  3. package/esm/animation/fadeOut.d.ts +1 -1
  4. package/esm/animation/utils.d.ts +3 -3
  5. package/esm/animation/utils.js +37 -31
  6. package/esm/animation/utils.js.map +1 -1
  7. package/esm/constant.js +1 -1
  8. package/esm/constant.js.map +1 -1
  9. package/esm/core/component.js +43 -30
  10. package/esm/core/component.js.map +1 -1
  11. package/esm/shapes/Text.js +21 -13
  12. package/esm/shapes/Text.js.map +1 -1
  13. package/esm/ui/axis/axis.d.ts +1 -1
  14. package/esm/ui/axis/axis.js +31 -25
  15. package/esm/ui/axis/axis.js.map +1 -1
  16. package/esm/ui/axis/constant.js +13 -11
  17. package/esm/ui/axis/constant.js.map +1 -1
  18. package/esm/ui/axis/guides/grid.d.ts +1 -1
  19. package/esm/ui/axis/guides/grid.js +34 -29
  20. package/esm/ui/axis/guides/grid.js.map +1 -1
  21. package/esm/ui/axis/guides/labels.js +83 -76
  22. package/esm/ui/axis/guides/labels.js.map +1 -1
  23. package/esm/ui/axis/guides/line.js +87 -74
  24. package/esm/ui/axis/guides/line.js.map +1 -1
  25. package/esm/ui/axis/guides/ticks.d.ts +1 -1
  26. package/esm/ui/axis/guides/ticks.js +39 -31
  27. package/esm/ui/axis/guides/ticks.js.map +1 -1
  28. package/esm/ui/axis/guides/title.d.ts +1 -1
  29. package/esm/ui/axis/guides/title.js +37 -33
  30. package/esm/ui/axis/guides/title.js.map +1 -1
  31. package/esm/ui/axis/guides/utils.js +12 -10
  32. package/esm/ui/axis/guides/utils.js.map +1 -1
  33. package/esm/ui/axis/overlap/autoEllipsis.js +19 -12
  34. package/esm/ui/axis/overlap/autoEllipsis.js.map +1 -1
  35. package/esm/ui/axis/overlap/autoHide.js +24 -20
  36. package/esm/ui/axis/overlap/autoHide.js.map +1 -1
  37. package/esm/ui/axis/overlap/autoRotate.js +25 -11
  38. package/esm/ui/axis/overlap/autoRotate.js.map +1 -1
  39. package/esm/ui/axis/overlap/autoWrap.js +14 -11
  40. package/esm/ui/axis/overlap/autoWrap.js.map +1 -1
  41. package/esm/ui/axis/overlap/index.js +7 -7
  42. package/esm/ui/axis/overlap/index.js.map +1 -1
  43. package/esm/ui/axis/utils/bounds.js +75 -48
  44. package/esm/ui/axis/utils/bounds.js.map +1 -1
  45. package/esm/ui/axis/utils/contain.js +14 -14
  46. package/esm/ui/axis/utils/contain.js.map +1 -1
  47. package/esm/ui/axis/utils/index.js +7 -3
  48. package/esm/ui/axis/utils/index.js.map +1 -1
  49. package/esm/ui/axis/utils/intersect.js +33 -21
  50. package/esm/ui/axis/utils/intersect.js.map +1 -1
  51. package/esm/ui/axis/utils/test.js +41 -29
  52. package/esm/ui/axis/utils/test.js.map +1 -1
  53. package/esm/ui/breadcrumb/index.js +72 -64
  54. package/esm/ui/breadcrumb/index.js.map +1 -1
  55. package/esm/ui/button/constant.js +3 -3
  56. package/esm/ui/button/constant.js.map +1 -1
  57. package/esm/ui/button/index.js +97 -81
  58. package/esm/ui/button/index.js.map +1 -1
  59. package/esm/ui/checkbox/constant.js +4 -4
  60. package/esm/ui/checkbox/constant.js.map +1 -1
  61. package/esm/ui/checkbox/index.js +26 -23
  62. package/esm/ui/checkbox/index.js.map +1 -1
  63. package/esm/ui/crosshair/base.js +45 -29
  64. package/esm/ui/crosshair/base.js.map +1 -1
  65. package/esm/ui/crosshair/circle.js +34 -25
  66. package/esm/ui/crosshair/circle.js.map +1 -1
  67. package/esm/ui/crosshair/constant.js +4 -4
  68. package/esm/ui/crosshair/constant.js.map +1 -1
  69. package/esm/ui/crosshair/line.js +75 -55
  70. package/esm/ui/crosshair/line.js.map +1 -1
  71. package/esm/ui/crosshair/polygon.js +70 -54
  72. package/esm/ui/crosshair/polygon.js.map +1 -1
  73. package/esm/ui/grid/index.d.ts +1 -1
  74. package/esm/ui/grid/index.js +95 -73
  75. package/esm/ui/grid/index.js.map +1 -1
  76. package/esm/ui/indicator/constant.js +2 -2
  77. package/esm/ui/indicator/constant.js.map +1 -1
  78. package/esm/ui/indicator/indicator.js +63 -58
  79. package/esm/ui/indicator/indicator.js.map +1 -1
  80. package/esm/ui/layout/layout.js +66 -52
  81. package/esm/ui/layout/layout.js.map +1 -1
  82. package/esm/ui/legend/base.js +13 -12
  83. package/esm/ui/legend/base.js.map +1 -1
  84. package/esm/ui/legend/category/item.js +156 -122
  85. package/esm/ui/legend/category/item.js.map +1 -1
  86. package/esm/ui/legend/category/items.js +201 -158
  87. package/esm/ui/legend/category/items.js.map +1 -1
  88. package/esm/ui/legend/category.js +56 -46
  89. package/esm/ui/legend/category.js.map +1 -1
  90. package/esm/ui/legend/constant.js +6 -6
  91. package/esm/ui/legend/constant.js.map +1 -1
  92. package/esm/ui/legend/continuous/handle.js +33 -28
  93. package/esm/ui/legend/continuous/handle.js.map +1 -1
  94. package/esm/ui/legend/continuous/ribbon.js +38 -34
  95. package/esm/ui/legend/continuous/ribbon.js.map +1 -1
  96. package/esm/ui/legend/continuous/utils.js +11 -10
  97. package/esm/ui/legend/continuous/utils.js.map +1 -1
  98. package/esm/ui/legend/continuous.js +521 -417
  99. package/esm/ui/legend/continuous.js.map +1 -1
  100. package/esm/ui/legend/utils.js +31 -24
  101. package/esm/ui/legend/utils.js.map +1 -1
  102. package/esm/ui/marker/index.js +44 -38
  103. package/esm/ui/marker/index.js.map +1 -1
  104. package/esm/ui/marker/symbol.js +24 -24
  105. package/esm/ui/marker/symbol.js.map +1 -1
  106. package/esm/ui/marker/utils.js +2 -2
  107. package/esm/ui/marker/utils.js.map +1 -1
  108. package/esm/ui/navigator/index.js +159 -128
  109. package/esm/ui/navigator/index.js.map +1 -1
  110. package/esm/ui/poptip/constant.d.ts +1 -1
  111. package/esm/ui/poptip/constant.js +69 -68
  112. package/esm/ui/poptip/constant.js.map +1 -1
  113. package/esm/ui/poptip/index.js +111 -95
  114. package/esm/ui/poptip/index.js.map +1 -1
  115. package/esm/ui/poptip/utils.js +15 -8
  116. package/esm/ui/poptip/utils.js.map +1 -1
  117. package/esm/ui/scrollbar/index.js +132 -102
  118. package/esm/ui/scrollbar/index.js.map +1 -1
  119. package/esm/ui/select/option.js +58 -48
  120. package/esm/ui/select/option.js.map +1 -1
  121. package/esm/ui/select/select.js +164 -142
  122. package/esm/ui/select/select.js.map +1 -1
  123. package/esm/ui/slider/constant.js +4 -4
  124. package/esm/ui/slider/constant.js.map +1 -1
  125. package/esm/ui/slider/handle.js +54 -46
  126. package/esm/ui/slider/handle.js.map +1 -1
  127. package/esm/ui/slider/index.js +328 -282
  128. package/esm/ui/slider/index.js.map +1 -1
  129. package/esm/ui/sparkline/columns.js +34 -25
  130. package/esm/ui/sparkline/columns.js.map +1 -1
  131. package/esm/ui/sparkline/index.js +180 -145
  132. package/esm/ui/sparkline/index.js.map +1 -1
  133. package/esm/ui/sparkline/lines.js +50 -37
  134. package/esm/ui/sparkline/lines.js.map +1 -1
  135. package/esm/ui/sparkline/path.js +40 -36
  136. package/esm/ui/sparkline/path.js.map +1 -1
  137. package/esm/ui/sparkline/utils.js +9 -8
  138. package/esm/ui/sparkline/utils.js.map +1 -1
  139. package/esm/ui/switch/constant.js +1 -1
  140. package/esm/ui/switch/constant.js.map +1 -1
  141. package/esm/ui/switch/index.js +54 -44
  142. package/esm/ui/switch/index.js.map +1 -1
  143. package/esm/ui/tag/index.js +32 -29
  144. package/esm/ui/tag/index.js.map +1 -1
  145. package/esm/ui/timebar/controller.js +79 -69
  146. package/esm/ui/timebar/controller.js.map +1 -1
  147. package/esm/ui/timebar/handle.js +71 -62
  148. package/esm/ui/timebar/handle.js.map +1 -1
  149. package/esm/ui/timebar/icons.js +478 -308
  150. package/esm/ui/timebar/icons.js.map +1 -1
  151. package/esm/ui/timebar/timebar.js +318 -263
  152. package/esm/ui/timebar/timebar.js.map +1 -1
  153. package/esm/ui/timebar/utils.js +7 -7
  154. package/esm/ui/timebar/utils.js.map +1 -1
  155. package/esm/ui/timeline/index.js +6 -2
  156. package/esm/ui/timeline/index.js.map +1 -1
  157. package/esm/ui/title/index.js +64 -59
  158. package/esm/ui/title/index.js.map +1 -1
  159. package/esm/ui/tooltip/constant.js +30 -26
  160. package/esm/ui/tooltip/constant.js.map +1 -1
  161. package/esm/ui/tooltip/index.js +126 -109
  162. package/esm/ui/tooltip/index.js.map +1 -1
  163. package/esm/util/bbox.js +47 -24
  164. package/esm/util/bbox.js.map +1 -1
  165. package/esm/util/callback.js +2 -1
  166. package/esm/util/callback.js.map +1 -1
  167. package/esm/util/classnames.js +10 -8
  168. package/esm/util/classnames.js.map +1 -1
  169. package/esm/util/deep-assign.js +14 -6
  170. package/esm/util/deep-assign.js.map +1 -1
  171. package/esm/util/defined.js +1 -1
  172. package/esm/util/defined.js.map +1 -1
  173. package/esm/util/ellipsis.js +2 -1
  174. package/esm/util/ellipsis.js.map +1 -1
  175. package/esm/util/event.js +3 -3
  176. package/esm/util/event.js.map +1 -1
  177. package/esm/util/geometry/line-length.js +4 -1
  178. package/esm/util/geometry/line-length.js.map +1 -1
  179. package/esm/util/geometry/lines-intersection.js +10 -5
  180. package/esm/util/geometry/lines-intersection.js.map +1 -1
  181. package/esm/util/group-by.js +1 -1
  182. package/esm/util/group-by.js.map +1 -1
  183. package/esm/util/group.js +3 -3
  184. package/esm/util/group.js.map +1 -1
  185. package/esm/util/html.js +1 -1
  186. package/esm/util/html.js.map +1 -1
  187. package/esm/util/if-show.js +5 -3
  188. package/esm/util/if-show.js.map +1 -1
  189. package/esm/util/in-range.js +3 -1
  190. package/esm/util/in-range.js.map +1 -1
  191. package/esm/util/interpolate.js +19 -12
  192. package/esm/util/interpolate.js.map +1 -1
  193. package/esm/util/keyframe-interpolate.d.ts +1 -1
  194. package/esm/util/keyframe-interpolate.js +7 -6
  195. package/esm/util/keyframe-interpolate.js.map +1 -1
  196. package/esm/util/layout/executer.js +4 -4
  197. package/esm/util/layout/executer.js.map +1 -1
  198. package/esm/util/layout/flex/index.js +26 -24
  199. package/esm/util/layout/flex/index.js.map +1 -1
  200. package/esm/util/layout/grid/index.js +1 -1
  201. package/esm/util/layout/grid/index.js.map +1 -1
  202. package/esm/util/layout/utils/helper.js +8 -7
  203. package/esm/util/layout/utils/helper.js.map +1 -1
  204. package/esm/util/matrix.js +8 -7
  205. package/esm/util/matrix.js.map +1 -1
  206. package/esm/util/number.js +7 -6
  207. package/esm/util/number.js.map +1 -1
  208. package/esm/util/offscreen.js +17 -9
  209. package/esm/util/offscreen.js.map +1 -1
  210. package/esm/util/omit.js +3 -3
  211. package/esm/util/omit.js.map +1 -1
  212. package/esm/util/path.js +41 -36
  213. package/esm/util/path.js.map +1 -1
  214. package/esm/util/primitive.js +3 -3
  215. package/esm/util/primitive.js.map +1 -1
  216. package/esm/util/replace-children.js +4 -3
  217. package/esm/util/replace-children.js.map +1 -1
  218. package/esm/util/sampling.js +3 -3
  219. package/esm/util/sampling.js.map +1 -1
  220. package/esm/util/scale-to-pixel.js +5 -4
  221. package/esm/util/scale-to-pixel.js.map +1 -1
  222. package/esm/util/selection.js +186 -142
  223. package/esm/util/selection.js.map +1 -1
  224. package/esm/util/series.js +1 -1
  225. package/esm/util/series.js.map +1 -1
  226. package/esm/util/shape.js +27 -15
  227. package/esm/util/shape.js.map +1 -1
  228. package/esm/util/string.js +5 -4
  229. package/esm/util/string.js.map +1 -1
  230. package/esm/util/style.js +29 -23
  231. package/esm/util/style.js.map +1 -1
  232. package/esm/util/svg2marker.js +16 -13
  233. package/esm/util/svg2marker.js.map +1 -1
  234. package/esm/util/text.js +14 -14
  235. package/esm/util/text.js.map +1 -1
  236. package/esm/util/throttle.js +13 -7
  237. package/esm/util/throttle.js.map +1 -1
  238. package/esm/util/time.js +24 -22
  239. package/esm/util/time.js.map +1 -1
  240. package/esm/util/timer.js +9 -5
  241. package/esm/util/timer.js.map +1 -1
  242. package/esm/util/transform.js +6 -5
  243. package/esm/util/transform.js.map +1 -1
  244. package/esm/util/transpose.js +1 -1
  245. package/esm/util/transpose.js.map +1 -1
  246. package/esm/util/traverse.js +1 -1
  247. package/esm/util/traverse.js.map +1 -1
  248. package/esm/util/visibility.js +2 -2
  249. package/esm/util/visibility.js.map +1 -1
  250. package/esm/util/wrap.js +4 -2
  251. package/esm/util/wrap.js.map +1 -1
  252. package/lib/animation/fadeIn.d.ts +1 -1
  253. package/lib/animation/fadeIn.js +1 -1
  254. package/lib/animation/fadeIn.js.map +1 -1
  255. package/lib/animation/fadeOut.d.ts +1 -1
  256. package/lib/animation/fadeOut.js +1 -1
  257. package/lib/animation/fadeOut.js.map +1 -1
  258. package/lib/animation/index.js +1 -1
  259. package/lib/animation/utils.d.ts +3 -3
  260. package/lib/animation/utils.js +39 -33
  261. package/lib/animation/utils.js.map +1 -1
  262. package/lib/core/component.js +43 -31
  263. package/lib/core/component.js.map +1 -1
  264. package/lib/core/index.js +1 -1
  265. package/lib/index.js +1 -1
  266. package/lib/shapes/Text.js +22 -15
  267. package/lib/shapes/Text.js.map +1 -1
  268. package/lib/shapes/index.js +1 -1
  269. package/lib/types/index.js +1 -1
  270. package/lib/ui/axis/axis.d.ts +1 -1
  271. package/lib/ui/axis/axis.js +39 -34
  272. package/lib/ui/axis/axis.js.map +1 -1
  273. package/lib/ui/axis/constant.js +12 -10
  274. package/lib/ui/axis/constant.js.map +1 -1
  275. package/lib/ui/axis/guides/grid.d.ts +1 -1
  276. package/lib/ui/axis/guides/grid.js +40 -35
  277. package/lib/ui/axis/guides/grid.js.map +1 -1
  278. package/lib/ui/axis/guides/labels.js +89 -82
  279. package/lib/ui/axis/guides/labels.js.map +1 -1
  280. package/lib/ui/axis/guides/line.js +92 -79
  281. package/lib/ui/axis/guides/line.js.map +1 -1
  282. package/lib/ui/axis/guides/ticks.d.ts +1 -1
  283. package/lib/ui/axis/guides/ticks.js +45 -37
  284. package/lib/ui/axis/guides/ticks.js.map +1 -1
  285. package/lib/ui/axis/guides/title.d.ts +1 -1
  286. package/lib/ui/axis/guides/title.js +41 -37
  287. package/lib/ui/axis/guides/title.js.map +1 -1
  288. package/lib/ui/axis/guides/utils.js +14 -12
  289. package/lib/ui/axis/guides/utils.js.map +1 -1
  290. package/lib/ui/axis/overlap/autoEllipsis.js +22 -15
  291. package/lib/ui/axis/overlap/autoEllipsis.js.map +1 -1
  292. package/lib/ui/axis/overlap/autoHide.js +27 -23
  293. package/lib/ui/axis/overlap/autoHide.js.map +1 -1
  294. package/lib/ui/axis/overlap/autoRotate.js +26 -12
  295. package/lib/ui/axis/overlap/autoRotate.js.map +1 -1
  296. package/lib/ui/axis/overlap/autoWrap.js +16 -13
  297. package/lib/ui/axis/overlap/autoWrap.js.map +1 -1
  298. package/lib/ui/axis/overlap/index.js +12 -12
  299. package/lib/ui/axis/overlap/index.js.map +1 -1
  300. package/lib/ui/axis/utils/bounds.js +75 -49
  301. package/lib/ui/axis/utils/bounds.js.map +1 -1
  302. package/lib/ui/axis/utils/contain.js +15 -15
  303. package/lib/ui/axis/utils/contain.js.map +1 -1
  304. package/lib/ui/axis/utils/index.js +8 -4
  305. package/lib/ui/axis/utils/index.js.map +1 -1
  306. package/lib/ui/axis/utils/intersect.js +34 -22
  307. package/lib/ui/axis/utils/intersect.js.map +1 -1
  308. package/lib/ui/axis/utils/test.js +47 -35
  309. package/lib/ui/axis/utils/test.js.map +1 -1
  310. package/lib/ui/breadcrumb/index.js +77 -70
  311. package/lib/ui/breadcrumb/index.js.map +1 -1
  312. package/lib/ui/button/index.js +101 -86
  313. package/lib/ui/button/index.js.map +1 -1
  314. package/lib/ui/checkbox/constant.js +2 -2
  315. package/lib/ui/checkbox/constant.js.map +1 -1
  316. package/lib/ui/checkbox/index.js +28 -26
  317. package/lib/ui/checkbox/index.js.map +1 -1
  318. package/lib/ui/crosshair/base.js +48 -33
  319. package/lib/ui/crosshair/base.js.map +1 -1
  320. package/lib/ui/crosshair/circle.js +37 -29
  321. package/lib/ui/crosshair/circle.js.map +1 -1
  322. package/lib/ui/crosshair/constant.js +1 -1
  323. package/lib/ui/crosshair/constant.js.map +1 -1
  324. package/lib/ui/crosshair/index.js +1 -1
  325. package/lib/ui/crosshair/line.js +77 -58
  326. package/lib/ui/crosshair/line.js.map +1 -1
  327. package/lib/ui/crosshair/polygon.js +72 -57
  328. package/lib/ui/crosshair/polygon.js.map +1 -1
  329. package/lib/ui/grid/index.d.ts +1 -1
  330. package/lib/ui/grid/index.js +97 -76
  331. package/lib/ui/grid/index.js.map +1 -1
  332. package/lib/ui/indicator/constant.js +1 -1
  333. package/lib/ui/indicator/constant.js.map +1 -1
  334. package/lib/ui/indicator/index.js +1 -1
  335. package/lib/ui/indicator/indicator.js +67 -63
  336. package/lib/ui/indicator/indicator.js.map +1 -1
  337. package/lib/ui/layout/layout.js +70 -57
  338. package/lib/ui/layout/layout.js.map +1 -1
  339. package/lib/ui/legend/base.js +15 -14
  340. package/lib/ui/legend/base.js.map +1 -1
  341. package/lib/ui/legend/category/item.js +159 -126
  342. package/lib/ui/legend/category/item.js.map +1 -1
  343. package/lib/ui/legend/category/items.js +208 -166
  344. package/lib/ui/legend/category/items.js.map +1 -1
  345. package/lib/ui/legend/category.js +60 -51
  346. package/lib/ui/legend/category.js.map +1 -1
  347. package/lib/ui/legend/constant.js +2 -2
  348. package/lib/ui/legend/constant.js.map +1 -1
  349. package/lib/ui/legend/continuous/handle.js +35 -31
  350. package/lib/ui/legend/continuous/handle.js.map +1 -1
  351. package/lib/ui/legend/continuous/ribbon.js +43 -40
  352. package/lib/ui/legend/continuous/ribbon.js.map +1 -1
  353. package/lib/ui/legend/continuous/utils.js +11 -10
  354. package/lib/ui/legend/continuous/utils.js.map +1 -1
  355. package/lib/ui/legend/continuous.js +535 -432
  356. package/lib/ui/legend/continuous.js.map +1 -1
  357. package/lib/ui/legend/index.js +2 -2
  358. package/lib/ui/legend/index.js.map +1 -1
  359. package/lib/ui/legend/utils.js +32 -25
  360. package/lib/ui/legend/utils.js.map +1 -1
  361. package/lib/ui/marker/index.js +48 -43
  362. package/lib/ui/marker/index.js.map +1 -1
  363. package/lib/ui/marker/symbol.js +22 -22
  364. package/lib/ui/marker/symbol.js.map +1 -1
  365. package/lib/ui/marker/utils.js +3 -3
  366. package/lib/ui/marker/utils.js.map +1 -1
  367. package/lib/ui/navigator/index.js +165 -135
  368. package/lib/ui/navigator/index.js.map +1 -1
  369. package/lib/ui/poptip/constant.d.ts +1 -1
  370. package/lib/ui/poptip/constant.js +67 -66
  371. package/lib/ui/poptip/constant.js.map +1 -1
  372. package/lib/ui/poptip/index.js +115 -100
  373. package/lib/ui/poptip/index.js.map +1 -1
  374. package/lib/ui/poptip/utils.js +15 -8
  375. package/lib/ui/poptip/utils.js.map +1 -1
  376. package/lib/ui/scrollbar/index.js +136 -107
  377. package/lib/ui/scrollbar/index.js.map +1 -1
  378. package/lib/ui/select/option.js +61 -52
  379. package/lib/ui/select/option.js.map +1 -1
  380. package/lib/ui/select/select.js +169 -148
  381. package/lib/ui/select/select.js.map +1 -1
  382. package/lib/ui/slider/constant.js +1 -1
  383. package/lib/ui/slider/constant.js.map +1 -1
  384. package/lib/ui/slider/handle.js +56 -49
  385. package/lib/ui/slider/handle.js.map +1 -1
  386. package/lib/ui/slider/index.js +336 -291
  387. package/lib/ui/slider/index.js.map +1 -1
  388. package/lib/ui/sparkline/columns.js +36 -28
  389. package/lib/ui/sparkline/columns.js.map +1 -1
  390. package/lib/ui/sparkline/index.js +187 -153
  391. package/lib/ui/sparkline/index.js.map +1 -1
  392. package/lib/ui/sparkline/lines.js +52 -40
  393. package/lib/ui/sparkline/lines.js.map +1 -1
  394. package/lib/ui/sparkline/path.js +42 -38
  395. package/lib/ui/sparkline/path.js.map +1 -1
  396. package/lib/ui/sparkline/utils.js +10 -9
  397. package/lib/ui/sparkline/utils.js.map +1 -1
  398. package/lib/ui/switch/index.js +58 -49
  399. package/lib/ui/switch/index.js.map +1 -1
  400. package/lib/ui/tag/index.js +36 -34
  401. package/lib/ui/tag/index.js.map +1 -1
  402. package/lib/ui/timebar/controller.js +82 -73
  403. package/lib/ui/timebar/controller.js.map +1 -1
  404. package/lib/ui/timebar/handle.js +74 -67
  405. package/lib/ui/timebar/handle.js.map +1 -1
  406. package/lib/ui/timebar/icons.js +466 -312
  407. package/lib/ui/timebar/icons.js.map +1 -1
  408. package/lib/ui/timebar/timebar.js +326 -272
  409. package/lib/ui/timebar/timebar.js.map +1 -1
  410. package/lib/ui/timebar/utils.js +8 -8
  411. package/lib/ui/timebar/utils.js.map +1 -1
  412. package/lib/ui/timeline/index.js +5 -2
  413. package/lib/ui/timeline/index.js.map +1 -1
  414. package/lib/ui/title/index.js +65 -61
  415. package/lib/ui/title/index.js.map +1 -1
  416. package/lib/ui/tooltip/constant.js +30 -26
  417. package/lib/ui/tooltip/constant.js.map +1 -1
  418. package/lib/ui/tooltip/index.js +129 -113
  419. package/lib/ui/tooltip/index.js.map +1 -1
  420. package/lib/util/bbox.js +46 -24
  421. package/lib/util/bbox.js.map +1 -1
  422. package/lib/util/callback.js +3 -2
  423. package/lib/util/callback.js.map +1 -1
  424. package/lib/util/classnames.js +10 -8
  425. package/lib/util/classnames.js.map +1 -1
  426. package/lib/util/deep-assign.js +15 -7
  427. package/lib/util/deep-assign.js.map +1 -1
  428. package/lib/util/defined.js +1 -1
  429. package/lib/util/defined.js.map +1 -1
  430. package/lib/util/ellipsis.js +3 -2
  431. package/lib/util/ellipsis.js.map +1 -1
  432. package/lib/util/event.js +3 -3
  433. package/lib/util/event.js.map +1 -1
  434. package/lib/util/extend-display-object.js +2 -2
  435. package/lib/util/extend-display-object.js.map +1 -1
  436. package/lib/util/geometry/index.js +1 -1
  437. package/lib/util/geometry/line-length.js +4 -1
  438. package/lib/util/geometry/line-length.js.map +1 -1
  439. package/lib/util/geometry/lines-intersection.js +10 -5
  440. package/lib/util/geometry/lines-intersection.js.map +1 -1
  441. package/lib/util/group-by.js +1 -1
  442. package/lib/util/group-by.js.map +1 -1
  443. package/lib/util/group.js +3 -3
  444. package/lib/util/group.js.map +1 -1
  445. package/lib/util/html.js +1 -1
  446. package/lib/util/html.js.map +1 -1
  447. package/lib/util/if-show.js +5 -3
  448. package/lib/util/if-show.js.map +1 -1
  449. package/lib/util/in-range.js +3 -1
  450. package/lib/util/in-range.js.map +1 -1
  451. package/lib/util/index.js +1 -1
  452. package/lib/util/interpolate.js +19 -12
  453. package/lib/util/interpolate.js.map +1 -1
  454. package/lib/util/keyframe-interpolate.d.ts +1 -1
  455. package/lib/util/keyframe-interpolate.js +8 -7
  456. package/lib/util/keyframe-interpolate.js.map +1 -1
  457. package/lib/util/layout/executer.js +6 -6
  458. package/lib/util/layout/executer.js.map +1 -1
  459. package/lib/util/layout/flex/index.js +28 -26
  460. package/lib/util/layout/flex/index.js.map +1 -1
  461. package/lib/util/layout/grid/index.js +1 -1
  462. package/lib/util/layout/grid/index.js.map +1 -1
  463. package/lib/util/layout/index.js +1 -1
  464. package/lib/util/layout/utils/helper.js +9 -8
  465. package/lib/util/layout/utils/helper.js.map +1 -1
  466. package/lib/util/matrix.js +8 -7
  467. package/lib/util/matrix.js.map +1 -1
  468. package/lib/util/number.js +7 -6
  469. package/lib/util/number.js.map +1 -1
  470. package/lib/util/offscreen.js +20 -12
  471. package/lib/util/offscreen.js.map +1 -1
  472. package/lib/util/omit.js +3 -3
  473. package/lib/util/omit.js.map +1 -1
  474. package/lib/util/path.js +42 -37
  475. package/lib/util/path.js.map +1 -1
  476. package/lib/util/primitive.js +2 -2
  477. package/lib/util/primitive.js.map +1 -1
  478. package/lib/util/replace-children.js +4 -3
  479. package/lib/util/replace-children.js.map +1 -1
  480. package/lib/util/sampling.js +3 -3
  481. package/lib/util/sampling.js.map +1 -1
  482. package/lib/util/scale-to-pixel.js +5 -4
  483. package/lib/util/scale-to-pixel.js.map +1 -1
  484. package/lib/util/selection.js +187 -144
  485. package/lib/util/selection.js.map +1 -1
  486. package/lib/util/series.js +2 -2
  487. package/lib/util/series.js.map +1 -1
  488. package/lib/util/shape.js +28 -16
  489. package/lib/util/shape.js.map +1 -1
  490. package/lib/util/string.js +5 -4
  491. package/lib/util/string.js.map +1 -1
  492. package/lib/util/style.js +30 -24
  493. package/lib/util/style.js.map +1 -1
  494. package/lib/util/svg2marker.js +17 -15
  495. package/lib/util/svg2marker.js.map +1 -1
  496. package/lib/util/text.js +16 -16
  497. package/lib/util/text.js.map +1 -1
  498. package/lib/util/throttle.js +13 -7
  499. package/lib/util/throttle.js.map +1 -1
  500. package/lib/util/time.js +24 -22
  501. package/lib/util/time.js.map +1 -1
  502. package/lib/util/timer.js +9 -5
  503. package/lib/util/timer.js.map +1 -1
  504. package/lib/util/transform.js +6 -5
  505. package/lib/util/transform.js.map +1 -1
  506. package/lib/util/transpose.js +1 -1
  507. package/lib/util/transpose.js.map +1 -1
  508. package/lib/util/traverse.js +1 -1
  509. package/lib/util/traverse.js.map +1 -1
  510. package/lib/util/visibility.js +3 -3
  511. package/lib/util/visibility.js.map +1 -1
  512. package/lib/util/wrap.js +5 -3
  513. package/lib/util/wrap.js.map +1 -1
  514. package/package.json +8 -8
  515. package/src/ui/poptip/constant.ts +1 -1
  516. package/src/ui/slider/index.ts +2 -3
@@ -1,4 +1,4 @@
1
- import { __rest } from "tslib";
1
+ import { __assign, __extends, __read, __rest, __spreadArray } from "tslib";
2
2
  import { clamp } from '@antv/util';
3
3
  import { Component } from '../../core';
4
4
  import { Line } from '../../shapes';
@@ -8,179 +8,254 @@ import { Slider } from '../slider';
8
8
  import { Controller } from './controller';
9
9
  import { ChartModeHandle, TimeModeHandle } from './handle';
10
10
  import { labelFormatter, parseBySeries } from './utils';
11
- export class Timebar extends Component {
12
- get data() {
13
- const { data } = this.attributes;
14
- const compareFn = (a, b) => {
15
- if (a.time < b.time)
16
- return -1;
17
- if (a.time > b.time)
18
- return 1;
19
- return 0;
11
+ var Timebar = /** @class */ (function (_super) {
12
+ __extends(Timebar, _super);
13
+ function Timebar(options) {
14
+ var _this = _super.call(this, deepAssign({}, Timebar.defaultOptions, options)) || this;
15
+ _this.axis = _this.appendChild(new Axis({
16
+ style: { type: 'linear', startPos: [0, 0], endPos: [0, 0], data: [], showArrow: false, animate: false },
17
+ }));
18
+ /** 时间线 group,用于放置 timeline 或者 chart */
19
+ _this.timeline = _this.appendChild(new Slider({
20
+ style: {
21
+ onChange: function (values) {
22
+ _this.handleSliderChange(values);
23
+ },
24
+ },
25
+ }));
26
+ _this.controller = _this.appendChild(new Controller({}));
27
+ _this.states = {};
28
+ _this.handleSliderChange = function (values) {
29
+ var prevValues = (function () {
30
+ var val = _this.states.values;
31
+ if (Array.isArray(val))
32
+ return __spreadArray([], __read(val), false);
33
+ return val;
34
+ })();
35
+ _this.setBySliderValues(values);
36
+ _this.dispatchOnChange(prevValues);
20
37
  };
21
- return data.sort(compareFn);
22
- }
23
- /** 计算空间分配 */
24
- get space() {
25
- const { x, y, width, height, type, controllerHeight } = this.attributes;
26
- const availableTimelineHeight = clamp(+height - controllerHeight, 0, +height);
27
- const controllerBBox = new BBox(x, y + +height - controllerHeight, +width, controllerHeight);
28
- // chart 模式下可用
29
- let axisBBox;
30
- let axisHeight = 0;
31
- if (type === 'chart') {
32
- // axis 默认分配高度为 35
33
- axisHeight = 35;
34
- axisBBox = new BBox(x, y + availableTimelineHeight - axisHeight, +width, axisHeight);
35
- }
36
- else
37
- axisBBox = new BBox();
38
- const timelineHeight = type === 'time' ? 10 : availableTimelineHeight;
39
- const timelineBBox = new BBox(x, y + (type === 'time' ? availableTimelineHeight : availableTimelineHeight - timelineHeight), +width, timelineHeight - axisHeight);
40
- return { axisBBox, controllerBBox, timelineBBox };
41
- }
42
- setBySliderValues(val) {
38
+ var _a = _this.attributes, selectionType = _a.selectionType, chartType = _a.chartType, speed = _a.speed, state = _a.state, playMode = _a.playMode, values = _a.values;
39
+ _this.states = { chartType: chartType, playMode: playMode, selectionType: selectionType, speed: speed, state: state };
40
+ _this.setByTimebarValues(values);
41
+ return _this;
42
+ }
43
+ Object.defineProperty(Timebar.prototype, "data", {
44
+ get: function () {
45
+ var data = this.attributes.data;
46
+ var compareFn = function (a, b) {
47
+ if (a.time < b.time)
48
+ return -1;
49
+ if (a.time > b.time)
50
+ return 1;
51
+ return 0;
52
+ };
53
+ return data.sort(compareFn);
54
+ },
55
+ enumerable: false,
56
+ configurable: true
57
+ });
58
+ Object.defineProperty(Timebar.prototype, "space", {
59
+ /** 计算空间分配 */
60
+ get: function () {
61
+ var _a = this.attributes, x = _a.x, y = _a.y, width = _a.width, height = _a.height, type = _a.type, controllerHeight = _a.controllerHeight;
62
+ var availableTimelineHeight = clamp(+height - controllerHeight, 0, +height);
63
+ var controllerBBox = new BBox(x, y + +height - controllerHeight, +width, controllerHeight);
64
+ // chart 模式下可用
65
+ var axisBBox;
66
+ var axisHeight = 0;
67
+ if (type === 'chart') {
68
+ // axis 默认分配高度为 35
69
+ axisHeight = 35;
70
+ axisBBox = new BBox(x, y + availableTimelineHeight - axisHeight, +width, axisHeight);
71
+ }
72
+ else
73
+ axisBBox = new BBox();
74
+ var timelineHeight = type === 'time' ? 10 : availableTimelineHeight;
75
+ var timelineBBox = new BBox(x, y + (type === 'time' ? availableTimelineHeight : availableTimelineHeight - timelineHeight), +width, timelineHeight - axisHeight);
76
+ return { axisBBox: axisBBox, controllerBBox: controllerBBox, timelineBBox: timelineBBox };
77
+ },
78
+ enumerable: false,
79
+ configurable: true
80
+ });
81
+ Timebar.prototype.setBySliderValues = function (val) {
43
82
  var _a, _b;
44
- const { data } = this;
45
- const [startRatio, endRatio] = Array.isArray(val) ? val : [0, val];
46
- const length = data.length;
47
- const startDatum = data[Math.floor(startRatio * length)];
48
- const endDatum = data[Math.ceil(endRatio * length) - (Array.isArray(val) ? 0 : 1)];
83
+ var data = this.data;
84
+ var _c = __read(Array.isArray(val) ? val : [0, val], 2), startRatio = _c[0], endRatio = _c[1];
85
+ var length = data.length;
86
+ var startDatum = data[Math.floor(startRatio * length)];
87
+ var endDatum = data[Math.ceil(endRatio * length) - (Array.isArray(val) ? 0 : 1)];
49
88
  // 如果 endDatum 不存在,则其已经比最大的时间范围更大
50
89
  this.states.values = [(_a = startDatum === null || startDatum === void 0 ? void 0 : startDatum.time) !== null && _a !== void 0 ? _a : data[0].time, (_b = endDatum === null || endDatum === void 0 ? void 0 : endDatum.time) !== null && _b !== void 0 ? _b : Infinity];
51
- }
52
- setByTimebarValues(val) {
90
+ };
91
+ Timebar.prototype.setByTimebarValues = function (val) {
53
92
  var _a, _b, _c;
54
- const { data } = this;
55
- const [start, end] = Array.isArray(val) ? val : [undefined, val];
56
- const startDatum = data.find(({ time }) => time === start);
57
- const endDatum = data.find(({ time }) => time === end);
93
+ var data = this.data;
94
+ var _d = __read(Array.isArray(val) ? val : [undefined, val], 2), start = _d[0], end = _d[1];
95
+ var startDatum = data.find(function (_a) {
96
+ var time = _a.time;
97
+ return time === start;
98
+ });
99
+ var endDatum = data.find(function (_a) {
100
+ var time = _a.time;
101
+ return time === end;
102
+ });
58
103
  this.states.values = [(_a = startDatum === null || startDatum === void 0 ? void 0 : startDatum.time) !== null && _a !== void 0 ? _a : (_b = data[0]) === null || _b === void 0 ? void 0 : _b.time, (_c = endDatum === null || endDatum === void 0 ? void 0 : endDatum.time) !== null && _c !== void 0 ? _c : Infinity];
59
- }
60
- setByIndex(index) {
104
+ };
105
+ Timebar.prototype.setByIndex = function (index) {
61
106
  var _a, _b, _c, _d;
62
- const { data } = this;
63
- const [startIndex, endIndex] = index;
107
+ var data = this.data;
108
+ var _e = __read(index, 2), startIndex = _e[0], endIndex = _e[1];
64
109
  this.states.values = [(_b = (_a = data[startIndex]) === null || _a === void 0 ? void 0 : _a.time) !== null && _b !== void 0 ? _b : data[0].time, (_d = (_c = this.data[endIndex]) === null || _c === void 0 ? void 0 : _c.time) !== null && _d !== void 0 ? _d : Infinity];
65
- }
66
- /**
67
- * 获取 timebar 的 values
68
- */
69
- get sliderValues() {
70
- const { values, selectionType } = this.states;
71
- const [start, end] = Array.isArray(values) ? values : [undefined, values];
72
- const { data } = this;
73
- const length = data.length;
74
- const isValue = selectionType === 'value';
75
- const getStartValue = () => {
76
- const startDatumIndex = data.findIndex(({ time }) => time === start);
77
- if (isValue)
110
+ };
111
+ Object.defineProperty(Timebar.prototype, "sliderValues", {
112
+ /**
113
+ * 获取 timebar 的 values
114
+ */
115
+ get: function () {
116
+ var _a = this.states, values = _a.values, selectionType = _a.selectionType;
117
+ var _b = __read(Array.isArray(values) ? values : [undefined, values], 2), start = _b[0], end = _b[1];
118
+ var data = this.data;
119
+ var length = data.length;
120
+ var isValue = selectionType === 'value';
121
+ var getStartValue = function () {
122
+ var startDatumIndex = data.findIndex(function (_a) {
123
+ var time = _a.time;
124
+ return time === start;
125
+ });
126
+ if (isValue)
127
+ return 0;
128
+ if (startDatumIndex > -1)
129
+ return startDatumIndex / length;
130
+ // value 模式下默认取 0
78
131
  return 0;
79
- if (startDatumIndex > -1)
80
- return startDatumIndex / length;
81
- // value 模式下默认取 0
82
- return 0;
83
- };
84
- const getEndValue = () => {
85
- if (end === Infinity)
132
+ };
133
+ var getEndValue = function () {
134
+ if (end === Infinity)
135
+ return 1;
136
+ var endDatumIndex = data.findIndex(function (_a) {
137
+ var time = _a.time;
138
+ return time === end;
139
+ });
140
+ if (endDatumIndex > -1)
141
+ return endDatumIndex / length;
142
+ // range 模式下默认取 1,value 模式下默认取 0.5
143
+ if (isValue)
144
+ return 0.5;
86
145
  return 1;
87
- const endDatumIndex = data.findIndex(({ time }) => time === end);
88
- if (endDatumIndex > -1)
89
- return endDatumIndex / length;
90
- // range 模式下默认取 1,value 模式下默认取 0.5
91
- if (isValue)
92
- return 0.5;
93
- return 1;
94
- };
95
- return [getStartValue(), getEndValue()];
96
- }
97
- get values() {
98
- const { values, selectionType } = this.states;
99
- const [start, end] = Array.isArray(values) ? values : [this.data[0].time, values];
100
- if (selectionType === 'value')
101
- return end;
102
- return [start, end];
103
- }
104
- getDatumByRatio(ratio) {
105
- const { data } = this;
106
- const length = data.length;
107
- const index = Math.floor(ratio * (length - 1));
146
+ };
147
+ return [getStartValue(), getEndValue()];
148
+ },
149
+ enumerable: false,
150
+ configurable: true
151
+ });
152
+ Object.defineProperty(Timebar.prototype, "values", {
153
+ get: function () {
154
+ var _a = this.states, values = _a.values, selectionType = _a.selectionType;
155
+ var _b = __read(Array.isArray(values) ? values : [this.data[0].time, values], 2), start = _b[0], end = _b[1];
156
+ if (selectionType === 'value')
157
+ return end;
158
+ return [start, end];
159
+ },
160
+ enumerable: false,
161
+ configurable: true
162
+ });
163
+ Timebar.prototype.getDatumByRatio = function (ratio) {
164
+ var data = this.data;
165
+ var length = data.length;
166
+ var index = Math.floor(ratio * (length - 1));
108
167
  return data[index];
109
- }
110
- get chartHandleIconShape() {
111
- const { selectionType } = this.states;
112
- const { timelineBBox: { height }, } = this.space;
113
- if (selectionType === 'range')
114
- return (type) => new ChartModeHandle({ style: { type, height, iconSize: height / 6 } });
115
- return () => new Line({ style: { x1: 0, y1: -height / 2, x2: 0, y2: height / 2, lineWidth: 2, stroke: '#c8c8c8' } });
116
- }
117
- getChartStyle(bbox) {
118
- const { x, y, width, height } = bbox;
119
- const { selectionType, chartType } = this.states;
120
- const { data } = this;
121
- const { type, labelFormatter: userDefinedLabelFormatter } = this.attributes;
122
- const _a = subStyleProps(this.attributes, 'chart'), { type: ignoreType } = _a, userDefinedChartStyle = __rest(_a, ["type"]);
123
- const isRange = selectionType === 'range';
168
+ };
169
+ Object.defineProperty(Timebar.prototype, "chartHandleIconShape", {
170
+ get: function () {
171
+ var selectionType = this.states.selectionType;
172
+ var height = this.space.timelineBBox.height;
173
+ if (selectionType === 'range')
174
+ return function (type) { return new ChartModeHandle({ style: { type: type, height: height, iconSize: height / 6 } }); };
175
+ return function () {
176
+ return new Line({ style: { x1: 0, y1: -height / 2, x2: 0, y2: height / 2, lineWidth: 2, stroke: '#c8c8c8' } });
177
+ };
178
+ },
179
+ enumerable: false,
180
+ configurable: true
181
+ });
182
+ Timebar.prototype.getChartStyle = function (bbox) {
183
+ var _this = this;
184
+ var x = bbox.x, y = bbox.y, width = bbox.width, height = bbox.height;
185
+ var _a = this.states, selectionType = _a.selectionType, chartType = _a.chartType;
186
+ var data = this.data;
187
+ var _b = this.attributes, type = _b.type, userDefinedLabelFormatter = _b.labelFormatter;
188
+ var _c = subStyleProps(this.attributes, 'chart'), ignoreType = _c.type, userDefinedChartStyle = __rest(_c, ["type"]);
189
+ var isRange = selectionType === 'range';
124
190
  if (type === 'time') {
125
- return Object.assign({ handleIconShape: () => new TimeModeHandle({}), selectionFill: '#2e7ff8', selectionFillOpacity: 1, showLabelOnInteraction: true, handleLabelDy: isRange ? -15 : 0, autoFitLabel: isRange, handleSpacing: isRange ? -15 : 0, trackFill: '#edeeef', trackLength: width, trackOpacity: 0.5, trackRadius: height / 2, trackSize: height / 2, type: selectionType, values: this.sliderValues, formatter: (value) => {
191
+ return __assign({ handleIconShape: function () { return new TimeModeHandle({}); }, selectionFill: '#2e7ff8', selectionFillOpacity: 1, showLabelOnInteraction: true, handleLabelDy: isRange ? -15 : 0, autoFitLabel: isRange, handleSpacing: isRange ? -15 : 0, trackFill: '#edeeef', trackLength: width, trackOpacity: 0.5, trackRadius: height / 2, trackSize: height / 2, type: selectionType, values: this.sliderValues, formatter: function (value) {
126
192
  if (userDefinedLabelFormatter)
127
193
  return userDefinedLabelFormatter(value);
128
- const time = this.getDatumByRatio(value).time;
194
+ var time = _this.getDatumByRatio(value).time;
129
195
  if (typeof time === 'number')
130
196
  return parseBySeries(time);
131
197
  return formatTime(time, 'YYYY-MM-DD HH:mm:ss');
132
- }, transform: `translate(${x}, ${y})`,
198
+ }, transform: "translate(".concat(x, ", ").concat(y, ")"),
133
199
  // x,
134
200
  // y,
135
201
  zIndex: 1 }, userDefinedChartStyle);
136
202
  }
137
203
  // type === 'chart'
138
- const handleIconOffset = selectionType === 'range' ? 5 : 0;
139
- const sparklineData = data.map(({ value }) => value);
140
- return Object.assign({ handleIconOffset, handleIconShape: this.chartHandleIconShape, selectionFill: '#fff', selectionFillOpacity: 0.5, selectionType: 'invert', sparklineSpacing: 0.1, sparklineColumnLineWidth: 0, sparklineColor: '#d4e5fd', sparklineAreaOpacity: 1, sparklineAreaLineWidth: 0, sparklineData, sparklineType: chartType, sparklineScale: 0.8, trackLength: width, trackSize: height, type: selectionType, values: this.sliderValues,
204
+ var handleIconOffset = selectionType === 'range' ? 5 : 0;
205
+ var sparklineData = data.map(function (_a) {
206
+ var value = _a.value;
207
+ return value;
208
+ });
209
+ return __assign({ handleIconOffset: handleIconOffset, handleIconShape: this.chartHandleIconShape, selectionFill: '#fff', selectionFillOpacity: 0.5, selectionType: 'invert', sparklineSpacing: 0.1, sparklineColumnLineWidth: 0, sparklineColor: '#d4e5fd', sparklineAreaOpacity: 1, sparklineAreaLineWidth: 0, sparklineData: sparklineData, sparklineType: chartType, sparklineScale: 0.8, trackLength: width, trackSize: height, type: selectionType, values: this.sliderValues,
141
210
  // x,
142
211
  // y,
143
- transform: `translate(${x}, ${y})`, zIndex: 1 }, userDefinedChartStyle);
144
- }
145
- renderChart(bbox = this.space.timelineBBox) {
212
+ transform: "translate(".concat(x, ", ").concat(y, ")"), zIndex: 1 }, userDefinedChartStyle);
213
+ };
214
+ Timebar.prototype.renderChart = function (bbox) {
215
+ if (bbox === void 0) { bbox = this.space.timelineBBox; }
146
216
  this.timeline.update(this.getChartStyle(bbox));
147
- }
148
- updateSelection() {
217
+ };
218
+ Timebar.prototype.updateSelection = function () {
149
219
  this.timeline.setValues(this.sliderValues, true);
150
220
  this.handleSliderChange(this.sliderValues);
151
- }
152
- getAxisStyle(bbox) {
153
- const { data } = this;
154
- const { interval, labelFormatter: userDefinedLabelFormatter } = this.attributes;
155
- const userDefinedAxisStyle = subStyleProps(this.attributes, 'axis');
156
- const { x, y, width } = bbox;
221
+ };
222
+ Timebar.prototype.getAxisStyle = function (bbox) {
223
+ var data = this.data;
224
+ var _a = this.attributes, interval = _a.interval, userDefinedLabelFormatter = _a.labelFormatter;
225
+ var userDefinedAxisStyle = subStyleProps(this.attributes, 'axis');
226
+ var x = bbox.x, y = bbox.y, width = bbox.width;
157
227
  // 需要补一个刻度
158
- const axisData = [...data, { time: 0 }].map(({ time }, index, arr) => ({
159
- label: `${time}`,
160
- value: index / (arr.length - 1),
161
- time,
162
- }));
163
- const style = Object.assign({ startPos: [x, y], endPos: [x + width, y], data: axisData,
228
+ var axisData = __spreadArray(__spreadArray([], __read(data), false), [{ time: 0 }], false).map(function (_a, index, arr) {
229
+ var time = _a.time;
230
+ return ({
231
+ label: "".concat(time),
232
+ value: index / (arr.length - 1),
233
+ time: time,
234
+ });
235
+ });
236
+ var style = __assign({ startPos: [x, y], endPos: [x + width, y], data: axisData,
164
237
  // hide last label
165
- labelFilter: (_datum, index) => index < axisData.length - 1, labelFormatter: ({ time }) => userDefinedLabelFormatter ? userDefinedLabelFormatter(time) : labelFormatter(time, interval) }, userDefinedAxisStyle);
238
+ labelFilter: function (_datum, index) { return index < axisData.length - 1; }, labelFormatter: function (_a) {
239
+ var time = _a.time;
240
+ return userDefinedLabelFormatter ? userDefinedLabelFormatter(time) : labelFormatter(time, interval);
241
+ } }, userDefinedAxisStyle);
166
242
  return style;
167
- }
168
- renderAxis(bbox = this.space.axisBBox) {
169
- const { type } = this.attributes;
243
+ };
244
+ Timebar.prototype.renderAxis = function (bbox) {
245
+ if (bbox === void 0) { bbox = this.space.axisBBox; }
246
+ var type = this.attributes.type;
170
247
  if (type !== 'chart')
171
248
  return;
172
249
  this.axis.update(this.getAxisStyle(bbox));
173
- }
174
- renderController(bbox = this.space.controllerBBox) {
175
- const { type } = this.attributes;
176
- const { state, speed, selectionType, chartType } = this.states;
177
- const userDefinedControllerStyle = subStyleProps(this.attributes, 'controller');
178
- const that = this;
179
- const style = Object.assign(Object.assign(Object.assign({}, bbox), { iconSize: 20, speed,
180
- state,
181
- selectionType,
182
- chartType,
183
- onChange(type, { value }) {
250
+ };
251
+ Timebar.prototype.renderController = function (bbox) {
252
+ if (bbox === void 0) { bbox = this.space.controllerBBox; }
253
+ var type = this.attributes.type;
254
+ var _a = this.states, state = _a.state, speed = _a.speed, selectionType = _a.selectionType, chartType = _a.chartType;
255
+ var userDefinedControllerStyle = subStyleProps(this.attributes, 'controller');
256
+ var that = this;
257
+ var style = __assign(__assign(__assign({}, bbox), { iconSize: 20, speed: speed, state: state, selectionType: selectionType, chartType: chartType, onChange: function (type, _a) {
258
+ var value = _a.value;
184
259
  switch (type) {
185
260
  case 'reset':
186
261
  that.internalReset();
@@ -214,15 +289,15 @@ export class Timebar extends Component {
214
289
  style.functions = [['reset', 'speed'], ['backward', 'playPause', 'forward'], ['selectionType']];
215
290
  }
216
291
  this.controller.update(style);
217
- }
218
- dispatchOnChange(prevValues) {
219
- const { data } = this;
220
- const { onChange } = this.attributes;
221
- const { values, selectionType } = this.states;
222
- const [start, end] = values;
223
- const endTime = end === Infinity ? data.at(-1).time : end;
224
- const newValues = selectionType === 'range' ? [start, endTime] : endTime;
225
- const isEqual = (val1, val2) => {
292
+ };
293
+ Timebar.prototype.dispatchOnChange = function (prevValues) {
294
+ var data = this.data;
295
+ var onChange = this.attributes.onChange;
296
+ var _a = this.states, values = _a.values, selectionType = _a.selectionType;
297
+ var _b = __read(values, 2), start = _b[0], end = _b[1];
298
+ var endTime = end === Infinity ? data.at(-1).time : end;
299
+ var newValues = selectionType === 'range' ? [start, endTime] : endTime;
300
+ var isEqual = function (val1, val2) {
226
301
  if (Array.isArray(val1)) {
227
302
  if (!Array.isArray(val2))
228
303
  return false;
@@ -242,10 +317,10 @@ export class Timebar extends Component {
242
317
  if (!prevValues || !isEqual(prevValues, newValues)) {
243
318
  onChange === null || onChange === void 0 ? void 0 : onChange(selectionType === 'range' ? [start, endTime] : endTime);
244
319
  }
245
- }
246
- internalReset(preventEvent) {
320
+ };
321
+ Timebar.prototype.internalReset = function (preventEvent) {
247
322
  var _a, _b;
248
- const { selectionType } = this.states;
323
+ var selectionType = this.states.selectionType;
249
324
  this.internalPause();
250
325
  this.setBySliderValues(selectionType === 'range' ? [0, 1] : [0, 0]);
251
326
  this.renderController();
@@ -254,21 +329,27 @@ export class Timebar extends Component {
254
329
  (_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onReset) === null || _b === void 0 ? void 0 : _b.call(_a);
255
330
  this.dispatchOnChange();
256
331
  }
257
- }
258
- reset() {
332
+ };
333
+ Timebar.prototype.reset = function () {
259
334
  this.internalReset();
260
- }
261
- moveSelection(direction, preventEvent) {
262
- const { data } = this;
263
- const length = data.length;
264
- const { values, selectionType, playMode } = this.states;
265
- const [startTime, endTime] = values;
266
- const startIndex = data.findIndex(({ time }) => time === startTime);
267
- let endIndex = data.findIndex(({ time }) => time === endTime);
335
+ };
336
+ Timebar.prototype.moveSelection = function (direction, preventEvent) {
337
+ var data = this.data;
338
+ var length = data.length;
339
+ var _a = this.states, values = _a.values, selectionType = _a.selectionType, playMode = _a.playMode;
340
+ var _b = __read(values, 2), startTime = _b[0], endTime = _b[1];
341
+ var startIndex = data.findIndex(function (_a) {
342
+ var time = _a.time;
343
+ return time === startTime;
344
+ });
345
+ var endIndex = data.findIndex(function (_a) {
346
+ var time = _a.time;
347
+ return time === endTime;
348
+ });
268
349
  if (endIndex === -1)
269
350
  endIndex = length;
270
- const diff = direction === 'backward' ? -1 : 1;
271
- let currentIndexes;
351
+ var diff = direction === 'backward' ? -1 : 1;
352
+ var currentIndexes;
272
353
  if (selectionType === 'range') {
273
354
  // end 后移一个时间间隔
274
355
  if (playMode === 'acc') {
@@ -285,11 +366,11 @@ export class Timebar extends Component {
285
366
  // end 后移一个时间间隔
286
367
  else
287
368
  currentIndexes = [startIndex, endIndex + diff];
288
- const normalizeIndexes = (indexes) => {
369
+ var normalizeIndexes = function (indexes) {
289
370
  // 先进行排序
290
- const [start, end] = indexes.sort((a, b) => a - b);
371
+ var _a = __read(indexes.sort(function (a, b) { return a - b; }), 2), start = _a[0], end = _a[1];
291
372
  // 保证 index 在 [0, length]
292
- const clampIndex = (index) => clamp(index, 0, length);
373
+ var clampIndex = function (index) { return clamp(index, 0, length); };
293
374
  // 如果 end 超出最大值
294
375
  if (end > length) {
295
376
  // value 模式下,重置到 0
@@ -309,152 +390,126 @@ export class Timebar extends Component {
309
390
  }
310
391
  return [clampIndex(start), clampIndex(end)];
311
392
  };
312
- const normalizedIndexes = normalizeIndexes(currentIndexes);
393
+ var normalizedIndexes = normalizeIndexes(currentIndexes);
313
394
  this.setByIndex(normalizedIndexes);
314
395
  this.updateSelection();
315
396
  return normalizedIndexes;
316
- }
317
- internalBackward(preventEvent) {
397
+ };
398
+ Timebar.prototype.internalBackward = function (preventEvent) {
318
399
  var _a, _b;
319
- const indexes = this.moveSelection('backward', preventEvent);
400
+ var indexes = this.moveSelection('backward', preventEvent);
320
401
  if (!preventEvent) {
321
402
  (_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onBackward) === null || _b === void 0 ? void 0 : _b.call(_a);
322
403
  this.dispatchOnChange();
323
404
  }
324
405
  return indexes;
325
- }
326
- backward() {
406
+ };
407
+ Timebar.prototype.backward = function () {
327
408
  this.internalBackward();
328
- }
329
- internalPlay(preventEvent) {
409
+ };
410
+ Timebar.prototype.internalPlay = function (preventEvent) {
411
+ var _this = this;
330
412
  var _a, _b;
331
- const { data } = this;
332
- const { loop } = this.attributes;
333
- const { speed = 1 } = this.states;
334
- this.playInterval = window.setInterval(() => {
335
- const indexes = this.internalForward();
413
+ var data = this.data;
414
+ var loop = this.attributes.loop;
415
+ var _c = this.states.speed, speed = _c === void 0 ? 1 : _c;
416
+ this.playInterval = window.setInterval(function () {
417
+ var indexes = _this.internalForward();
336
418
  // 如果不是循环播放,则播放到最后一个值时暂停
337
419
  if (indexes[1] === data.length && !loop) {
338
420
  // 这里需要抛出暂停事件
339
- this.internalPause();
340
- this.renderController();
421
+ _this.internalPause();
422
+ _this.renderController();
341
423
  }
342
424
  }, 1000 / speed);
343
425
  this.states.state = 'play';
344
426
  !preventEvent && ((_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onPlay) === null || _b === void 0 ? void 0 : _b.call(_a));
345
- }
346
- play() {
427
+ };
428
+ Timebar.prototype.play = function () {
347
429
  this.internalPlay();
348
- }
349
- internalPause(preventEvent) {
430
+ };
431
+ Timebar.prototype.internalPause = function (preventEvent) {
350
432
  var _a, _b;
351
433
  clearInterval(this.playInterval);
352
434
  this.states.state = 'pause';
353
435
  !preventEvent && ((_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onPause) === null || _b === void 0 ? void 0 : _b.call(_a));
354
- }
355
- pause() {
436
+ };
437
+ Timebar.prototype.pause = function () {
356
438
  this.internalPause();
357
- }
358
- internalForward(preventEvent) {
439
+ };
440
+ Timebar.prototype.internalForward = function (preventEvent) {
359
441
  var _a, _b;
360
- const indexes = this.moveSelection('forward', preventEvent);
442
+ var indexes = this.moveSelection('forward', preventEvent);
361
443
  if (!preventEvent) {
362
444
  (_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onForward) === null || _b === void 0 ? void 0 : _b.call(_a);
363
445
  this.dispatchOnChange();
364
446
  }
365
447
  return indexes;
366
- }
367
- forward() {
448
+ };
449
+ Timebar.prototype.forward = function () {
368
450
  this.internalForward();
369
- }
370
- handleSpeedChange(value) {
451
+ };
452
+ Timebar.prototype.handleSpeedChange = function (value) {
371
453
  var _a, _b;
372
454
  this.states.speed = value;
373
- const { state } = this.states;
455
+ var state = this.states.state;
374
456
  if (state === 'play') {
375
457
  // 重新设定 interval
376
458
  this.internalPause(true);
377
459
  this.internalPlay(true);
378
460
  }
379
461
  (_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onSpeedChange) === null || _b === void 0 ? void 0 : _b.call(_a, value);
380
- }
381
- handleSelectionTypeChange(type) {
462
+ };
463
+ Timebar.prototype.handleSelectionTypeChange = function (type) {
382
464
  var _a, _b;
383
465
  this.states.selectionType = type;
384
466
  this.renderChart();
385
467
  (_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onSelectionTypeChange) === null || _b === void 0 ? void 0 : _b.call(_a, type);
386
- }
387
- handleChartTypeChange(type) {
468
+ };
469
+ Timebar.prototype.handleChartTypeChange = function (type) {
388
470
  var _a, _b;
389
471
  this.states.chartType = type;
390
472
  this.renderChart();
391
473
  (_b = (_a = this.attributes) === null || _a === void 0 ? void 0 : _a.onChartTypeChange) === null || _b === void 0 ? void 0 : _b.call(_a, type);
392
- }
393
- constructor(options) {
394
- super(deepAssign({}, Timebar.defaultOptions, options));
395
- this.axis = this.appendChild(new Axis({
396
- style: { type: 'linear', startPos: [0, 0], endPos: [0, 0], data: [], showArrow: false, animate: false },
397
- }));
398
- /** 时间线 group,用于放置 timeline 或者 chart */
399
- this.timeline = this.appendChild(new Slider({
400
- style: {
401
- onChange: (values) => {
402
- this.handleSliderChange(values);
403
- },
404
- },
405
- }));
406
- this.controller = this.appendChild(new Controller({}));
407
- this.states = {};
408
- this.handleSliderChange = (values) => {
409
- const prevValues = (() => {
410
- const val = this.states.values;
411
- if (Array.isArray(val))
412
- return [...val];
413
- return val;
414
- })();
415
- this.setBySliderValues(values);
416
- this.dispatchOnChange(prevValues);
417
- };
418
- const { selectionType, chartType, speed, state, playMode, values } = this.attributes;
419
- this.states = { chartType, playMode, selectionType, speed, state };
420
- this.setByTimebarValues(values);
421
- }
422
- render() {
423
- const { axisBBox, controllerBBox, timelineBBox } = this.space;
474
+ };
475
+ Timebar.prototype.render = function () {
476
+ var _a = this.space, axisBBox = _a.axisBBox, controllerBBox = _a.controllerBBox, timelineBBox = _a.timelineBBox;
424
477
  this.renderController(controllerBBox);
425
478
  this.renderAxis(axisBBox);
426
479
  this.renderChart(timelineBBox);
427
480
  if (this.states.state === 'play')
428
481
  this.internalPlay();
429
- }
430
- destroy() {
431
- super.destroy();
482
+ };
483
+ Timebar.prototype.destroy = function () {
484
+ _super.prototype.destroy.call(this);
432
485
  this.internalPause(true);
433
- }
434
- }
435
- Timebar.defaultOptions = {
436
- style: {
437
- x: 0,
438
- y: 0,
439
- axisLabelFill: '#6e6e6e',
440
- axisLabelTextAlign: 'left',
441
- axisLabelTextBaseline: 'top',
442
- axisLabelTransform: 'translate(5, -12)',
443
- axisLineLineWidth: 1,
444
- axisLineStroke: '#cacdd1',
445
- axisTickLength: 15,
446
- axisTickLineWidth: 1,
447
- axisTickStroke: '#cacdd1',
448
- chartShowLabel: false,
449
- chartType: 'line',
450
- controllerAlign: 'center',
451
- controllerHeight: 40,
452
- data: [],
453
- interval: 'day',
454
- loop: false,
455
- playMode: 'acc',
456
- selectionType: 'range',
457
- type: 'time',
458
- },
459
- };
486
+ };
487
+ Timebar.defaultOptions = {
488
+ style: {
489
+ x: 0,
490
+ y: 0,
491
+ axisLabelFill: '#6e6e6e',
492
+ axisLabelTextAlign: 'left',
493
+ axisLabelTextBaseline: 'top',
494
+ axisLabelTransform: 'translate(5, -12)',
495
+ axisLineLineWidth: 1,
496
+ axisLineStroke: '#cacdd1',
497
+ axisTickLength: 15,
498
+ axisTickLineWidth: 1,
499
+ axisTickStroke: '#cacdd1',
500
+ chartShowLabel: false,
501
+ chartType: 'line',
502
+ controllerAlign: 'center',
503
+ controllerHeight: 40,
504
+ data: [],
505
+ interval: 'day',
506
+ loop: false,
507
+ playMode: 'acc',
508
+ selectionType: 'range',
509
+ type: 'time',
510
+ },
511
+ };
512
+ return Timebar;
513
+ }(Component));
514
+ export { Timebar };
460
515
  //# sourceMappingURL=timebar.js.map