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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (516) hide show
  1. package/dist/component.min.js +1 -1
  2. package/esm/animation/fadeIn.d.ts +1 -1
  3. package/esm/animation/fadeOut.d.ts +1 -1
  4. package/esm/animation/utils.d.ts +3 -3
  5. package/esm/animation/utils.js +37 -31
  6. package/esm/animation/utils.js.map +1 -1
  7. package/esm/constant.js +1 -1
  8. package/esm/constant.js.map +1 -1
  9. package/esm/core/component.js +43 -30
  10. package/esm/core/component.js.map +1 -1
  11. package/esm/shapes/Text.js +21 -13
  12. package/esm/shapes/Text.js.map +1 -1
  13. package/esm/ui/axis/axis.d.ts +1 -1
  14. package/esm/ui/axis/axis.js +31 -25
  15. package/esm/ui/axis/axis.js.map +1 -1
  16. package/esm/ui/axis/constant.js +13 -11
  17. package/esm/ui/axis/constant.js.map +1 -1
  18. package/esm/ui/axis/guides/grid.d.ts +1 -1
  19. package/esm/ui/axis/guides/grid.js +34 -29
  20. package/esm/ui/axis/guides/grid.js.map +1 -1
  21. package/esm/ui/axis/guides/labels.js +83 -76
  22. package/esm/ui/axis/guides/labels.js.map +1 -1
  23. package/esm/ui/axis/guides/line.js +87 -74
  24. package/esm/ui/axis/guides/line.js.map +1 -1
  25. package/esm/ui/axis/guides/ticks.d.ts +1 -1
  26. package/esm/ui/axis/guides/ticks.js +39 -31
  27. package/esm/ui/axis/guides/ticks.js.map +1 -1
  28. package/esm/ui/axis/guides/title.d.ts +1 -1
  29. package/esm/ui/axis/guides/title.js +37 -33
  30. package/esm/ui/axis/guides/title.js.map +1 -1
  31. package/esm/ui/axis/guides/utils.js +12 -10
  32. package/esm/ui/axis/guides/utils.js.map +1 -1
  33. package/esm/ui/axis/overlap/autoEllipsis.js +19 -12
  34. package/esm/ui/axis/overlap/autoEllipsis.js.map +1 -1
  35. package/esm/ui/axis/overlap/autoHide.js +24 -20
  36. package/esm/ui/axis/overlap/autoHide.js.map +1 -1
  37. package/esm/ui/axis/overlap/autoRotate.js +25 -11
  38. package/esm/ui/axis/overlap/autoRotate.js.map +1 -1
  39. package/esm/ui/axis/overlap/autoWrap.js +14 -11
  40. package/esm/ui/axis/overlap/autoWrap.js.map +1 -1
  41. package/esm/ui/axis/overlap/index.js +7 -7
  42. package/esm/ui/axis/overlap/index.js.map +1 -1
  43. package/esm/ui/axis/utils/bounds.js +75 -48
  44. package/esm/ui/axis/utils/bounds.js.map +1 -1
  45. package/esm/ui/axis/utils/contain.js +14 -14
  46. package/esm/ui/axis/utils/contain.js.map +1 -1
  47. package/esm/ui/axis/utils/index.js +7 -3
  48. package/esm/ui/axis/utils/index.js.map +1 -1
  49. package/esm/ui/axis/utils/intersect.js +33 -21
  50. package/esm/ui/axis/utils/intersect.js.map +1 -1
  51. package/esm/ui/axis/utils/test.js +41 -29
  52. package/esm/ui/axis/utils/test.js.map +1 -1
  53. package/esm/ui/breadcrumb/index.js +72 -64
  54. package/esm/ui/breadcrumb/index.js.map +1 -1
  55. package/esm/ui/button/constant.js +3 -3
  56. package/esm/ui/button/constant.js.map +1 -1
  57. package/esm/ui/button/index.js +97 -81
  58. package/esm/ui/button/index.js.map +1 -1
  59. package/esm/ui/checkbox/constant.js +4 -4
  60. package/esm/ui/checkbox/constant.js.map +1 -1
  61. package/esm/ui/checkbox/index.js +26 -23
  62. package/esm/ui/checkbox/index.js.map +1 -1
  63. package/esm/ui/crosshair/base.js +45 -29
  64. package/esm/ui/crosshair/base.js.map +1 -1
  65. package/esm/ui/crosshair/circle.js +34 -25
  66. package/esm/ui/crosshair/circle.js.map +1 -1
  67. package/esm/ui/crosshair/constant.js +4 -4
  68. package/esm/ui/crosshair/constant.js.map +1 -1
  69. package/esm/ui/crosshair/line.js +75 -55
  70. package/esm/ui/crosshair/line.js.map +1 -1
  71. package/esm/ui/crosshair/polygon.js +70 -54
  72. package/esm/ui/crosshair/polygon.js.map +1 -1
  73. package/esm/ui/grid/index.d.ts +1 -1
  74. package/esm/ui/grid/index.js +95 -73
  75. package/esm/ui/grid/index.js.map +1 -1
  76. package/esm/ui/indicator/constant.js +2 -2
  77. package/esm/ui/indicator/constant.js.map +1 -1
  78. package/esm/ui/indicator/indicator.js +63 -58
  79. package/esm/ui/indicator/indicator.js.map +1 -1
  80. package/esm/ui/layout/layout.js +66 -52
  81. package/esm/ui/layout/layout.js.map +1 -1
  82. package/esm/ui/legend/base.js +13 -12
  83. package/esm/ui/legend/base.js.map +1 -1
  84. package/esm/ui/legend/category/item.js +156 -122
  85. package/esm/ui/legend/category/item.js.map +1 -1
  86. package/esm/ui/legend/category/items.js +201 -158
  87. package/esm/ui/legend/category/items.js.map +1 -1
  88. package/esm/ui/legend/category.js +56 -46
  89. package/esm/ui/legend/category.js.map +1 -1
  90. package/esm/ui/legend/constant.js +6 -6
  91. package/esm/ui/legend/constant.js.map +1 -1
  92. package/esm/ui/legend/continuous/handle.js +33 -28
  93. package/esm/ui/legend/continuous/handle.js.map +1 -1
  94. package/esm/ui/legend/continuous/ribbon.js +38 -34
  95. package/esm/ui/legend/continuous/ribbon.js.map +1 -1
  96. package/esm/ui/legend/continuous/utils.js +11 -10
  97. package/esm/ui/legend/continuous/utils.js.map +1 -1
  98. package/esm/ui/legend/continuous.js +521 -417
  99. package/esm/ui/legend/continuous.js.map +1 -1
  100. package/esm/ui/legend/utils.js +31 -24
  101. package/esm/ui/legend/utils.js.map +1 -1
  102. package/esm/ui/marker/index.js +44 -38
  103. package/esm/ui/marker/index.js.map +1 -1
  104. package/esm/ui/marker/symbol.js +24 -24
  105. package/esm/ui/marker/symbol.js.map +1 -1
  106. package/esm/ui/marker/utils.js +2 -2
  107. package/esm/ui/marker/utils.js.map +1 -1
  108. package/esm/ui/navigator/index.js +159 -128
  109. package/esm/ui/navigator/index.js.map +1 -1
  110. package/esm/ui/poptip/constant.d.ts +1 -1
  111. package/esm/ui/poptip/constant.js +69 -68
  112. package/esm/ui/poptip/constant.js.map +1 -1
  113. package/esm/ui/poptip/index.js +111 -95
  114. package/esm/ui/poptip/index.js.map +1 -1
  115. package/esm/ui/poptip/utils.js +15 -8
  116. package/esm/ui/poptip/utils.js.map +1 -1
  117. package/esm/ui/scrollbar/index.js +132 -102
  118. package/esm/ui/scrollbar/index.js.map +1 -1
  119. package/esm/ui/select/option.js +58 -48
  120. package/esm/ui/select/option.js.map +1 -1
  121. package/esm/ui/select/select.js +164 -142
  122. package/esm/ui/select/select.js.map +1 -1
  123. package/esm/ui/slider/constant.js +4 -4
  124. package/esm/ui/slider/constant.js.map +1 -1
  125. package/esm/ui/slider/handle.js +54 -46
  126. package/esm/ui/slider/handle.js.map +1 -1
  127. package/esm/ui/slider/index.js +328 -282
  128. package/esm/ui/slider/index.js.map +1 -1
  129. package/esm/ui/sparkline/columns.js +34 -25
  130. package/esm/ui/sparkline/columns.js.map +1 -1
  131. package/esm/ui/sparkline/index.js +180 -145
  132. package/esm/ui/sparkline/index.js.map +1 -1
  133. package/esm/ui/sparkline/lines.js +50 -37
  134. package/esm/ui/sparkline/lines.js.map +1 -1
  135. package/esm/ui/sparkline/path.js +40 -36
  136. package/esm/ui/sparkline/path.js.map +1 -1
  137. package/esm/ui/sparkline/utils.js +9 -8
  138. package/esm/ui/sparkline/utils.js.map +1 -1
  139. package/esm/ui/switch/constant.js +1 -1
  140. package/esm/ui/switch/constant.js.map +1 -1
  141. package/esm/ui/switch/index.js +54 -44
  142. package/esm/ui/switch/index.js.map +1 -1
  143. package/esm/ui/tag/index.js +32 -29
  144. package/esm/ui/tag/index.js.map +1 -1
  145. package/esm/ui/timebar/controller.js +79 -69
  146. package/esm/ui/timebar/controller.js.map +1 -1
  147. package/esm/ui/timebar/handle.js +71 -62
  148. package/esm/ui/timebar/handle.js.map +1 -1
  149. package/esm/ui/timebar/icons.js +478 -308
  150. package/esm/ui/timebar/icons.js.map +1 -1
  151. package/esm/ui/timebar/timebar.js +318 -263
  152. package/esm/ui/timebar/timebar.js.map +1 -1
  153. package/esm/ui/timebar/utils.js +7 -7
  154. package/esm/ui/timebar/utils.js.map +1 -1
  155. package/esm/ui/timeline/index.js +6 -2
  156. package/esm/ui/timeline/index.js.map +1 -1
  157. package/esm/ui/title/index.js +64 -59
  158. package/esm/ui/title/index.js.map +1 -1
  159. package/esm/ui/tooltip/constant.js +30 -26
  160. package/esm/ui/tooltip/constant.js.map +1 -1
  161. package/esm/ui/tooltip/index.js +126 -109
  162. package/esm/ui/tooltip/index.js.map +1 -1
  163. package/esm/util/bbox.js +47 -24
  164. package/esm/util/bbox.js.map +1 -1
  165. package/esm/util/callback.js +2 -1
  166. package/esm/util/callback.js.map +1 -1
  167. package/esm/util/classnames.js +10 -8
  168. package/esm/util/classnames.js.map +1 -1
  169. package/esm/util/deep-assign.js +14 -6
  170. package/esm/util/deep-assign.js.map +1 -1
  171. package/esm/util/defined.js +1 -1
  172. package/esm/util/defined.js.map +1 -1
  173. package/esm/util/ellipsis.js +2 -1
  174. package/esm/util/ellipsis.js.map +1 -1
  175. package/esm/util/event.js +3 -3
  176. package/esm/util/event.js.map +1 -1
  177. package/esm/util/geometry/line-length.js +4 -1
  178. package/esm/util/geometry/line-length.js.map +1 -1
  179. package/esm/util/geometry/lines-intersection.js +10 -5
  180. package/esm/util/geometry/lines-intersection.js.map +1 -1
  181. package/esm/util/group-by.js +1 -1
  182. package/esm/util/group-by.js.map +1 -1
  183. package/esm/util/group.js +3 -3
  184. package/esm/util/group.js.map +1 -1
  185. package/esm/util/html.js +1 -1
  186. package/esm/util/html.js.map +1 -1
  187. package/esm/util/if-show.js +5 -3
  188. package/esm/util/if-show.js.map +1 -1
  189. package/esm/util/in-range.js +3 -1
  190. package/esm/util/in-range.js.map +1 -1
  191. package/esm/util/interpolate.js +19 -12
  192. package/esm/util/interpolate.js.map +1 -1
  193. package/esm/util/keyframe-interpolate.d.ts +1 -1
  194. package/esm/util/keyframe-interpolate.js +7 -6
  195. package/esm/util/keyframe-interpolate.js.map +1 -1
  196. package/esm/util/layout/executer.js +4 -4
  197. package/esm/util/layout/executer.js.map +1 -1
  198. package/esm/util/layout/flex/index.js +26 -24
  199. package/esm/util/layout/flex/index.js.map +1 -1
  200. package/esm/util/layout/grid/index.js +1 -1
  201. package/esm/util/layout/grid/index.js.map +1 -1
  202. package/esm/util/layout/utils/helper.js +8 -7
  203. package/esm/util/layout/utils/helper.js.map +1 -1
  204. package/esm/util/matrix.js +8 -7
  205. package/esm/util/matrix.js.map +1 -1
  206. package/esm/util/number.js +7 -6
  207. package/esm/util/number.js.map +1 -1
  208. package/esm/util/offscreen.js +17 -9
  209. package/esm/util/offscreen.js.map +1 -1
  210. package/esm/util/omit.js +3 -3
  211. package/esm/util/omit.js.map +1 -1
  212. package/esm/util/path.js +41 -36
  213. package/esm/util/path.js.map +1 -1
  214. package/esm/util/primitive.js +3 -3
  215. package/esm/util/primitive.js.map +1 -1
  216. package/esm/util/replace-children.js +4 -3
  217. package/esm/util/replace-children.js.map +1 -1
  218. package/esm/util/sampling.js +3 -3
  219. package/esm/util/sampling.js.map +1 -1
  220. package/esm/util/scale-to-pixel.js +5 -4
  221. package/esm/util/scale-to-pixel.js.map +1 -1
  222. package/esm/util/selection.js +186 -142
  223. package/esm/util/selection.js.map +1 -1
  224. package/esm/util/series.js +1 -1
  225. package/esm/util/series.js.map +1 -1
  226. package/esm/util/shape.js +27 -15
  227. package/esm/util/shape.js.map +1 -1
  228. package/esm/util/string.js +5 -4
  229. package/esm/util/string.js.map +1 -1
  230. package/esm/util/style.js +29 -23
  231. package/esm/util/style.js.map +1 -1
  232. package/esm/util/svg2marker.js +16 -13
  233. package/esm/util/svg2marker.js.map +1 -1
  234. package/esm/util/text.js +14 -14
  235. package/esm/util/text.js.map +1 -1
  236. package/esm/util/throttle.js +13 -7
  237. package/esm/util/throttle.js.map +1 -1
  238. package/esm/util/time.js +24 -22
  239. package/esm/util/time.js.map +1 -1
  240. package/esm/util/timer.js +9 -5
  241. package/esm/util/timer.js.map +1 -1
  242. package/esm/util/transform.js +6 -5
  243. package/esm/util/transform.js.map +1 -1
  244. package/esm/util/transpose.js +1 -1
  245. package/esm/util/transpose.js.map +1 -1
  246. package/esm/util/traverse.js +1 -1
  247. package/esm/util/traverse.js.map +1 -1
  248. package/esm/util/visibility.js +2 -2
  249. package/esm/util/visibility.js.map +1 -1
  250. package/esm/util/wrap.js +4 -2
  251. package/esm/util/wrap.js.map +1 -1
  252. package/lib/animation/fadeIn.d.ts +1 -1
  253. package/lib/animation/fadeIn.js +1 -1
  254. package/lib/animation/fadeIn.js.map +1 -1
  255. package/lib/animation/fadeOut.d.ts +1 -1
  256. package/lib/animation/fadeOut.js +1 -1
  257. package/lib/animation/fadeOut.js.map +1 -1
  258. package/lib/animation/index.js +1 -1
  259. package/lib/animation/utils.d.ts +3 -3
  260. package/lib/animation/utils.js +39 -33
  261. package/lib/animation/utils.js.map +1 -1
  262. package/lib/core/component.js +43 -31
  263. package/lib/core/component.js.map +1 -1
  264. package/lib/core/index.js +1 -1
  265. package/lib/index.js +1 -1
  266. package/lib/shapes/Text.js +22 -15
  267. package/lib/shapes/Text.js.map +1 -1
  268. package/lib/shapes/index.js +1 -1
  269. package/lib/types/index.js +1 -1
  270. package/lib/ui/axis/axis.d.ts +1 -1
  271. package/lib/ui/axis/axis.js +39 -34
  272. package/lib/ui/axis/axis.js.map +1 -1
  273. package/lib/ui/axis/constant.js +12 -10
  274. package/lib/ui/axis/constant.js.map +1 -1
  275. package/lib/ui/axis/guides/grid.d.ts +1 -1
  276. package/lib/ui/axis/guides/grid.js +40 -35
  277. package/lib/ui/axis/guides/grid.js.map +1 -1
  278. package/lib/ui/axis/guides/labels.js +89 -82
  279. package/lib/ui/axis/guides/labels.js.map +1 -1
  280. package/lib/ui/axis/guides/line.js +92 -79
  281. package/lib/ui/axis/guides/line.js.map +1 -1
  282. package/lib/ui/axis/guides/ticks.d.ts +1 -1
  283. package/lib/ui/axis/guides/ticks.js +45 -37
  284. package/lib/ui/axis/guides/ticks.js.map +1 -1
  285. package/lib/ui/axis/guides/title.d.ts +1 -1
  286. package/lib/ui/axis/guides/title.js +41 -37
  287. package/lib/ui/axis/guides/title.js.map +1 -1
  288. package/lib/ui/axis/guides/utils.js +14 -12
  289. package/lib/ui/axis/guides/utils.js.map +1 -1
  290. package/lib/ui/axis/overlap/autoEllipsis.js +22 -15
  291. package/lib/ui/axis/overlap/autoEllipsis.js.map +1 -1
  292. package/lib/ui/axis/overlap/autoHide.js +27 -23
  293. package/lib/ui/axis/overlap/autoHide.js.map +1 -1
  294. package/lib/ui/axis/overlap/autoRotate.js +26 -12
  295. package/lib/ui/axis/overlap/autoRotate.js.map +1 -1
  296. package/lib/ui/axis/overlap/autoWrap.js +16 -13
  297. package/lib/ui/axis/overlap/autoWrap.js.map +1 -1
  298. package/lib/ui/axis/overlap/index.js +12 -12
  299. package/lib/ui/axis/overlap/index.js.map +1 -1
  300. package/lib/ui/axis/utils/bounds.js +75 -49
  301. package/lib/ui/axis/utils/bounds.js.map +1 -1
  302. package/lib/ui/axis/utils/contain.js +15 -15
  303. package/lib/ui/axis/utils/contain.js.map +1 -1
  304. package/lib/ui/axis/utils/index.js +8 -4
  305. package/lib/ui/axis/utils/index.js.map +1 -1
  306. package/lib/ui/axis/utils/intersect.js +34 -22
  307. package/lib/ui/axis/utils/intersect.js.map +1 -1
  308. package/lib/ui/axis/utils/test.js +47 -35
  309. package/lib/ui/axis/utils/test.js.map +1 -1
  310. package/lib/ui/breadcrumb/index.js +77 -70
  311. package/lib/ui/breadcrumb/index.js.map +1 -1
  312. package/lib/ui/button/index.js +101 -86
  313. package/lib/ui/button/index.js.map +1 -1
  314. package/lib/ui/checkbox/constant.js +2 -2
  315. package/lib/ui/checkbox/constant.js.map +1 -1
  316. package/lib/ui/checkbox/index.js +28 -26
  317. package/lib/ui/checkbox/index.js.map +1 -1
  318. package/lib/ui/crosshair/base.js +48 -33
  319. package/lib/ui/crosshair/base.js.map +1 -1
  320. package/lib/ui/crosshair/circle.js +37 -29
  321. package/lib/ui/crosshair/circle.js.map +1 -1
  322. package/lib/ui/crosshair/constant.js +1 -1
  323. package/lib/ui/crosshair/constant.js.map +1 -1
  324. package/lib/ui/crosshair/index.js +1 -1
  325. package/lib/ui/crosshair/line.js +77 -58
  326. package/lib/ui/crosshair/line.js.map +1 -1
  327. package/lib/ui/crosshair/polygon.js +72 -57
  328. package/lib/ui/crosshair/polygon.js.map +1 -1
  329. package/lib/ui/grid/index.d.ts +1 -1
  330. package/lib/ui/grid/index.js +97 -76
  331. package/lib/ui/grid/index.js.map +1 -1
  332. package/lib/ui/indicator/constant.js +1 -1
  333. package/lib/ui/indicator/constant.js.map +1 -1
  334. package/lib/ui/indicator/index.js +1 -1
  335. package/lib/ui/indicator/indicator.js +67 -63
  336. package/lib/ui/indicator/indicator.js.map +1 -1
  337. package/lib/ui/layout/layout.js +70 -57
  338. package/lib/ui/layout/layout.js.map +1 -1
  339. package/lib/ui/legend/base.js +15 -14
  340. package/lib/ui/legend/base.js.map +1 -1
  341. package/lib/ui/legend/category/item.js +159 -126
  342. package/lib/ui/legend/category/item.js.map +1 -1
  343. package/lib/ui/legend/category/items.js +208 -166
  344. package/lib/ui/legend/category/items.js.map +1 -1
  345. package/lib/ui/legend/category.js +60 -51
  346. package/lib/ui/legend/category.js.map +1 -1
  347. package/lib/ui/legend/constant.js +2 -2
  348. package/lib/ui/legend/constant.js.map +1 -1
  349. package/lib/ui/legend/continuous/handle.js +35 -31
  350. package/lib/ui/legend/continuous/handle.js.map +1 -1
  351. package/lib/ui/legend/continuous/ribbon.js +43 -40
  352. package/lib/ui/legend/continuous/ribbon.js.map +1 -1
  353. package/lib/ui/legend/continuous/utils.js +11 -10
  354. package/lib/ui/legend/continuous/utils.js.map +1 -1
  355. package/lib/ui/legend/continuous.js +535 -432
  356. package/lib/ui/legend/continuous.js.map +1 -1
  357. package/lib/ui/legend/index.js +2 -2
  358. package/lib/ui/legend/index.js.map +1 -1
  359. package/lib/ui/legend/utils.js +32 -25
  360. package/lib/ui/legend/utils.js.map +1 -1
  361. package/lib/ui/marker/index.js +48 -43
  362. package/lib/ui/marker/index.js.map +1 -1
  363. package/lib/ui/marker/symbol.js +22 -22
  364. package/lib/ui/marker/symbol.js.map +1 -1
  365. package/lib/ui/marker/utils.js +3 -3
  366. package/lib/ui/marker/utils.js.map +1 -1
  367. package/lib/ui/navigator/index.js +165 -135
  368. package/lib/ui/navigator/index.js.map +1 -1
  369. package/lib/ui/poptip/constant.d.ts +1 -1
  370. package/lib/ui/poptip/constant.js +67 -66
  371. package/lib/ui/poptip/constant.js.map +1 -1
  372. package/lib/ui/poptip/index.js +115 -100
  373. package/lib/ui/poptip/index.js.map +1 -1
  374. package/lib/ui/poptip/utils.js +15 -8
  375. package/lib/ui/poptip/utils.js.map +1 -1
  376. package/lib/ui/scrollbar/index.js +136 -107
  377. package/lib/ui/scrollbar/index.js.map +1 -1
  378. package/lib/ui/select/option.js +61 -52
  379. package/lib/ui/select/option.js.map +1 -1
  380. package/lib/ui/select/select.js +169 -148
  381. package/lib/ui/select/select.js.map +1 -1
  382. package/lib/ui/slider/constant.js +1 -1
  383. package/lib/ui/slider/constant.js.map +1 -1
  384. package/lib/ui/slider/handle.js +56 -49
  385. package/lib/ui/slider/handle.js.map +1 -1
  386. package/lib/ui/slider/index.js +336 -291
  387. package/lib/ui/slider/index.js.map +1 -1
  388. package/lib/ui/sparkline/columns.js +36 -28
  389. package/lib/ui/sparkline/columns.js.map +1 -1
  390. package/lib/ui/sparkline/index.js +187 -153
  391. package/lib/ui/sparkline/index.js.map +1 -1
  392. package/lib/ui/sparkline/lines.js +52 -40
  393. package/lib/ui/sparkline/lines.js.map +1 -1
  394. package/lib/ui/sparkline/path.js +42 -38
  395. package/lib/ui/sparkline/path.js.map +1 -1
  396. package/lib/ui/sparkline/utils.js +10 -9
  397. package/lib/ui/sparkline/utils.js.map +1 -1
  398. package/lib/ui/switch/index.js +58 -49
  399. package/lib/ui/switch/index.js.map +1 -1
  400. package/lib/ui/tag/index.js +36 -34
  401. package/lib/ui/tag/index.js.map +1 -1
  402. package/lib/ui/timebar/controller.js +82 -73
  403. package/lib/ui/timebar/controller.js.map +1 -1
  404. package/lib/ui/timebar/handle.js +74 -67
  405. package/lib/ui/timebar/handle.js.map +1 -1
  406. package/lib/ui/timebar/icons.js +466 -312
  407. package/lib/ui/timebar/icons.js.map +1 -1
  408. package/lib/ui/timebar/timebar.js +326 -272
  409. package/lib/ui/timebar/timebar.js.map +1 -1
  410. package/lib/ui/timebar/utils.js +8 -8
  411. package/lib/ui/timebar/utils.js.map +1 -1
  412. package/lib/ui/timeline/index.js +5 -2
  413. package/lib/ui/timeline/index.js.map +1 -1
  414. package/lib/ui/title/index.js +65 -61
  415. package/lib/ui/title/index.js.map +1 -1
  416. package/lib/ui/tooltip/constant.js +30 -26
  417. package/lib/ui/tooltip/constant.js.map +1 -1
  418. package/lib/ui/tooltip/index.js +129 -113
  419. package/lib/ui/tooltip/index.js.map +1 -1
  420. package/lib/util/bbox.js +46 -24
  421. package/lib/util/bbox.js.map +1 -1
  422. package/lib/util/callback.js +3 -2
  423. package/lib/util/callback.js.map +1 -1
  424. package/lib/util/classnames.js +10 -8
  425. package/lib/util/classnames.js.map +1 -1
  426. package/lib/util/deep-assign.js +15 -7
  427. package/lib/util/deep-assign.js.map +1 -1
  428. package/lib/util/defined.js +1 -1
  429. package/lib/util/defined.js.map +1 -1
  430. package/lib/util/ellipsis.js +3 -2
  431. package/lib/util/ellipsis.js.map +1 -1
  432. package/lib/util/event.js +3 -3
  433. package/lib/util/event.js.map +1 -1
  434. package/lib/util/extend-display-object.js +2 -2
  435. package/lib/util/extend-display-object.js.map +1 -1
  436. package/lib/util/geometry/index.js +1 -1
  437. package/lib/util/geometry/line-length.js +4 -1
  438. package/lib/util/geometry/line-length.js.map +1 -1
  439. package/lib/util/geometry/lines-intersection.js +10 -5
  440. package/lib/util/geometry/lines-intersection.js.map +1 -1
  441. package/lib/util/group-by.js +1 -1
  442. package/lib/util/group-by.js.map +1 -1
  443. package/lib/util/group.js +3 -3
  444. package/lib/util/group.js.map +1 -1
  445. package/lib/util/html.js +1 -1
  446. package/lib/util/html.js.map +1 -1
  447. package/lib/util/if-show.js +5 -3
  448. package/lib/util/if-show.js.map +1 -1
  449. package/lib/util/in-range.js +3 -1
  450. package/lib/util/in-range.js.map +1 -1
  451. package/lib/util/index.js +1 -1
  452. package/lib/util/interpolate.js +19 -12
  453. package/lib/util/interpolate.js.map +1 -1
  454. package/lib/util/keyframe-interpolate.d.ts +1 -1
  455. package/lib/util/keyframe-interpolate.js +8 -7
  456. package/lib/util/keyframe-interpolate.js.map +1 -1
  457. package/lib/util/layout/executer.js +6 -6
  458. package/lib/util/layout/executer.js.map +1 -1
  459. package/lib/util/layout/flex/index.js +28 -26
  460. package/lib/util/layout/flex/index.js.map +1 -1
  461. package/lib/util/layout/grid/index.js +1 -1
  462. package/lib/util/layout/grid/index.js.map +1 -1
  463. package/lib/util/layout/index.js +1 -1
  464. package/lib/util/layout/utils/helper.js +9 -8
  465. package/lib/util/layout/utils/helper.js.map +1 -1
  466. package/lib/util/matrix.js +8 -7
  467. package/lib/util/matrix.js.map +1 -1
  468. package/lib/util/number.js +7 -6
  469. package/lib/util/number.js.map +1 -1
  470. package/lib/util/offscreen.js +20 -12
  471. package/lib/util/offscreen.js.map +1 -1
  472. package/lib/util/omit.js +3 -3
  473. package/lib/util/omit.js.map +1 -1
  474. package/lib/util/path.js +42 -37
  475. package/lib/util/path.js.map +1 -1
  476. package/lib/util/primitive.js +2 -2
  477. package/lib/util/primitive.js.map +1 -1
  478. package/lib/util/replace-children.js +4 -3
  479. package/lib/util/replace-children.js.map +1 -1
  480. package/lib/util/sampling.js +3 -3
  481. package/lib/util/sampling.js.map +1 -1
  482. package/lib/util/scale-to-pixel.js +5 -4
  483. package/lib/util/scale-to-pixel.js.map +1 -1
  484. package/lib/util/selection.js +187 -144
  485. package/lib/util/selection.js.map +1 -1
  486. package/lib/util/series.js +2 -2
  487. package/lib/util/series.js.map +1 -1
  488. package/lib/util/shape.js +28 -16
  489. package/lib/util/shape.js.map +1 -1
  490. package/lib/util/string.js +5 -4
  491. package/lib/util/string.js.map +1 -1
  492. package/lib/util/style.js +30 -24
  493. package/lib/util/style.js.map +1 -1
  494. package/lib/util/svg2marker.js +17 -15
  495. package/lib/util/svg2marker.js.map +1 -1
  496. package/lib/util/text.js +16 -16
  497. package/lib/util/text.js.map +1 -1
  498. package/lib/util/throttle.js +13 -7
  499. package/lib/util/throttle.js.map +1 -1
  500. package/lib/util/time.js +24 -22
  501. package/lib/util/time.js.map +1 -1
  502. package/lib/util/timer.js +9 -5
  503. package/lib/util/timer.js.map +1 -1
  504. package/lib/util/transform.js +6 -5
  505. package/lib/util/transform.js.map +1 -1
  506. package/lib/util/transpose.js +1 -1
  507. package/lib/util/transpose.js.map +1 -1
  508. package/lib/util/traverse.js +1 -1
  509. package/lib/util/traverse.js.map +1 -1
  510. package/lib/util/visibility.js +3 -3
  511. package/lib/util/visibility.js.map +1 -1
  512. package/lib/util/wrap.js +5 -3
  513. package/lib/util/wrap.js.map +1 -1
  514. package/package.json +8 -8
  515. package/src/ui/poptip/constant.ts +1 -1
  516. package/src/ui/slider/index.ts +2 -3
