@antv/component 2.0.4 → 2.1.1-alpha.1

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