@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,115 +1,126 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Continuous = void 0;
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");
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");
19
20
  function getMinMax(data) {
20
21
  return {
21
- min: Math.min(...data.map((d) => d.value)),
22
- max: Math.max(...data.map((d) => d.value)),
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)),
23
24
  };
24
25
  }
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;
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;
34
36
  e.stopPropagation();
35
- const value = this.getValueByCanvasPoint(e);
37
+ var value = _this.getValueByCanvasPoint(e);
36
38
  if (block) {
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);
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);
41
46
  }
42
47
  else {
43
- const safetyValue = this.getTickValue(value);
44
- this.showIndicator(safetyValue, `${this.getRealValue(safetyValue)}`);
45
- this.dispatchIndicated(safetyValue);
48
+ var safetyValue = _this.getTickValue(value);
49
+ _this.showIndicator(safetyValue, "".concat(_this.getRealValue(safetyValue)));
50
+ _this.dispatchIndicated(safetyValue);
46
51
  }
47
52
  };
48
- this.onDragStart = (target) => (e) => {
53
+ _this.onDragStart = function (target) { return function (e) {
49
54
  e.stopPropagation();
50
55
  // 关闭滑动
51
- if (!this.attributes.slidable)
56
+ if (!_this.attributes.slidable)
52
57
  return;
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;
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;
68
73
  if (target === 'start')
69
- start !== currValue && this.updateSelection(currValue, end);
74
+ start !== currValue && _this.updateSelection(currValue, end);
70
75
  else if (target === 'end')
71
- end !== currValue && this.updateSelection(start, currValue);
76
+ end !== currValue && _this.updateSelection(start, currValue);
72
77
  else if (target === 'ribbon' && diffValue !== 0) {
73
- this.prevValue = currValue;
74
- this.updateSelection(diffValue, diffValue, true);
78
+ _this.prevValue = currValue;
79
+ _this.updateSelection(diffValue, diffValue, true);
75
80
  }
76
81
  };
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);
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);
83
88
  };
84
- }
85
- get handleOffsetRatio() {
86
- return this.ifHorizontal(0.5, 0.5);
87
- }
88
- getBBox() {
89
- const { width, height } = this.attributes;
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;
90
100
  return new util_2.BBox(0, 0, width, height);
91
- }
92
- render(attributes, container) {
101
+ };
102
+ Continuous.prototype.render = function (attributes, container) {
103
+ var _this = this;
93
104
  // 渲染顺序
94
105
  // 1. 绘制 title, 获得可用空间
95
106
  // 2. 绘制 label, handle
96
107
  // 3. 基于可用空间、label高度、handle 宽高,计算 ribbon 宽高
97
108
  // 4. 绘制 ribbon
98
109
  // 5. 调整 label、handle 位置
99
- const { showLabel } = attributes;
110
+ var showLabel = attributes.showLabel;
100
111
  /** title */
101
112
  this.renderTitle((0, util_2.select)(container));
102
- const { x, y } = this.availableSpace;
113
+ var _a = this.availableSpace, x = _a.x, y = _a.y;
103
114
  /** label */
104
115
  /** content */
105
- const contentGroup = (0, util_2.select)(container)
116
+ var contentGroup = (0, util_2.select)(container)
106
117
  .maybeAppendByClassName(constant_2.CLASS_NAMES.contentGroup, 'g')
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);
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);
111
122
  });
112
- const ribbonGroup = contentGroup.maybeAppendByClassName(constant_2.CLASS_NAMES.ribbonGroup, 'g').styles({ zIndex: 0 });
123
+ var ribbonGroup = contentGroup.maybeAppendByClassName(constant_2.CLASS_NAMES.ribbonGroup, 'g').styles({ zIndex: 0 });
113
124
  /** handle */
114
125
  this.handlesGroup = contentGroup.maybeAppendByClassName(constant_2.CLASS_NAMES.handlesGroup, 'g').styles({ zIndex: 2 });
115
126
  this.renderHandles();
@@ -120,153 +131,201 @@ class Continuous extends core_1.Component {
120
131
  this.adjustLabel();
121
132
  this.adjustHandles();
122
133
  // this.adjustTitle();
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) {
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) {
147
174
  return (0, utils_2.ifHorizontal)(this.attributes.orientation, typeof a === 'function' ? a() : a, typeof b === 'function' ? b() : b);
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;
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;
154
181
  container
155
182
  .selectAll(constant_2.CLASS_NAMES.title.class)
156
183
  .data(showTitle ? [titleText] : [])
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)
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);
192
239
  return this.cacheLabelBBox;
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)),
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); }),
254
313
  range: this.ribbonRange,