@@ -1,3 +1,4 @@
1
+ import { __assign, __extends, __read, __spreadArray } from "tslib";
1
2
  import { CustomEvent } from '@antv/g';
2
3
  import { Linear } from '@antv/scale';
3
4
  import { clamp, isUndefined } from '@antv/util';
@@ -15,98 +16,108 @@ import { getNextTickValue } from './continuous/utils';
15
16
  import { getSafetySelections, getStepValueByValue, ifHorizontal } from './utils';
16
17
  function getMinMax(data) {
17
18
  return {
18
- min: Math.min(...data.map((d) => d.value)),
19
- max: Math.max(...data.map((d) => d.value)),
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)),
20
21
  };
21
22
  }
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;
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;
31
33
  e.stopPropagation();
32
- const value = this.getValueByCanvasPoint(e);
34
+ var value = _this.getValueByCanvasPoint(e);
33
35
  if (block) {
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);
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);
38
43
  }
39
44
  else {
40
- const safetyValue = this.getTickValue(value);
41
- this.showIndicator(safetyValue, `${this.getRealValue(safetyValue)}`);
42
- this.dispatchIndicated(safetyValue);
45
+ var safetyValue = _this.getTickValue(value);
46
+ _this.showIndicator(safetyValue, "".concat(_this.getRealValue(safetyValue)));
47
+ _this.dispatchIndicated(safetyValue);
43
48
  }
