@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,4 +1,3 @@
1
- import { __assign, __extends, __read, __spreadArray } from "tslib";
2
1
  import { CustomEvent } from '@antv/g';
3
2
  import { Linear } from '@antv/scale';
4
3
  import { clamp, isUndefined } from '@antv/util';
@@ -16,108 +15,98 @@ import { getNextTickValue } from './continuous/utils';
16
15
  import { getSafetySelections, getStepValueByValue, ifHorizontal } from './utils';
17
16
  function getMinMax(data) {
18
17
  return {
19
- min: Math.min.apply(Math, __spreadArray([], __read(data.map(function (d) { return d.value; })), false)),
20
- max: Math.max.apply(Math, __spreadArray([], __read(data.map(function (d) { return d.value; })), false)),
18
+ min: Math.min(...data.map((d) => d.value)),
19
+ max: Math.max(...data.map((d) => d.value)),
21
20
  };
22
21
  }
23
- var Continuous = /** @class */ (function (_super) {
24
- __extends(Continuous, _super);
25
- function Continuous(options) {
26
- var _this = _super.call(this, options, CONTINUOUS_DEFAULT_OPTIONS) || this;
27
- _this.eventToOffsetScale = new Linear({});
28
- _this.innerRibbonScale = new Linear({});
29
- _this.cacheLabelBBox = null;
30
- _this.cacheHandleBBox = null;
31
- _this.onHovering = function (e) {
32
- var _a = _this.attributes, data = _a.data, block = _a.block;
22
+ export class Continuous extends Component {
23
+ constructor(options) {
24
+ super(options, CONTINUOUS_DEFAULT_OPTIONS);
25
+ this.eventToOffsetScale = new Linear({});
26
+ this.innerRibbonScale = new Linear({});
27
+ this.cacheLabelBBox = null;
28
+ this.cacheHandleBBox = null;
29
+ this.onHovering = (e) => {
30
+ const { data, block } = this.attributes;
33
31
  e.stopPropagation();
34
- var value = _this.getValueByCanvasPoint(e);
32
+ const value = this.getValueByCanvasPoint(e);
35
33
  if (block) {
36
- var range = getNextTickValue(data.map(function (_a) {
37
- var value = _a.value;
38
- return value;
39
- }), value).range;
40
- var selection = _this.getRealSelection(range);
41
- _this.showIndicator((range[0] + range[1]) / 2, "".concat(selection[0], "-").concat(selection[1]));
42
- _this.dispatchIndicated(value, range);
34
+ const { range } = getNextTickValue(data.map(({ value }) => value), value);
35
+ const selection = this.getRealSelection(range);
36
+ this.showIndicator((range[0] + range[1]) / 2, `${selection[0]}-${selection[1]}`);
37
+ this.dispatchIndicated(value, range);
43
38
  }
44
39
  else {
45
- var safetyValue = _this.getTickValue(value);
46
- _this.showIndicator(safetyValue, "".concat(_this.getRealValue(safetyValue)));
47
- _this.dispatchIndicated(safetyValue);
40
+ const safetyValue = this.getTickValue(value);
41
+ this.showIndicator(safetyValue, `${this.getRealValue(safetyValue)}`);
42
+ this.dispatchIndicated(safetyValue);
48
43
  }
49
44
  };
50
- _this.onDragStart = function (target) { return function (e) {
45
+ this.onDragStart = (target) => (e) => {
51
46
  e.stopPropagation();
52
47
  // 关闭滑动
53
- if (!_this.attributes.slidable)
48
+ if (!this.attributes.slidable)
54
49
  return;
55
- _this.target = target;
56
- _this.prevValue = _this.getTickValue(_this.getValueByCanvasPoint(e));
57
- document.addEventListener('mousemove', _this.onDragging);
58
- document.addEventListener('touchmove', _this.onDragging);
59
- document.addEventListener('mouseleave', _this.onDragEnd);
60
- document.addEventListener('mouseup', _this.onDragEnd);
61
- document.addEventListener('mouseup', _this.onDragEnd);
62
- document.addEventListener('touchend', _this.onDragEnd);
63
- }; };
64
- _this.onDragging = function (e) {
65
- var target = _this.target;
66
- _this.updateMouse();
67
- var _a = __read(_this.selection, 2), start = _a[0], end = _a[1];
68
- var currValue = _this.getTickValue(_this.getValueByCanvasPoint(e));
69
- var diffValue = currValue - _this.prevValue;
50
+ this.target = target;
51
+ this.prevValue = this.getTickValue(this.getValueByCanvasPoint(e));
52
+ document.addEventListener('mousemove', this.onDragging);
53
+ document.addEventListener('touchmove', this.onDragging);
54
+ document.addEventListener('mouseleave', this.onDragEnd);
55
+ document.addEventListener('mouseup', this.onDragEnd);
56
+ document.addEventListener('mouseup', this.onDragEnd);
57
+ document.addEventListener('touchend', this.onDragEnd);
58
+ };
59
+ this.onDragging = (e) => {
60
+ const { target } = this;
61
+ this.updateMouse();
62
+ const [start, end] = this.selection;
63
+ const currValue = this.getTickValue(this.getValueByCanvasPoint(e));
64
+ const diffValue = currValue - this.prevValue;
70
65
  if (target === 'start')
71
- start !== currValue && _this.updateSelection(currValue, end);
66
+ start !== currValue && this.updateSelection(currValue, end);
72
67
  else if (target === 'end')
73
- end !== currValue && _this.updateSelection(start, currValue);
68
+ end !== currValue && this.updateSelection(start, currValue);
74
69
  else if (target === 'ribbon' && diffValue !== 0) {
75
- _this.prevValue = currValue;
76
- _this.updateSelection(diffValue, diffValue, true);
70
+ this.prevValue = currValue;
71
+ this.updateSelection(diffValue, diffValue, true);
77
72
  }
78
73
  };
79
- _this.onDragEnd = function () {
80
- _this.style.cursor = 'pointer';
81
- document.removeEventListener('mousemove', _this.onDragging);
82
- document.removeEventListener('touchmove', _this.onDragging);
83
- document.removeEventListener('mouseup', _this.onDragEnd);
84
- document.removeEventListener('touchend', _this.onDragEnd);
74
+ this.onDragEnd = () => {
75
+ this.style.cursor = 'pointer';
76
+ document.removeEventListener('mousemove', this.onDragging);
77
+ document.removeEventListener('touchmove', this.onDragging);
78
+ document.removeEventListener('mouseup', this.onDragEnd);
79
+ document.removeEventListener('touchend', this.onDragEnd);
85
80
  };
86
- return _this;
87
- }
88
- Object.defineProperty(Continuous.prototype, "handleOffsetRatio", {
89
- get: function () {
90
- return this.ifHorizontal(0.5, 0.5);
91
- },
92
- enumerable: false,
93
- configurable: true
94
- });
95
- Continuous.prototype.getBBox = function () {
96
- var _a = this.attributes, width = _a.width, height = _a.height;
81
+ }
82
+ get handleOffsetRatio() {
83
+ return this.ifHorizontal(0.5, 0.5);
84
+ }
85
+ getBBox() {
86
+ const { width, height } = this.attributes;
97
87
  return new BBox(0, 0, width, height);
98
- };
99
- Continuous.prototype.render = function (attributes, container) {
100
- var _this = this;
88
+ }
89
+ render(attributes, container) {
101
90
  // 渲染顺序
102
91
  // 1. 绘制 title, 获得可用空间
103
92
  // 2. 绘制 label, handle
104
93
  // 3. 基于可用空间、label高度、handle 宽高,计算 ribbon 宽高
105
94
  // 4. 绘制 ribbon
106
95
  // 5. 调整 label、handle 位置
107
- var showLabel = attributes.showLabel;
96
+ const { showLabel } = attributes;
108
97
  /** title */
109
98
  this.renderTitle(select(container));
110
- var _a = this.availableSpace, x = _a.x, y = _a.y;
99
+ const { x, y } = this.availableSpace;
111
100
  /** label */
112
101
  /** content */
113
- var contentGroup = select(container)
102
+ const contentGroup = select(container)
114
103
  .maybeAppendByClassName(CLASS_NAMES.contentGroup, 'g')
115
- .styles({ transform: "translate(".concat(x, ", ").concat(y, ")") });
116
- var labelGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.labelGroup, 'g').styles({ zIndex: 1 });
117
- ifShow(!!showLabel, labelGroup, function (group) {
118
- _this.renderLabel(group);
104
+ .styles({ transform: `translate(${x}, ${y})` });
105
+ const labelGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.labelGroup, 'g').styles({ zIndex: 1 });
106
+ ifShow(!!showLabel, labelGroup, (group) => {
107
+ this.renderLabel(group);
119
108
  });
120
- var ribbonGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.ribbonGroup, 'g').styles({ zIndex: 0 });
109
+ const ribbonGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.ribbonGroup, 'g').styles({ zIndex: 0 });
121
110
  /** handle */
122
111
  this.handlesGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.handlesGroup, 'g').styles({ zIndex: 2 });
123
112
  this.renderHandles();
@@ -128,201 +117,153 @@ var Continuous = /** @class */ (function (_super) {
128
117
  this.adjustLabel();
129
118
  this.adjustHandles();
130
119
  // this.adjustTitle();
131
- };
132
- Object.defineProperty(Continuous.prototype, "range", {
133
- get: function () {
134
- var _a = this.attributes, data = _a.data, domain = _a.domain;
135
- return domain ? { min: domain[0], max: domain[1] } : getMinMax(data);
136
- },
137
- enumerable: false,
138
- configurable: true
139
- });
140
- Object.defineProperty(Continuous.prototype, "ribbonScale", {
141
- get: function () {
142
- var _a = this.range, min = _a.min, max = _a.max;
143
- this.innerRibbonScale.update({
144
- domain: [min, max],
145
- range: [0, 1],
146
- });
147
- return this.innerRibbonScale;
148
- },
149
- enumerable: false,
150
- configurable: true
151
- });
152
- Object.defineProperty(Continuous.prototype, "ribbonRange", {
153
- get: function () {
154
- var _a = __read(this.selection, 2), min = _a[0], max = _a[1];
155
- var scale = this.ribbonScale;
156
- return [scale.map(min), scale.map(max)];
157
- },
158
- enumerable: false,
159
- configurable: true
160
- });
161
- Object.defineProperty(Continuous.prototype, "selection", {
162
- get: function () {
163
- var _a = this.range, min = _a.min, max = _a.max;
164
- var _b = this.attributes.defaultValue, _c = _b === void 0 ? [min, max] : _b, _d = __read(_c, 2), start = _d[0], end = _d[1];
165
- return [start, end];
166
- },
167
- enumerable: false,
168
- configurable: true
169
- });
170
- Continuous.prototype.ifHorizontal = function (a, b) {
120
+ }
121
+ get range() {
122
+ const { data, domain } = this.attributes;
123
+ return domain ? { min: domain[0], max: domain[1] } : getMinMax(data);
124
+ }
125
+ get ribbonScale() {
126
+ const { min, max } = this.range;
127
+ this.innerRibbonScale.update({
128
+ domain: [min, max],
129
+ range: [0, 1],
130
+ });
131
+ return this.innerRibbonScale;
132
+ }
133
+ get ribbonRange() {
134
+ const [min, max] = this.selection;
135
+ const scale = this.ribbonScale;
136
+ return [scale.map(min), scale.map(max)];
137
+ }
138
+ get selection() {
139
+ const { min, max } = this.range;
140
+ const { defaultValue: [start, end] = [min, max] } = this.attributes;
141
+ return [start, end];
142
+ }
143
+ ifHorizontal(a, b) {
171
144
  return ifHorizontal(this.attributes.orientation, typeof a === 'function' ? a() : a, typeof b === 'function' ? b() : b);
172
- };
173
- Continuous.prototype.renderTitle = function (container) {
174
- var _a = this.attributes, showTitle = _a.showTitle, titleText = _a.titleText, width = _a.width, height = _a.height;
175
- var style = subStyleProps(this.attributes, 'title');
176
- var finalTitleStyle = __assign(__assign({}, style), { width: width, height: height, text: titleText });
177
- var that = this;
145
+ }
146
+ renderTitle(container) {
147
+ const { showTitle, titleText, width, height } = this.attributes;
148
+ const style = subStyleProps(this.attributes, 'title');
149
+ const finalTitleStyle = Object.assign(Object.assign({}, style), { width, height, text: titleText });
150
+ const that = this;
178
151
  container
179
152
  .selectAll(CLASS_NAMES.title.class)
180
153
  .data(showTitle ? [titleText] : [])
181
- .join(function (enter) {
182
- return enter
183
- .append(function () { return new Title({ style: finalTitleStyle }); })
184
- .attr('className', CLASS_NAMES.title.name)
185
- .each(function () {
186
- that.title = this;
187
- });
188
- }, function (update) { return update.update(finalTitleStyle); }, function (exit) {
189
- return exit
190
- .each(function () {
191
- that.title = undefined;
192
- })
193
- .remove();
194
- });
195
- };
196
- Object.defineProperty(Continuous.prototype, "availableSpace", {
197
- get: function () {
198
- if (this.title)
199
- return this.title.getAvailableSpace();
200
- var _a = this.attributes, width = _a.width, height = _a.height;
201
- return new BBox(0, 0, width, height);
202
- },
203
- enumerable: false,
204
- configurable: true
205
- });
206
- Object.defineProperty(Continuous.prototype, "labelFixedSpacing", {
207
- get: function () {
208
- var showTick = this.attributes.showTick;
209
- return showTick ? 5 : 0;
210
- },
211
- enumerable: false,
212
- configurable: true
213
- });
214
- Object.defineProperty(Continuous.prototype, "labelPosition", {
215
- get: function () {
216
- var _a = this.attributes, orientation = _a.orientation, labelDirection = _a.labelDirection;
217
- var positions = {
218
- vertical: { positive: 'right', negative: 'left' },
219
- horizontal: { positive: 'bottom', negative: 'top' },
220
- };
221
- return positions[orientation][labelDirection];
222
- },
223
- enumerable: false,
224
- configurable: true
225
- });
226
- Object.defineProperty(Continuous.prototype, "labelBBox", {
227
- get: function () {
228
- var _a;
229
- var showLabel = this.attributes.showLabel;
230
- if (!showLabel)
231
- return new BBox(0, 0, 0, 0);
232
- if (this.cacheLabelBBox)
233
- return this.cacheLabelBBox;
234
- var _b = ((_a = this.label.querySelector(AXIS_CLASS_NAMES.labelGroup.class)) === null || _a === void 0 ? void 0 : _a.children.slice(-1)[0]).getBBox(), width = _b.width, height = _b.height;
235
- this.cacheLabelBBox = new BBox(0, 0, width, height);
154
+ .join((enter) => enter
155
+ .append(() => new Title({ style: finalTitleStyle }))
156
+ .attr('className', CLASS_NAMES.title.name)
157
+ .each(function () {
158
+ that.title = this;
159
+ }), (update) => update.update(finalTitleStyle), (exit) => exit
160
+ .each(() => {
161
+ that.title = undefined;
162
+ })
163
+ .remove());
164
+ }
165
+ get availableSpace() {
166
+ if (this.title)
167
+ return this.title.getAvailableSpace();
168
+ const { width, height } = this.attributes;
169
+ return new BBox(0, 0, width, height);
170
+ }
171
+ get labelFixedSpacing() {
172
+ const { showTick } = this.attributes;
173
+ return showTick ? 5 : 0;
174
+ }
175
+ get labelPosition() {
176
+ const { orientation, labelDirection } = this.attributes;
177
+ const positions = {
178
+ vertical: { positive: 'right', negative: 'left' },
179
+ horizontal: { positive: 'bottom', negative: 'top' },
180
+ };
181
+ return positions[orientation][labelDirection];
182
+ }
183
+ get labelBBox() {
184
+ var _a;
185
+ const { showLabel } = this.attributes;
186
+ if (!showLabel)
187
+ return new BBox(0, 0, 0, 0);
188
+ if (this.cacheLabelBBox)
236
189
  return this.cacheLabelBBox;
237
- },
238
- enumerable: false,
239
- configurable: true
240
- });
241
- Object.defineProperty(Continuous.prototype, "labelShape", {
242
- get: function () {
243
- var _a = this.attributes, showLabel = _a.showLabel, _b = _a.labelSpacing, labelSpacing = _b === void 0 ? 0 : _b;
244
- if (!showLabel)
245
- return { width: 0, height: 0, size: 0, length: 0 };
246
- var _c = this.labelBBox, width = _c.width, height = _c.height;
247
- var size = this.ifHorizontal(height, width) + labelSpacing + this.labelFixedSpacing;
248
- var length = this.ifHorizontal(width, height);
249
- return { width: width, height: height, size: size, length: length };
250
- },
251
- enumerable: false,
252
- configurable: true
253
- });
254
- Object.defineProperty(Continuous.prototype, "ribbonBBox", {
255
- get: function () {
256
- var _a = this.attributes, showHandle = _a.showHandle, userDefinedRibbonSize = _a.ribbonSize;
257
- var _b = this.availableSpace, availableWidth = _b.width, availableHeight = _b.height;
258
- var _c = this.labelShape, labelSize = _c.size, labelLength = _c.length;
259
- var _d = __read(this.ifHorizontal([availableHeight, availableWidth], [availableWidth, availableHeight]), 2), availableSize = _d[0], availableLength = _d[1];
260
- var _e = showHandle ? this.handleShape : { size: 0, length: 0 }, handleSize = _e.size, handleLength = _e.length;
261
- var handleRatio = this.handleOffsetRatio;
262
- var ribbonSize = 0;
263
- var labelPosition = this.labelPosition;
264
- if (userDefinedRibbonSize) {
265
- ribbonSize = userDefinedRibbonSize;
266
- }
267
- else if (['bottom', 'right'].includes(labelPosition)) {
268
- ribbonSize = Math.min(availableSize - labelSize, (availableSize - handleSize) / handleRatio);
269
- }
270
- else if (availableSize * (1 - handleRatio) > handleSize) {
271
- ribbonSize = Math.max(availableSize - labelSize, 0);
272
- }
273
- else
274
- ribbonSize = Math.max((availableSize - labelSize - handleSize) / handleRatio, 0);
275
- var edgeLength = Math.max(handleLength, labelLength);
276
- var ribbonLength = availableLength - edgeLength;
277
- var _f = __read(this.ifHorizontal([ribbonLength, ribbonSize], [ribbonSize, ribbonLength]), 2), width = _f[0], height = _f[1];
278
- // 需要考虑 handle 的占用空间
279
- // todo 为了防止因为 handle 文本变化导致的 ribbon 位置变化,handle size 取最大值
280
- var finalLabelOccupy = ['top', 'left'].includes(labelPosition) ? labelSize : 0;
281
- var _g = __read(this.ifHorizontal([edgeLength / 2, finalLabelOccupy], [finalLabelOccupy, edgeLength / 2]), 2), x = _g[0], y = _g[1];
282
- return new BBox(x, y, width, height);
283
- },
284
- enumerable: false,
285
- configurable: true
286
- });
287
- Object.defineProperty(Continuous.prototype, "ribbonShape", {
288
- get: function () {
289
- var _a = this.ribbonBBox, width = _a.width, height = _a.height;
290
- return this.ifHorizontal({ size: height, length: width }, { size: width, length: height });
291
- },
292
- enumerable: false,
293
- configurable: true
294
- });
295
- Continuous.prototype.renderRibbon = function (container) {
296
- var _a = this.attributes, data = _a.data, type = _a.type, orientation = _a.orientation, color = _a.color, block = _a.block;
297
- var ribbonStyle = subStyleProps(this.attributes, 'ribbon');
298
- var _b = this.range, min = _b.min, max = _b.max;
299
- var _c = this.ribbonBBox, x = _c.x, y = _c.y;
300
- var _d = this.ribbonShape, length = _d.length, size = _d.size;
301
- var style = deepAssign({
302
- transform: "translate(".concat(x, ", ").concat(y, ")"),
303
- length: length,
304
- size: size,
305
- type: type,
306
- orientation: orientation,
307
- color: color,
308
- block: block,
309
- partition: data.map(function (d) { return (d.value - min) / (max - min); }),
190
+ const { width, height } = ((_a = this.label.querySelector(AXIS_CLASS_NAMES.labelGroup.class)) === null || _a === void 0 ? void 0 : _a.children.slice(-1)[0]).getBBox();
191
+ this.cacheLabelBBox = new BBox(0, 0, width, height);
192
+ return this.cacheLabelBBox;
193
+ }
194
+ get labelShape() {
195
+ const { showLabel, labelSpacing = 0 } = this.attributes;
196
+ if (!showLabel)
197
+ return { width: 0, height: 0, size: 0, length: 0 };
198
+ const { width, height } = this.labelBBox;
199
+ const size = this.ifHorizontal(height, width) + labelSpacing + this.labelFixedSpacing;
200
+ const length = this.ifHorizontal(width, height);
201
+ return { width, height, size, length };
202
+ }
203
+ get ribbonBBox() {
204
+ const { showHandle, ribbonSize: userDefinedRibbonSize } = this.attributes;
205
+ const { width: availableWidth, height: availableHeight } = this.availableSpace;
206
+ const { size: labelSize, length: labelLength } = this.labelShape;
207
+ const [availableSize, availableLength] = this.ifHorizontal([availableHeight, availableWidth], [availableWidth, availableHeight]);
208
+ const { size: handleSize, length: handleLength } = showHandle ? this.handleShape : { size: 0, length: 0 };
209
+ const handleRatio = this.handleOffsetRatio;
210
+ let ribbonSize = 0;
211
+ const labelPosition = this.labelPosition;
212
+ if (userDefinedRibbonSize) {
213
+ ribbonSize = userDefinedRibbonSize;
214
+ }
215
+ else if (['bottom', 'right'].includes(labelPosition)) {
216
+ ribbonSize = Math.min(availableSize - labelSize, (availableSize - handleSize) / handleRatio);
217
+ }
218
+ else if (availableSize * (1 - handleRatio) > handleSize) {
219
+ ribbonSize = Math.max(availableSize - labelSize, 0);
220
+ }
221
+ else
222
+ ribbonSize = Math.max((availableSize - labelSize - handleSize) / handleRatio, 0);
223
+ const edgeLength = Math.max(handleLength, labelLength);
224
+ const ribbonLength = availableLength - edgeLength;
225
+ const [width, height] = this.ifHorizontal([ribbonLength, ribbonSize], [ribbonSize, ribbonLength]);
226
+ // 需要考虑 handle 的占用空间
227
+ // todo 为了防止因为 handle 文本变化导致的 ribbon 位置变化,handle size 取最大值
228
+ const finalLabelOccupy = ['top', 'left'].includes(labelPosition) ? labelSize : 0;
229
+ const [x, y] = this.ifHorizontal([edgeLength / 2, finalLabelOccupy], [finalLabelOccupy, edgeLength / 2]);
230
+ return new BBox(x, y, width, height);
231
+ }
232
+ get ribbonShape() {
233
+ const { width, height } = this.ribbonBBox;
234
+ return this.ifHorizontal({ size: height, length: width }, { size: width, length: height });
235
+ }
236
+ renderRibbon(container) {
237
+ const { data, type, orientation, color, block } = this.attributes;
238
+ const ribbonStyle = subStyleProps(this.attributes, 'ribbon');
239
+ const { min, max } = this.range;
240
+ const { x, y } = this.ribbonBBox;
241
+ const { length, size } = this.ribbonShape;
242
+ const style = deepAssign({
243
+ transform: `translate(${x}, ${y})`,
244
+ length,
245
+ size,
246
+ type,
247
+ orientation,
248
+ color,
249
+ block,
250
+ partition: data.map((d) => (d.value - min) / (max - min)),
310
251
  range: this.ribbonRange,
311
252
  }, ribbonStyle);
312
- this.ribbon = container.maybeAppendByClassName(CLASS_NAMES.ribbon, function () { return new Ribbon({ style: style }); }).update(style);
313
- };
314
- Continuous.prototype.getHandleClassName = function (type) {
253
+ this.ribbon = container.maybeAppendByClassName(CLASS_NAMES.ribbon, () => new Ribbon({ style })).update(style);
254
+ }
255
+ getHandleClassName(type) {
315
256
  // @ts-ignore
316
- return "".concat(CLASS_NAMES.prefix("".concat(type, "-handle")));
317
- };
318
- Continuous.prototype.renderHandles = function () {
319
- var _a = this.attributes, showHandle = _a.showHandle, orientation = _a.orientation;
320
- var handleStyle = subStyleProps(this.attributes, 'handle');
321
- var _b = __read(this.selection, 2), min = _b[0], max = _b[1];
322
- var style = __assign(__assign({}, handleStyle), { orientation: orientation });
323
- var _c = handleStyle.shape, shape = _c === void 0 ? 'slider' : _c;
324
- var HandleCtor = shape === 'basic' ? Handle : SliderHandle;
325
- var that = this;
257
+ return `${CLASS_NAMES.prefix(`${type}-handle`)}`;
258
+ }
259
+ renderHandles() {
260
+ const { showHandle, orientation } = this.attributes;
261
+ const handleStyle = subStyleProps(this.attributes, 'handle');
262
+ const [min, max] = this.selection;
263
+ const style = Object.assign(Object.assign({}, handleStyle), { orientation });
264
+ const { shape = 'slider' } = handleStyle;
265
+ const HandleCtor = shape === 'basic' ? Handle : SliderHandle;
266
+ const that = this;
326
267
  this.handlesGroup
327
268
  .selectAll(CLASS_NAMES.handle.class)
328
269
  .data(showHandle
@@ -330,234 +271,202 @@ var Continuous = /** @class */ (function (_super) {
330
271
  { value: min, type: 'start' },
331
272
  { value: max, type: 'end' },
332
273
  ]
333
- : [], function (d) { return d.type; })
334
- .join(function (enter) {
335
- return enter
336
- .append(function () { return new HandleCtor({ style: style }); })
337
- .attr('className', function (_a) {
338
- var type = _a.type;
339
- return "".concat(CLASS_NAMES.handle, " ").concat(that.getHandleClassName(type));
340
- })
341
- .each(function (_a) {
342
- var type = _a.type, labelText = _a.value;
343
- this.update({ labelText: labelText });
344
- var name = "".concat(type, "Handle");
345
- that[name] = this;
346
- this.addEventListener('pointerdown', that.onDragStart(type));
347
- });
348
- }, function (update) {
349
- return update.update(style).each(function (_a) {
350
- var labelText = _a.value;
351
- this.update({ labelText: labelText });
352
- });
353
- }, function (exit) {
354
- return exit
355
- .each(function (_a) {
356
- var type = _a.type;
357
- var name = "".concat(type, "Handle");
358
- that[name] = undefined;
359
- })
360
- .remove();
361
- });
362
- };
363
- Continuous.prototype.adjustHandles = function () {
364
- var _a = __read(this.selection, 2), min = _a[0], max = _a[1];
274
+ : [], (d) => d.type)
275
+ .join((enter) => enter
276
+ .append(() => new HandleCtor({ style }))
277
+ .attr('className', ({ type }) => `${CLASS_NAMES.handle} ${that.getHandleClassName(type)}`)
278
+ .each(function ({ type, value: labelText }) {
279
+ this.update({ labelText });
280
+ const name = `${type}Handle`;
281
+ that[name] = this;
282
+ this.addEventListener('pointerdown', that.onDragStart(type));
283
+ }), (update) => update.update(style).each(function ({ value: labelText }) {
284
+ this.update({ labelText });
285
+ }), (exit) => exit
286
+ .each(({ type }) => {
287
+ const name = `${type}Handle`;
288
+ that[name] = undefined;
289
+ })
290
+ .remove());
291
+ }
292
+ adjustHandles() {
293
+ const [min, max] = this.selection;
365
294
  this.setHandlePosition('start', min);
366
295
  this.setHandlePosition('end', max);
367
- };
368
- Object.defineProperty(Continuous.prototype, "handleBBox", {
369
- get: function () {
370
- if (this.cacheHandleBBox)
371
- return this.cacheHandleBBox;
372
- if (!this.attributes.showHandle)
373
- return new BBox(0, 0, 0, 0);
374
- var _a = this.startHandle.getBBox(), startHandleWidth = _a.width, startHandleHeight = _a.height;
375
- var _b = this.endHandle.getBBox(), endHandleWidth = _b.width, endHandleHeight = _b.height;
376
- var _c = __read([Math.max(startHandleWidth, endHandleWidth), Math.max(startHandleHeight, endHandleHeight)], 2), width = _c[0], height = _c[1];
377
- this.cacheHandleBBox = new BBox(0, 0, width, height);
296
+ }
297
+ get handleBBox() {
298
+ if (this.cacheHandleBBox)
378
299
  return this.cacheHandleBBox;
379
- },
380
- enumerable: false,
381
- configurable: true
382
- });
383
- Object.defineProperty(Continuous.prototype, "handleShape", {
384
- /**
385
- * 因为 handle label 的宽高是动态的,所以 handle bbox 是第一次渲染时的 bbox
386
- */
387
- get: function () {
388
- var _a = this.handleBBox, width = _a.width, height = _a.height;
389
- var _b = __read(this.ifHorizontal([height, width], [width, height]), 2), size = _b[0], length = _b[1];
390
- return { width: width, height: height, size: size, length: length };
391
- },
392
- enumerable: false,
393
- configurable: true
394
- });
395
- Continuous.prototype.setHandlePosition = function (type, value) {
396
- var handleFormatter = this.attributes.handleFormatter;
397
- var _a = this.ribbonBBox, ribbonX = _a.x, ribbonY = _a.y;
398
- var ribbonSize = this.ribbonShape.size;
399
- var offset = this.getOffset(value);
400
- var _b = __read(this.ifHorizontal([ribbonX + offset, ribbonY + ribbonSize * this.handleOffsetRatio], [ribbonX + ribbonSize * this.handleOffsetRatio, ribbonY + offset]), 2), x = _b[0], y = _b[1];
401
- var handle = this.handlesGroup.select(".".concat(this.getHandleClassName(type))).node();
402
- handle === null || handle === void 0 ? void 0 : handle.update({ transform: "translate(".concat(x, ", ").concat(y, ")"), formatter: handleFormatter });
403
- };
404
- Continuous.prototype.renderIndicator = function (container) {
405
- var style = subStyleProps(this.attributes, 'indicator');
406
- this.indicator = container.maybeAppendByClassName(CLASS_NAMES.indicator, function () { return new Indicator({}); }).update(style);
300
+ if (!this.attributes.showHandle)
301
+ return new BBox(0, 0, 0, 0);
302
+ const { width: startHandleWidth, height: startHandleHeight } = this.startHandle.getBBox();
303
+ const { width: endHandleWidth, height: endHandleHeight } = this.endHandle.getBBox();
304
+ const [width, height] = [Math.max(startHandleWidth, endHandleWidth), Math.max(startHandleHeight, endHandleHeight)];
305
+ this.cacheHandleBBox = new BBox(0, 0, width, height);
306
+ return this.cacheHandleBBox;
307
+ }
308
+ /**
309
+ * 因为 handle label 的宽高是动态的,所以 handle bbox 是第一次渲染时的 bbox
310
+ */
311
+ get handleShape() {
312
+ const { width, height } = this.handleBBox;
313
+ const [size, length] = this.ifHorizontal([height, width], [width, height]);
314
+ return { width, height, size, length };
315
+ }
316
+ setHandlePosition(type, value) {
317
+ const { handleFormatter } = this.attributes;
318
+ const { x: ribbonX, y: ribbonY } = this.ribbonBBox;
319
+ const { size: ribbonSize } = this.ribbonShape;
320
+ const offset = this.getOffset(value);
321
+ const [x, y] = this.ifHorizontal([ribbonX + offset, ribbonY + ribbonSize * this.handleOffsetRatio], [ribbonX + ribbonSize * this.handleOffsetRatio, ribbonY + offset]);
322
+ const handle = this.handlesGroup.select(`.${this.getHandleClassName(type)}`).node();
323
+ handle === null || handle === void 0 ? void 0 : handle.update({ transform: `translate(${x}, ${y})`, formatter: handleFormatter });
324
+ }
325
+ renderIndicator(container) {
326
+ const style = subStyleProps(this.attributes, 'indicator');
327
+ this.indicator = container.maybeAppendByClassName(CLASS_NAMES.indicator, () => new Indicator({})).update(style);
407
328
  // this.hideIndicator();
408
- };
409
- Object.defineProperty(Continuous.prototype, "labelData", {
410
- get: function () {
411
- var _this = this;
412
- var data = this.attributes.data;
413
- return data.reduce(function (acc, curr, index, arr) {
414
- var _a, _b;
415
- var id = (_a = curr === null || curr === void 0 ? void 0 : curr.id) !== null && _a !== void 0 ? _a : index.toString();
416
- acc.push(__assign(__assign({}, curr), { id: id, index: index, type: 'value', label: (_b = curr === null || curr === void 0 ? void 0 : curr.label) !== null && _b !== void 0 ? _b : curr.value.toString(), value: _this.ribbonScale.map(curr.value) }));
417
- if (index < arr.length - 1) {
418
- var next = arr[index + 1];
419
- var _c = __read([curr.value, next.value], 2), cr = _c[0], nx = _c[1];
420
- var midVal = (cr + nx) / 2;
421
- acc.push(__assign(__assign({}, curr), { id: id, index: index, type: 'range', range: [cr, nx], label: [cr, nx].join('~'), value: _this.ribbonScale.map(midVal) }));
422
- }
423
- return acc;
424
- }, []);
425
- },
426
- enumerable: false,
427
- configurable: true
428
- });
429
- Object.defineProperty(Continuous.prototype, "labelStyle", {
430
- get: function () {
431
- var _a = __read(['center', 'middle'], 2), labelTextAlign = _a[0], labelTextBaseline = _a[1];
432
- var labelPosition = this.labelPosition;
433
- if (labelPosition === 'top')
434
- labelTextBaseline = 'bottom';
435
- else if (labelPosition === 'bottom')
436
- labelTextBaseline = 'top';
437
- else if (labelPosition === 'left')
438
- labelTextAlign = 'end';
439
- else if (labelPosition === 'right')
440
- labelTextAlign = 'start';
441
- return {
442
- labelTextAlign: labelTextAlign,
443
- labelTextBaseline: labelTextBaseline,
444
- };
445
- },
446
- enumerable: false,
447
- configurable: true
448
- });
449
- Continuous.prototype.renderLabel = function (container) {
450
- var _a = this.attributes, _b = _a.showTick, showTick = _b === void 0 ? false : _b, labelFilter = _a.labelFilter, labelFormatter = _a.labelFormatter;
451
- var tickStyle = subStyleProps(this.attributes, 'tick');
452
- var labelStyle = subStyleProps(this.attributes, 'label');
453
- var align = labelStyle.align;
454
- var style = deepAssign(__assign({ showLine: false, showGrid: false, showTick: showTick, type: 'linear', startPos: [0, 0], endPos: [0, 0], tickDirection: 'negative', labelTransform: 'rotate(0)' }, this.labelStyle), superStyleProps(tickStyle, 'tick'), superStyleProps(labelStyle, 'label'), { data: this.labelData });
455
- var functionStyle = {
456
- tickFilter: function (datum, index, data) {
329
+ }
330
+ get labelData() {
331
+ const { data } = this.attributes;
332
+ return data.reduce((acc, curr, index, arr) => {
333
+ var _a, _b;
334
+ const id = (_a = curr === null || curr === void 0 ? void 0 : curr.id) !== null && _a !== void 0 ? _a : index.toString();
335
+ acc.push(Object.assign(Object.assign({}, curr), { id,
336
+ index, type: 'value', label: (_b = curr === null || curr === void 0 ? void 0 : curr.label) !== null && _b !== void 0 ? _b : curr.value.toString(), value: this.ribbonScale.map(curr.value) }));
337
+ if (index < arr.length - 1) {
338
+ const next = arr[index + 1];
339
+ const [cr, nx] = [curr.value, next.value];
340
+ const midVal = (cr + nx) / 2;
341
+ acc.push(Object.assign(Object.assign({}, curr), { id,
342
+ index, type: 'range', range: [cr, nx], label: [cr, nx].join('~'), value: this.ribbonScale.map(midVal) }));
343
+ }
344
+ return acc;
345
+ }, []);
346
+ }
347
+ get labelStyle() {
348
+ let [labelTextAlign, labelTextBaseline] = ['center', 'middle'];
349
+ const labelPosition = this.labelPosition;
350
+ if (labelPosition === 'top')
351
+ labelTextBaseline = 'bottom';
352
+ else if (labelPosition === 'bottom')
353
+ labelTextBaseline = 'top';
354
+ else if (labelPosition === 'left')
355
+ labelTextAlign = 'end';
356
+ else if (labelPosition === 'right')
357
+ labelTextAlign = 'start';
358
+ return {
359
+ labelTextAlign,
360
+ labelTextBaseline,
361
+ };
362
+ }
363
+ renderLabel(container) {
364
+ const { showTick = false, labelFilter, labelFormatter } = this.attributes;
365
+ const tickStyle = subStyleProps(this.attributes, 'tick');
366
+ const labelStyle = subStyleProps(this.attributes, 'label');
367
+ const { align } = labelStyle;
368
+ const style = deepAssign(Object.assign({ showLine: false, showGrid: false, showTick, type: 'linear', startPos: [0, 0], endPos: [0, 0], tickDirection: 'negative', labelTransform: 'rotate(0)' }, this.labelStyle), superStyleProps(tickStyle, 'tick'), superStyleProps(labelStyle, 'label'), { data: this.labelData });
369
+ const functionStyle = {
370
+ tickFilter: (datum, index, data) => {
457
371
  if ((datum === null || datum === void 0 ? void 0 : datum.type) !== 'value')
458
372
  return false;
459
373
  if (labelFilter)
460
- return labelFilter(datum, datum.index, data.filter(function (d) { return d.type !== 'value'; }));
374
+ return labelFilter(datum, datum.index, data.filter((d) => d.type !== 'value'));
461
375
  return true;
462
376
  },
463
- labelFilter: function (datum, index, data) {
377
+ labelFilter: (datum, index, data) => {
464
378
  if ((datum === null || datum === void 0 ? void 0 : datum.type) !== align)
465
379
  return false;
466
380
  if (labelFilter)
467
- return labelFilter(datum, datum.index, data.filter(function (d) { return d.type === align; }));
381
+ return labelFilter(datum, datum.index, data.filter((d) => d.type === align));
468
382
  return true;
469
383
  },
470
- labelFormatter: labelFormatter,
384
+ labelFormatter,
471
385
  };
472
- var finalLabelStyle = __assign(__assign(__assign({}, style), functionStyle), { labelOverlap: [{ type: 'hide' }] });
473
- this.label = container.maybeAppendByClassName(CLASS_NAMES.label, function () { return new Axis({ style: finalLabelStyle }); }).node();
386
+ const finalLabelStyle = Object.assign(Object.assign(Object.assign({}, style), functionStyle), { labelOverlap: [{ type: 'hide' }] });
387
+ this.label = container.maybeAppendByClassName(CLASS_NAMES.label, () => new Axis({ style: finalLabelStyle })).node();
474
388
  this.label.update(finalLabelStyle, false);
475
- };
476
- Object.defineProperty(Continuous.prototype, "labelAxisStyle", {
477
- get: function () {
478
- // @ts-ignore
479
- var _a = this.attributes, showTick = _a.showTick, labelDirection = _a.labelDirection, labelSpacing = _a.labelSpacing, definedTickLength = _a.tickLength;
480
- var ribbonSize = this.ribbonShape.size;
481
- var labelPosition = this.labelPosition;
482
- var labelFixedSpacing = this.labelFixedSpacing;
483
- var _b = __read([0, 0, 0], 3), offset = _b[0], spacing = _b[1], tickLength = _b[2];
484
- var internalVal = definedTickLength !== null && definedTickLength !== void 0 ? definedTickLength : ribbonSize;
485
- if (showTick) {
486
- tickLength = internalVal;
487
- spacing = labelFixedSpacing;
488
- if (labelDirection === 'positive') {
489
- if (labelPosition === 'right') {
490
- offset = internalVal;
491
- tickLength = internalVal;
492
- }
493
- else if (labelPosition === 'bottom')
494
- offset = tickLength;
495
- }
496
- else if (labelDirection === 'negative') {
497
- if (labelPosition === 'top')
498
- offset = ribbonSize;
499
- else if (labelPosition === 'left')
500
- offset = ribbonSize;
501
- }
502
- }
503
- else if (labelDirection === 'positive') {
504
- if (labelPosition === 'right')
505
- spacing = internalVal;
506
- else if (labelPosition === 'bottom') {
507
- offset = ribbonSize + labelFixedSpacing;
508
- spacing = labelSpacing;
389
+ }
390
+ get labelAxisStyle() {
391
+ // @ts-ignore
392
+ const { showTick, labelDirection, labelSpacing, tickLength: definedTickLength } = this.attributes;
393
+ const { size: ribbonSize } = this.ribbonShape;
394
+ const labelPosition = this.labelPosition;
395
+ const labelFixedSpacing = this.labelFixedSpacing;
396
+ let [offset, spacing, tickLength] = [0, 0, 0];
397
+ const internalVal = definedTickLength !== null && definedTickLength !== void 0 ? definedTickLength : ribbonSize;
398
+ if (showTick) {
399
+ tickLength = internalVal;
400
+ spacing = labelFixedSpacing;
401
+ if (labelDirection === 'positive') {
402
+ if (labelPosition === 'right') {
403
+ offset = internalVal;
404
+ tickLength = internalVal;
509
405
  }
406
+ else if (labelPosition === 'bottom')
407
+ offset = tickLength;
510
408
  }
511
409
  else if (labelDirection === 'negative') {
512
- if (labelPosition === 'left')
513
- spacing = labelSpacing;
514
- else if (labelPosition === 'top')
515
- spacing = labelSpacing;
410
+ if (labelPosition === 'top')
411
+ offset = ribbonSize;
412
+ else if (labelPosition === 'left')
413
+ offset = ribbonSize;
414
+ }
415
+ }
416
+ else if (labelDirection === 'positive') {
417
+ if (labelPosition === 'right')
418
+ spacing = internalVal;
419
+ else if (labelPosition === 'bottom') {
420
+ offset = ribbonSize + labelFixedSpacing;
421
+ spacing = labelSpacing;
516
422
  }
517
- return { offset: offset, spacing: spacing, tickLength: tickLength };
518
- },
519
- enumerable: false,
520
- configurable: true
521
- });
522
- Continuous.prototype.adjustLabel = function () {
523
- var showLabel = this.attributes.showLabel;
423
+ }
424
+ else if (labelDirection === 'negative') {
425
+ if (labelPosition === 'left')
426
+ spacing = labelSpacing;
427
+ else if (labelPosition === 'top')
428
+ spacing = labelSpacing;
429
+ }
430
+ return { offset, spacing, tickLength };
431
+ }
432
+ adjustLabel() {
433
+ const { showLabel } = this.attributes;
524
434
  if (!showLabel)
525
435
  return;
526
- var _a = this.ribbonBBox, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
527
- var _b = this.labelAxisStyle, axisOffset = _b.offset, axisSpacing = _b.spacing, axisTickLength = _b.tickLength;
528
- var _c = __read(this.ifHorizontal([
436
+ const { x, y, width, height } = this.ribbonBBox;
437
+ const { offset: axisOffset, spacing: axisSpacing, tickLength: axisTickLength } = this.labelAxisStyle;
438
+ const [startPos, endPos] = this.ifHorizontal([
529
439
  [x, y + axisOffset],
530
440
  [x + width, y + axisOffset],
531
441
  ], [
532
442
  [x + axisOffset, y + height],
533
443
  [x + axisOffset, y],
534
- ]), 2), startPos = _c[0], endPos = _c[1];
444
+ ]);
535
445
  this.label.update({
536
- startPos: startPos,
537
- endPos: endPos,
446
+ startPos,
447
+ endPos,
538
448
  tickLength: axisTickLength,
539
449
  labelSpacing: axisSpacing,
540
450
  }, false);
541
- };
542
- Continuous.prototype.bindEvents = function () {
451
+ }
452
+ bindEvents() {
543
453
  this.style.cursor = 'pointer';
544
454
  // 绑定 drag 开始事件
545
455
  this.ribbon.on('pointerdown', this.onDragStart('ribbon'));
546
456
  this.ribbon.on('pointermove', this.onHovering);
547
457
  this.addEventListener('pointerout', this.hideIndicator);
548
- };
549
- Continuous.prototype.showIndicator = function (value, text) {
550
- if (text === void 0) { text = "".concat(value); }
551
- var showIndicator = this.attributes.showIndicator;
458
+ }
459
+ showIndicator(value, text = `${value}`) {
460
+ const { showIndicator } = this.attributes;
552
461
  if (!showIndicator || typeof value !== 'number') {
553
462
  this.hideIndicator();
554
463
  return;
555
464
  }
556
- var _a = this.range, min = _a.min, max = _a.max;
557
- var _b = this.ribbonBBox, x = _b.x, y = _b.y;
558
- var safeValue = clamp(value, min, max);
559
- var offset = this.getOffset(safeValue);
560
- var pos = this.ifHorizontal([offset + x, y], [x, offset + y]);
465
+ const { min, max } = this.range;
466
+ const { x, y } = this.ribbonBBox;
467
+ const safeValue = clamp(value, min, max);
468
+ const offset = this.getOffset(safeValue);
469
+ const pos = this.ifHorizontal([offset + x, y], [x, offset + y]);
561
470
  this.indicator.update({
562
471
  x: pos[0],
563
472
  y: pos[1],
@@ -565,115 +474,102 @@ var Continuous = /** @class */ (function (_super) {
565
474
  labelText: text,
566
475
  });
567
476
  show(this.indicator.node());
568
- };
569
- Continuous.prototype.hideIndicator = function () {
477
+ }
478
+ hideIndicator() {
570
479
  hide(this.indicator.node());
571
- };
572
- Continuous.prototype.updateMouse = function () {
480
+ }
481
+ updateMouse() {
573
482
  if (this.attributes.slidable)
574
483
  this.style.cursor = 'grabbing';
575
- };
576
- Continuous.prototype.setSelection = function (start, end) {
484
+ }
485
+ setSelection(start, end) {
577
486
  this.updateSelection(start, end);
578
- };
579
- Continuous.prototype.updateSelection = function (stVal, endVal, isOffset) {
580
- var _a;
581
- if (isOffset === void 0) { isOffset = false; }
582
- var _b = __read(this.selection, 2), currSt = _b[0], currEnd = _b[1];
583
- var _c = __read([stVal, endVal], 2), start = _c[0], end = _c[1];
487
+ }
488
+ updateSelection(stVal, endVal, isOffset = false) {
489
+ const [currSt, currEnd] = this.selection;
490
+ let [start, end] = [stVal, endVal];
584
491
  if (isOffset) {
585
492
  // 获取当前值
586
493
  start += currSt;
587
494
  end += currEnd;
588
495
  }
589
496
  // 值校验
590
- var _d = this.range, min = _d.min, max = _d.max;
591
- _a = __read(getSafetySelections([min, max], [start, end], this.selection), 2), start = _a[0], end = _a[1];
497
+ const { min, max } = this.range;
498
+ [start, end] = getSafetySelections([min, max], [start, end], this.selection);
592
499
  this.update({ defaultValue: [start, end] });
593
500
  this.dispatchSelection();
594
- };
595
- Object.defineProperty(Continuous.prototype, "step", {
596
- get: function () {
597
- var _a = this.attributes.step, step = _a === void 0 ? 1 : _a;
598
- var _b = this.range, min = _b.min, max = _b.max;
599
- if (isUndefined(step))
600
- return toPrecision((max - min) * STEP_RATIO, 0);
601
- return step;
602
- },
603
- enumerable: false,
604
- configurable: true
605
- });
606
- Continuous.prototype.getTickValue = function (value) {
607
- var _a = this.attributes, data = _a.data, block = _a.block;
608
- var min = this.range.min;
501
+ }
502
+ get step() {
503
+ const { step = 1 } = this.attributes;
504
+ const { min, max } = this.range;
505
+ if (isUndefined(step))
506
+ return toPrecision((max - min) * STEP_RATIO, 0);
507
+ return step;
508
+ }
509
+ getTickValue(value) {
510
+ const { data, block } = this.attributes;
511
+ const { min } = this.range;
609
512
  if (block)
610
- return getNextTickValue(data.map(function (_a) {
611
- var value = _a.value;
612
- return value;
613
- }), value).tick;
513
+ return getNextTickValue(data.map(({ value }) => value), value).tick;
614
514
  return getStepValueByValue(value, this.step, min);
615
- };
515
+ }
616
516
  /**
617
517
  * 事件触发的位置对应的value值
618
518
  */
619
- Continuous.prototype.getValueByCanvasPoint = function (e) {
620
- var _a = this.range, min = _a.min, max = _a.max;
621
- var _b = __read(this.ribbon.node().getPosition(), 2), x = _b[0], y = _b[1];
622
- var startPos = this.ifHorizontal(x, y);
623
- var currValue = this.ifHorizontal.apply(this, __spreadArray([], __read(getEventPos(e)), false));
624
- var offset = currValue - startPos;
625
- var value = clamp(this.getOffset(offset, true), min, max);
519
+ getValueByCanvasPoint(e) {
520
+ const { min, max } = this.range;
521
+ const [x, y] = this.ribbon.node().getPosition();
522
+ const startPos = this.ifHorizontal(x, y);
523
+ const currValue = this.ifHorizontal(...getEventPos(e));
524
+ const offset = currValue - startPos;
525
+ const value = clamp(this.getOffset(offset, true), min, max);
626
526
  return value;
627
- };
527
+ }
628
528
  /** reverse: 屏幕偏移量 -> 值 */
629
- Continuous.prototype.getOffset = function (value, reverse) {
630
- if (reverse === void 0) { reverse = false; }
631
- var _a = this.range, min = _a.min, max = _a.max;
632
- var ribbonLen = this.ribbonShape.length;
633
- var scale = this.eventToOffsetScale;
529
+ getOffset(value, reverse = false) {
530
+ const { min, max } = this.range;
531
+ const { length: ribbonLen } = this.ribbonShape;
532
+ const scale = this.eventToOffsetScale;
634
533
  scale.update({ domain: [min, max], range: [0, ribbonLen] });
635
534
  if (reverse)
636
535
  return scale.invert(value);
637
536
  return scale.map(value);
638
- };
639
- Continuous.prototype.getRealSelection = function (range) {
640
- var max = this.range.max;
641
- var _a = __read(range, 2), start = _a[0], end = _a[1];
537
+ }
538
+ getRealSelection(range) {
539
+ const { max } = this.range;
540
+ const [start, end] = range;
642
541
  return this.ifHorizontal([start, end], [max - end, max - start]);
643
- };
644
- Continuous.prototype.getRealValue = function (value) {
645
- var max = this.range.max;
542
+ }
543
+ getRealValue(value) {
544
+ const { max } = this.range;
646
545
  return this.ifHorizontal(value, max - value);
647
- };
648
- Continuous.prototype.dispatchSelection = function () {
649
- var selection = this.getRealSelection(this.selection);
650
- var evt = new CustomEvent('valuechange', {
546
+ }
547
+ dispatchSelection() {
548
+ const selection = this.getRealSelection(this.selection);
549
+ const evt = new CustomEvent('valuechange', {
651
550
  detail: {
652
551
  value: selection,
653
552
  },
654
553
  });
655
554
  this.dispatchEvent(evt);
656
- };
657
- Continuous.prototype.dispatchIndicated = function (value, range) {
658
- var _this = this;
659
- var max = this.range.max;
660
- var detail = this.ifHorizontal(function () {
555
+ }
556
+ dispatchIndicated(value, range) {
557
+ const { max } = this.range;
558
+ const detail = this.ifHorizontal(() => {
661
559
  return {
662
- value: value,
663
- range: range,
560
+ value,
561
+ range,
664
562
  };
665
- }, function () {
563
+ }, () => {
666
564
  return {
667
565
  value: max - value,
668
- range: range ? _this.getRealSelection(range) : undefined,
566
+ range: range ? this.getRealSelection(range) : undefined,
669
567
  };
670
568
  });
671
- var evt = new CustomEvent('indicate', {
672
- detail: detail,
569
+ const evt = new CustomEvent('indicate', {
570
+ detail,
673
571
  });
674
572
  this.dispatchEvent(evt);
675
- };
676
- return Continuous;
677
- }(Component));
678
- export { Continuous };
573
+ }
574
+ }
679
575
  //# sourceMappingURL=continuous.js.map