255
314
  }, ribbonStyle);
256
- this.ribbon = container.maybeAppendByClassName(constant_2.CLASS_NAMES.ribbon, () => new ribbon_1.Ribbon({ style })).update(style);
257
- }
258
- getHandleClassName(type) {
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) {
259
318
  // @ts-ignore
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;
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;
270
329
  this.handlesGroup
271
330
  .selectAll(constant_2.CLASS_NAMES.handle.class)
272
331
  .data(showHandle
@@ -274,202 +333,234 @@ class Continuous extends core_1.Component {
274
333
  { value: min, type: 'start' },
275
334
  { value: max, type: 'end' },
276
335
  ]
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;
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];
297
368
  this.setHandlePosition('start', min);
298
369
  this.setHandlePosition('end', max);
299
- }
300
- get handleBBox() {
301
- if (this.cacheHandleBBox)
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);
302
381
  return this.cacheHandleBBox;
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);
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);
331
410
  // this.hideIndicator();
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) => {
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) {
374
460
  if ((datum === null || datum === void 0 ? void 0 : datum.type) !== 'value')
375
461
  return false;
376
462
  if (labelFilter)
377
- return labelFilter(datum, datum.index, data.filter((d) => d.type !== 'value'));
463
+ return labelFilter(datum, datum.index, data.filter(function (d) { return d.type !== 'value'; }));
378
464
  return true;
379
465
  },
380
- labelFilter: (datum, index, data) => {
466
+ labelFilter: function (datum, index, data) {
381
467
  if ((datum === null || datum === void 0 ? void 0 : datum.type) !== align)
382
468
  return false;
383
469
  if (labelFilter)
384
- return labelFilter(datum, datum.index, data.filter((d) => d.type === align));
470
+ return labelFilter(datum, datum.index, data.filter(function (d) { return d.type === align; }));
385
471
  return true;
386
472
  },
387
- labelFormatter,
473
+ labelFormatter: labelFormatter,
388
474
  };
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();
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();
391
477
  this.label.update(finalLabelStyle, false);
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;
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;
408
504
  }
409
- else if (labelPosition === 'bottom')
410
- offset = tickLength;
411
505
  }
412
- else if (labelDirection === 'negative') {
413
- if (labelPosition === 'top')
414
- offset = ribbonSize;
415
- else if (labelPosition === 'left')
416
- offset = ribbonSize;
506
+ else if (labelDirection === 'positive') {
507
+ if (labelPosition === 'right')
508
+ spacing = internalVal;
509
+ else if (labelPosition === 'bottom') {
510
+ offset = ribbonSize + labelFixedSpacing;
511
+ spacing = labelSpacing;
512
+ }
417
513
  }
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;
514
+ else if (labelDirection === 'negative') {
515
+ if (labelPosition === 'left')
516
+ spacing = labelSpacing;
517
+ else if (labelPosition === 'top')
518
+ spacing = labelSpacing;
425
519
  }
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;
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;
437
527
  if (!showLabel)
438
528
  return;
439
- const { x, y, width, height } = this.ribbonBBox;
440
- const { offset: axisOffset, spacing: axisSpacing, tickLength: axisTickLength } = this.labelAxisStyle;
441
- const [startPos, endPos] = this.ifHorizontal([
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([
442
532
  [x, y + axisOffset],
443
533
  [x + width, y + axisOffset],
444
534
  ], [
445
535
  [x + axisOffset, y + height],
446
536
  [x + axisOffset, y],
447
- ]);
537
+ ]), 2), startPos = _c[0], endPos = _c[1];
448
538
  this.label.update({
449
- startPos,
450
- endPos,
539
+ startPos: startPos,
540
+ endPos: endPos,
451
541
  tickLength: axisTickLength,
452
542
  labelSpacing: axisSpacing,
453
543
  }, false);