44
49
  };
45
- this.onDragStart = (target) => (e) => {
50
+ _this.onDragStart = function (target) { return function (e) {
46
51
  e.stopPropagation();
47
52
  // 关闭滑动
48
- if (!this.attributes.slidable)
53
+ if (!_this.attributes.slidable)
49
54
  return;
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;
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;
65
70
  if (target === 'start')
66
- start !== currValue && this.updateSelection(currValue, end);
71
+ start !== currValue && _this.updateSelection(currValue, end);
67
72
  else if (target === 'end')
68
- end !== currValue && this.updateSelection(start, currValue);
73
+ end !== currValue && _this.updateSelection(start, currValue);
69
74
  else if (target === 'ribbon' && diffValue !== 0) {
70
- this.prevValue = currValue;
71
- this.updateSelection(diffValue, diffValue, true);
75
+ _this.prevValue = currValue;
76
+ _this.updateSelection(diffValue, diffValue, true);
72
77
  }
73
78
  };
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);
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);
80
85
  };
81
- }
82
- get handleOffsetRatio() {
83
- return this.ifHorizontal(0.5, 0.5);
84
- }
85
- getBBox() {
86
- const { width, height } = this.attributes;
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;
87
97
  return new BBox(0, 0, width, height);
88
- }
89
- render(attributes, container) {
98
+ };
99
+ Continuous.prototype.render = function (attributes, container) {
100
+ var _this = this;
90
101
  // 渲染顺序
91
102
  // 1. 绘制 title, 获得可用空间
92
103
  // 2. 绘制 label, handle
93
104
  // 3. 基于可用空间、label高度、handle 宽高,计算 ribbon 宽高
94
105
  // 4. 绘制 ribbon
95
106
  // 5. 调整 label、handle 位置
96
- const { showLabel } = attributes;
107
+ var showLabel = attributes.showLabel;
97
108
  /** title */
98
109
  this.renderTitle(select(container));
99
- const { x, y } = this.availableSpace;
110
+ var _a = this.availableSpace, x = _a.x, y = _a.y;
100
111
  /** label */
101
112
  /** content */
102
- const contentGroup = select(container)
113
+ var contentGroup = select(container)
103
114
  .maybeAppendByClassName(CLASS_NAMES.contentGroup, 'g')
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);
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);
108
119
  });
