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