454
- }
455
- bindEvents() {
544
+ };
545
+ Continuous.prototype.bindEvents = function () {
456
546
  this.style.cursor = 'pointer';
457
547
  // 绑定 drag 开始事件
458
548
  this.ribbon.on('pointerdown', this.onDragStart('ribbon'));
459
549
  this.ribbon.on('pointermove', this.onHovering);
460
550
  this.addEventListener('pointerout', this.hideIndicator);
461
- }
462
- showIndicator(value, text = `${value}`) {
463
- const { showIndicator } = this.attributes;
551
+ };
552
+ Continuous.prototype.showIndicator = function (value, text) {
553
+ if (text === void 0) { text = "".concat(value); }
554
+ var showIndicator = this.attributes.showIndicator;
464
555
  if (!showIndicator || typeof value !== 'number') {
465
556
  this.hideIndicator();
466
557
  return;
467
558
  }
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]);
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]);
473
564
  this.indicator.update({
474
565
  x: pos[0],
475
566
  y: pos[1],
@@ -477,103 +568,115 @@ class Continuous extends core_1.Component {
477
568
  labelText: text,
478
569
  });
479
570
  (0, util_2.show)(this.indicator.node());
480
- }
481
- hideIndicator() {
571
+ };
572
+ Continuous.prototype.hideIndicator = function () {
482
573
  (0, util_2.hide)(this.indicator.node());
483
- }
484
- updateMouse() {
574
+ };
575
+ Continuous.prototype.updateMouse = function () {
485
576
  if (this.attributes.slidable)
486
577
  this.style.cursor = 'grabbing';
487
- }
488
- setSelection(start, end) {
578
+ };
579
+ Continuous.prototype.setSelection = function (start, end) {
489
580
  this.updateSelection(start, end);
490
- }
491
- updateSelection(stVal, endVal, isOffset = false) {
492
- const [currSt, currEnd] = this.selection;
493
- let [start, end] = [stVal, endVal];
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];
494
587
  if (isOffset) {
495
588
  // 获取当前值
496
589
  start += currSt;
497
590
  end += currEnd;
498
591
  }
499
592
  // 值校验
500
- const { min, max } = this.range;
501
- [start, end] = (0, utils_2.getSafetySelections)([min, max], [start, end], this.selection);
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];
502
595
  this.update({ defaultValue: [start, end] });
503
596
  this.dispatchSelection();
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;
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;
515
612
  if (block)
516
- return (0, utils_1.getNextTickValue)(data.map(({ value }) => value), value).tick;
613
+ return (0, utils_1.getNextTickValue)(data.map(function (_a) {
614
+ var value = _a.value;
615
+ return value;
616
+ }), value).tick;
517
617
  return (0, utils_2.getStepValueByValue)(value, this.step, min);
518
- }
618
+ };
519
619
  /**
520
620
  * 事件触发的位置对应的value值
521
621
  */
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);
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);
529
629
  return value;
530
- }
630
+ };
531
631
  /** reverse: 屏幕偏移量 -> 值 */
532
- getOffset(value, reverse = false) {
533
- const { min, max } = this.range;
534
- const { length: ribbonLen } = this.ribbonShape;
535
- const scale = this.eventToOffsetScale;
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;
536
637
  scale.update({ domain: [min, max], range: [0, ribbonLen] });
537
638
  if (reverse)
538
639
  return scale.invert(value);
539
640
  return scale.map(value);
540
- }
541
- getRealSelection(range) {
542
- const { max } = this.range;
543
- const [start, end] = range;
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];
544
645
  return this.ifHorizontal([start, end], [max - end, max - start]);
545
- }
546
- getRealValue(value) {
547
- const { max } = this.range;
646
+ };
647
+ Continuous.prototype.getRealValue = function (value) {
648
+ var max = this.range.max;
548
649
  return this.ifHorizontal(value, max - value);
549
- }
550
- dispatchSelection() {
551
- const selection = this.getRealSelection(this.selection);
552
- const evt = new g_1.CustomEvent('valuechange', {
650
+ };
651
+ Continuous.prototype.dispatchSelection = function () {
652
+ var selection = this.getRealSelection(this.selection);
653
+ var evt = new g_1.CustomEvent('valuechange', {
553
654
  detail: {
554
655
  value: selection,
555
656
  },
556
657
  });
557
658
  this.dispatchEvent(evt);
558
- }
559
- dispatchIndicated(value, range) {
560
- const { max } = this.range;
561
- const detail = this.ifHorizontal(() => {
659
+ };
660
+ Continuous.prototype.dispatchIndicated = function (value, range) {
661
+ var _this = this;
662
+ var max = this.range.max;
663
+ var detail = this.ifHorizontal(function () {
562
664
  return {
563
- value,
564
- range,
665
+ value: value,
666
+ range: range,
565
667
  };
566
- }, () => {
668
+ }, function () {
567
669
  return {
568
670
  value: max - value,
569
- range: range ? this.getRealSelection(range) : undefined,
671
+ range: range ? _this.getRealSelection(range) : undefined,
570
672
  };
571
673
  });
572
- const evt = new g_1.CustomEvent('indicate', {
573
- detail,
674
+ var evt = new g_1.CustomEvent('indicate', {
675
+ detail: detail,
574
676
  });
575
677
  this.dispatchEvent(evt);
576
- }
577
- }
678
+ };
679
+ return Continuous;
680
+ }(core_1.Component));
578
681
  exports.Continuous = Continuous;
579
682
  //# sourceMappingURL=continuous.js.map