109
- const ribbonGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.ribbonGroup, 'g').styles({ zIndex: 0 });
120
+ var ribbonGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.ribbonGroup, 'g').styles({ zIndex: 0 });
110
121
  /** handle */
111
122
  this.handlesGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.handlesGroup, 'g').styles({ zIndex: 2 });
112
123
  this.renderHandles();
@@ -117,153 +128,201 @@ export class Continuous extends Component {
117
128
  this.adjustLabel();
118
129
  this.adjustHandles();
119
130
  // this.adjustTitle();
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) {
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) {
144
171
  return ifHorizontal(this.attributes.orientation, typeof a === 'function' ? a() : a, typeof b === 'function' ? b() : b);
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;
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;
151
178
  container
152
179
  .selectAll(CLASS_NAMES.title.class)
153
180
  .data(showTitle ? [titleText] : [])
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)
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);
189
236
  return this.cacheLabelBBox;
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)),
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); }),
251
310
  range: this.ribbonRange,
252
311
  }, ribbonStyle);
253
- this.ribbon = container.maybeAppendByClassName(CLASS_NAMES.ribbon, () => new Ribbon({ style })).update(style);
254
- }
255
- getHandleClassName(type) {
312
+ this.ribbon = container.maybeAppendByClassName(CLASS_NAMES.ribbon, function () { return new Ribbon({ style: style }); }).update(style);
313
+ };
314
+ Continuous.prototype.getHandleClassName = function (type) {
256
315
  // @ts-ignore
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;
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;
267
326
  this.handlesGroup
268
327
  .selectAll(CLASS_NAMES.handle.class)
269
328
  .data(showHandle
@@ -271,202 +330,234 @@ export class Continuous extends Component {
271
330
  { value: min, type: 'start' },
272
331
  { value: max, type: 'end' },
273
332
  ]
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;
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];
294
365
  this.setHandlePosition('start', min);
295
366
  this.setHandlePosition('end', max);
296
- }
297
- get handleBBox() {
298
- if (this.cacheHandleBBox)
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);
299
378
  return this.cacheHandleBBox;
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);
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);
328
407
  // this.hideIndicator();
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) => {
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) {
371
457
  if ((datum === null || datum === void 0 ? void 0 : datum.type) !== 'value')
372
458
  return false;
373
459
  if (labelFilter)
374
- return labelFilter(datum, datum.index, data.filter((d) => d.type !== 'value'));
460
+ return labelFilter(datum, datum.index, data.filter(function (d) { return d.type !== 'value'; }));
375
461
  return true;
376
462
  },
377
- labelFilter: (datum, index, data) => {
463
+ labelFilter: function (datum, index, data) {
378
464
  if ((datum === null || datum === void 0 ? void 0 : datum.type) !== align)
379
465
  return false;
380
466
  if (labelFilter)
381
- return labelFilter(datum, datum.index, data.filter((d) => d.type === align));
467
+ return labelFilter(datum, datum.index, data.filter(function (d) { return d.type === align; }));
382
468
  return true;
383
469
  },
384
- labelFormatter,
470
+ labelFormatter: labelFormatter,
385
471
  };
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();
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();
388
474
  this.label.update(finalLabelStyle, false);
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;
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;
405
501
  }
406
- else if (labelPosition === 'bottom')
407
- offset = tickLength;
408
502
  }
409
- else if (labelDirection === 'negative') {
410
- if (labelPosition === 'top')
411
- offset = ribbonSize;
412
- else if (labelPosition === 'left')
413
- offset = ribbonSize;
503
+ else if (labelDirection === 'positive') {
504
+ if (labelPosition === 'right')
505
+ spacing = internalVal;
506
+ else if (labelPosition === 'bottom') {
507
+ offset = ribbonSize + labelFixedSpacing;
508
+ spacing = labelSpacing;
509
+ }
414
510
  }
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;
511
+ else if (labelDirection === 'negative') {
512
+ if (labelPosition === 'left')
513
+ spacing = labelSpacing;
514
+ else if (labelPosition === 'top')
515
+ spacing = labelSpacing;
422
516
  }
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;
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;
434
524
  if (!showLabel)
435
525
  return;
436
- const { x, y, width, height } = this.ribbonBBox;
437
- const { offset: axisOffset, spacing: axisSpacing, tickLength: axisTickLength } = this.labelAxisStyle;
438
- const [startPos, endPos] = this.ifHorizontal([
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([
439
529
  [x, y + axisOffset],
440
530
  [x + width, y + axisOffset],
441
531
  ], [
442
532
  [x + axisOffset, y + height],
443
533
  [x + axisOffset, y],
444
- ]);
534
+ ]), 2), startPos = _c[0], endPos = _c[1];
445
535
  this.label.update({
446
- startPos,
447
- endPos,
536
+ startPos: startPos,
537
+ endPos: endPos,
448
538
  tickLength: axisTickLength,
449
539
  labelSpacing: axisSpacing,
450
540
  }, false);
451
- }
452
- bindEvents() {
541
+ };
542
+ Continuous.prototype.bindEvents = function () {
453
543
  this.style.cursor = 'pointer';
454
544
  // 绑定 drag 开始事件
455
545
  this.ribbon.on('pointerdown', this.onDragStart('ribbon'));
456
546
  this.ribbon.on('pointermove', this.onHovering);
457
547
  this.addEventListener('pointerout', this.hideIndicator);
458
- }
459
- showIndicator(value, text = `${value}`) {
460
- const { showIndicator } = this.attributes;
548
+ };
549
+ Continuous.prototype.showIndicator = function (value, text) {
550
+ if (text === void 0) { text = "".concat(value); }
551
+ var showIndicator = this.attributes.showIndicator;
461
552
  if (!showIndicator || typeof value !== 'number') {
462
553
  this.hideIndicator();
463
554
  return;
464
555
  }
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]);
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]);
470
561
  this.indicator.update({
471
562
  x: pos[0],
472
563
  y: pos[1],
@@ -474,102 +565,115 @@ export class Continuous extends Component {
474
565
  labelText: text,
475
566
  });
476
567
  show(this.indicator.node());
477
- }
478
- hideIndicator() {
568
+ };
569
+ Continuous.prototype.hideIndicator = function () {
479
570
  hide(this.indicator.node());
480
- }
481
- updateMouse() {
571
+ };
572
+ Continuous.prototype.updateMouse = function () {
482
573
  if (this.attributes.slidable)
483
574
  this.style.cursor = 'grabbing';
484
- }
485
- setSelection(start, end) {
575
+ };
576
+ Continuous.prototype.setSelection = function (start, end) {
486
577
  this.updateSelection(start, end);
487
- }
488
- updateSelection(stVal, endVal, isOffset = false) {
489
- const [currSt, currEnd] = this.selection;
490
- let [start, end] = [stVal, endVal];
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];
491
584
  if (isOffset) {
492
585
  // 获取当前值
493
586
  start += currSt;
494
587
  end += currEnd;
495
588
  }
496
589
  // 值校验
497
- const { min, max } = this.range;
498
- [start, end] = getSafetySelections([min, max], [start, end], this.selection);
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];
499
592
  this.update({ defaultValue: [start, end] });
500
593
  this.dispatchSelection();
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;
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;
512
609
  if (block)
513
- return getNextTickValue(data.map(({ value }) => value), value).tick;
610
+ return getNextTickValue(data.map(function (_a) {
611
+ var value = _a.value;
612
+ return value;
613
+ }), value).tick;
514
614
  return getStepValueByValue(value, this.step, min);
515
- }
615
+ };
516
616
  /**
517
617
  * 事件触发的位置对应的value值
518
618
  */
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);
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);
526
626
  return value;
527
- }
627
+ };
528
628
  /** reverse: 屏幕偏移量 -> 值 */
529
- getOffset(value, reverse = false) {
530
- const { min, max } = this.range;
531
- const { length: ribbonLen } = this.ribbonShape;
532
- const scale = this.eventToOffsetScale;
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;
533
634
  scale.update({ domain: [min, max], range: [0, ribbonLen] });
534
635
  if (reverse)
535
636
  return scale.invert(value);
536
637
  return scale.map(value);
537
- }
538
- getRealSelection(range) {
539
- const { max } = this.range;
540
- const [start, end] = range;
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];
541
642
  return this.ifHorizontal([start, end], [max - end, max - start]);
542
- }
543
- getRealValue(value) {
544
- const { max } = this.range;
643
+ };
644
+ Continuous.prototype.getRealValue = function (value) {
645
+ var max = this.range.max;
545
646
  return this.ifHorizontal(value, max - value);
546
- }
547
- dispatchSelection() {
548
- const selection = this.getRealSelection(this.selection);
549
- const evt = new CustomEvent('valuechange', {
647
+ };
648
+ Continuous.prototype.dispatchSelection = function () {
649
+ var selection = this.getRealSelection(this.selection);
650
+ var evt = new CustomEvent('valuechange', {
550
651
  detail: {
551
652
  value: selection,
552
653
  },
553
654
  });
554
655
  this.dispatchEvent(evt);
555
- }
556
- dispatchIndicated(value, range) {
557
- const { max } = this.range;
558
- const detail = this.ifHorizontal(() => {
656
+ };
657
+ Continuous.prototype.dispatchIndicated = function (value, range) {
658
+ var _this = this;
659
+ var max = this.range.max;
660
+ var detail = this.ifHorizontal(function () {
559
661
  return {
560
- value,
561
- range,
662
+ value: value,
663
+ range: range,
562
664
  };
563
- }, () => {
665
+ }, function () {
564
666
  return {
565
667
  value: max - value,
566
- range: range ? this.getRealSelection(range) : undefined,
668
+ range: range ? _this.getRealSelection(range) : undefined,
567
669
  };
568
670
  });
569
- const evt = new CustomEvent('indicate', {
570
- detail,
671
+ var evt = new CustomEvent('indicate', {
672
+ detail: detail,
571
673
  });
572
674
  this.dispatchEvent(evt);
573
- }
574
- }
675
+ };
676
+ return Continuous;
677
+ }(Component));
678
+ export { Continuous };
575
679
  //# sourceMappingURL=continuous.js.map