@antv/g2 5.0.0-beta.3 → 5.0.0-beta.5

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 (459) hide show
  1. package/dist/g2-lite.min.js +5 -2
  2. package/dist/g2.min.js +5 -2
  3. package/esm/api/mark/mark.js +1 -2
  4. package/esm/api/mark/mark.js.map +1 -1
  5. package/esm/api/mark/types.d.ts +1 -2
  6. package/esm/component/axis.js +46 -24
  7. package/esm/component/axis.js.map +1 -1
  8. package/esm/component/index.d.ts +4 -0
  9. package/esm/component/index.js +2 -0
  10. package/esm/component/index.js.map +1 -1
  11. package/esm/component/legendCategory.js +1 -0
  12. package/esm/component/legendCategory.js.map +1 -1
  13. package/esm/component/slider.d.ts +9 -0
  14. package/esm/component/slider.js +57 -0
  15. package/esm/component/slider.js.map +1 -0
  16. package/esm/component/sliderX.d.ts +7 -0
  17. package/esm/component/sliderX.js +9 -0
  18. package/esm/component/sliderX.js.map +1 -0
  19. package/esm/component/sliderY.d.ts +7 -0
  20. package/esm/component/sliderY.js +9 -0
  21. package/esm/component/sliderY.js.map +1 -0
  22. package/esm/composition/facetRect.js +4 -4
  23. package/esm/composition/facetRect.js.map +1 -1
  24. package/esm/composition/mark.js +3 -1
  25. package/esm/composition/mark.js.map +1 -1
  26. package/esm/composition/repeatMatrix.js +2 -2
  27. package/esm/composition/repeatMatrix.js.map +1 -1
  28. package/esm/data/filter.d.ts +3 -3
  29. package/esm/data/filter.js.map +1 -1
  30. package/esm/data/index.d.ts +3 -1
  31. package/esm/data/index.js +1 -0
  32. package/esm/data/index.js.map +1 -1
  33. package/esm/data/sort.d.ts +8 -0
  34. package/esm/data/sort.js +12 -0
  35. package/esm/data/sort.js.map +1 -0
  36. package/esm/interaction/builtin/brushHighlight.d.ts +1 -1
  37. package/esm/interaction/builtin/tooltip.d.ts +6 -4
  38. package/esm/interaction/index.d.ts +5 -0
  39. package/esm/interaction/index.js +5 -0
  40. package/esm/interaction/index.js.map +1 -1
  41. package/esm/interaction/native/brushHighlight.d.ts +15 -0
  42. package/esm/interaction/native/brushHighlight.js +283 -0
  43. package/esm/interaction/native/brushHighlight.js.map +1 -0
  44. package/esm/interaction/native/brushXHighlight.d.ts +1 -0
  45. package/esm/interaction/native/brushXHighlight.js +8 -0
  46. package/esm/interaction/native/brushXHighlight.js.map +1 -0
  47. package/esm/interaction/native/brushYHighlight.d.ts +1 -0
  48. package/esm/interaction/native/brushYHighlight.js +8 -0
  49. package/esm/interaction/native/brushYHighlight.js.map +1 -0
  50. package/esm/interaction/native/legendFilter.d.ts +8 -0
  51. package/esm/interaction/native/legendFilter.js +180 -0
  52. package/esm/interaction/native/legendFilter.js.map +1 -0
  53. package/esm/interaction/native/tooltip.d.ts +2 -2
  54. package/esm/interaction/native/tooltip.js +134 -44
  55. package/esm/interaction/native/tooltip.js.map +1 -1
  56. package/esm/interaction/native/utils.d.ts +5 -1
  57. package/esm/interaction/native/utils.js +25 -2
  58. package/esm/interaction/native/utils.js.map +1 -1
  59. package/esm/label-transform/contrastReverse.d.ts +9 -0
  60. package/esm/label-transform/contrastReverse.js +48 -0
  61. package/esm/label-transform/contrastReverse.js.map +1 -0
  62. package/esm/label-transform/index.d.ts +8 -8
  63. package/esm/label-transform/index.js +4 -4
  64. package/esm/label-transform/index.js.map +1 -1
  65. package/esm/label-transform/overflowHide.d.ts +7 -0
  66. package/esm/label-transform/overflowHide.js +18 -0
  67. package/esm/label-transform/overflowHide.js.map +1 -0
  68. package/esm/label-transform/overlapDodgeY.d.ts +7 -0
  69. package/esm/label-transform/{dodgeY.js → overlapDodgeY.js} +4 -4
  70. package/esm/label-transform/overlapDodgeY.js.map +1 -0
  71. package/esm/label-transform/overlapHide.d.ts +7 -0
  72. package/esm/label-transform/overlapHide.js +24 -0
  73. package/esm/label-transform/overlapHide.js.map +1 -0
  74. package/esm/mark/area.js +1 -1
  75. package/esm/mark/area.js.map +1 -1
  76. package/esm/mark/line.js +1 -1
  77. package/esm/mark/line.js.map +1 -1
  78. package/esm/runtime/component.js +29 -1
  79. package/esm/runtime/component.js.map +1 -1
  80. package/esm/runtime/plot.js +38 -13
  81. package/esm/runtime/plot.js.map +1 -1
  82. package/esm/runtime/scale.js +17 -5
  83. package/esm/runtime/scale.js.map +1 -1
  84. package/esm/runtime/transform.js +10 -4
  85. package/esm/runtime/transform.js.map +1 -1
  86. package/esm/runtime/types/common.d.ts +1 -0
  87. package/esm/runtime/types/mark.d.ts +1 -1
  88. package/esm/runtime/types/options.d.ts +2 -0
  89. package/esm/runtime/types/theme.d.ts +5 -0
  90. package/esm/shape/label/label.js +3 -3
  91. package/esm/shape/label/label.js.map +1 -1
  92. package/esm/shape/label/position/area.d.ts +13 -0
  93. package/esm/shape/label/position/area.js +28 -0
  94. package/esm/shape/label/position/area.js.map +1 -0
  95. package/esm/shape/label/position/bottom.d.ts +1 -0
  96. package/esm/shape/label/position/bottom.js +2 -0
  97. package/esm/shape/label/position/bottom.js.map +1 -0
  98. package/esm/shape/label/position/bottomLeft.d.ts +1 -0
  99. package/esm/shape/label/position/bottomLeft.js +2 -0
  100. package/esm/shape/label/position/bottomLeft.js.map +1 -0
  101. package/esm/shape/label/position/bottomRight.d.ts +1 -0
  102. package/esm/shape/label/position/bottomRight.js +2 -0
  103. package/esm/shape/label/position/bottomRight.js.map +1 -0
  104. package/esm/shape/label/position/default.d.ts +20 -0
  105. package/esm/shape/label/{position.js → position/default.js} +9 -45
  106. package/esm/shape/label/position/default.js.map +1 -0
  107. package/esm/shape/label/position/index.d.ts +13 -0
  108. package/esm/shape/label/position/index.js +14 -0
  109. package/esm/shape/label/position/index.js.map +1 -0
  110. package/esm/shape/label/position/inside.d.ts +1 -0
  111. package/esm/shape/label/position/inside.js +2 -0
  112. package/esm/shape/label/position/inside.js.map +1 -0
  113. package/esm/shape/label/position/left.d.ts +1 -0
  114. package/esm/shape/label/position/left.js +2 -0
  115. package/esm/shape/label/position/left.js.map +1 -0
  116. package/esm/shape/label/position/outside.d.ts +1 -0
  117. package/esm/shape/label/position/outside.js +2 -0
  118. package/esm/shape/label/position/outside.js.map +1 -0
  119. package/esm/shape/label/position/right.d.ts +1 -0
  120. package/esm/shape/label/position/right.js +2 -0
  121. package/esm/shape/label/position/right.js.map +1 -0
  122. package/esm/shape/label/position/spider.d.ts +7 -0
  123. package/esm/shape/label/position/spider.js +40 -0
  124. package/esm/shape/label/position/spider.js.map +1 -0
  125. package/esm/shape/label/position/surround.d.ts +7 -0
  126. package/esm/shape/label/position/surround.js +37 -0
  127. package/esm/shape/label/position/surround.js.map +1 -0
  128. package/esm/shape/label/position/top.d.ts +1 -0
  129. package/esm/shape/label/position/top.js +2 -0
  130. package/esm/shape/label/position/top.js.map +1 -0
  131. package/esm/shape/label/position/topLeft.d.ts +1 -0
  132. package/esm/shape/label/position/topLeft.js +2 -0
  133. package/esm/shape/label/position/topLeft.js.map +1 -0
  134. package/esm/shape/label/position/topRight.d.ts +1 -0
  135. package/esm/shape/label/position/topRight.js +2 -0
  136. package/esm/shape/label/position/topRight.js.map +1 -0
  137. package/esm/spec/composition.d.ts +2 -0
  138. package/esm/spec/data.d.ts +10 -3
  139. package/esm/spec/geometry.d.ts +2 -1
  140. package/esm/spec/interaction.d.ts +28 -5
  141. package/esm/spec/labelTransform.d.ts +24 -11
  142. package/esm/spec/theme.d.ts +5 -2
  143. package/esm/spec/transform.d.ts +7 -2
  144. package/esm/stdlib/index.js +9 -10
  145. package/esm/stdlib/index.js.map +1 -1
  146. package/esm/theme/academy.d.ts +3 -0
  147. package/esm/theme/academy.js +402 -0
  148. package/esm/theme/academy.js.map +1 -0
  149. package/esm/theme/dark.js +80 -29
  150. package/esm/theme/dark.js.map +1 -1
  151. package/esm/theme/index.d.ts +1 -0
  152. package/esm/theme/index.js +1 -0
  153. package/esm/theme/index.js.map +1 -1
  154. package/esm/theme/light.js +71 -19
  155. package/esm/theme/light.js.map +1 -1
  156. package/esm/transform/filter.d.ts +7 -0
  157. package/esm/transform/filter.js +42 -0
  158. package/esm/transform/filter.js.map +1 -0
  159. package/esm/transform/index.d.ts +2 -0
  160. package/esm/transform/index.js +1 -0
  161. package/esm/transform/index.js.map +1 -1
  162. package/esm/transform/maybeTooltip.js +3 -1
  163. package/esm/transform/maybeTooltip.js.map +1 -1
  164. package/esm/utils/bounds.d.ts +26 -0
  165. package/esm/utils/bounds.js +41 -0
  166. package/esm/utils/bounds.js.map +1 -0
  167. package/esm/utils/color.d.ts +6 -0
  168. package/esm/utils/color.js +7 -0
  169. package/esm/utils/color.js.map +1 -0
  170. package/esm/utils/coordinate.d.ts +1 -0
  171. package/esm/utils/coordinate.js +12 -0
  172. package/esm/utils/coordinate.js.map +1 -1
  173. package/esm/utils/helper.d.ts +1 -0
  174. package/esm/utils/helper.js +3 -0
  175. package/esm/utils/helper.js.map +1 -1
  176. package/esm/utils/selection.d.ts +1 -0
  177. package/esm/utils/selection.js.map +1 -1
  178. package/esm/utils/size.js +1 -1
  179. package/esm/utils/size.js.map +1 -1
  180. package/lib/api/mark/mark.js +1 -2
  181. package/lib/api/mark/mark.js.map +1 -1
  182. package/lib/api/mark/types.d.ts +1 -2
  183. package/lib/component/axis.js +46 -24
  184. package/lib/component/axis.js.map +1 -1
  185. package/lib/component/index.d.ts +4 -0
  186. package/lib/component/index.js +5 -1
  187. package/lib/component/index.js.map +1 -1
  188. package/lib/component/legendCategory.js +1 -0
  189. package/lib/component/legendCategory.js.map +1 -1
  190. package/lib/component/slider.d.ts +9 -0
  191. package/lib/component/slider.js +61 -0
  192. package/lib/component/slider.js.map +1 -0
  193. package/lib/component/sliderX.d.ts +7 -0
  194. package/lib/component/sliderX.js +13 -0
  195. package/lib/component/sliderX.js.map +1 -0
  196. package/lib/component/sliderY.d.ts +7 -0
  197. package/lib/component/sliderY.js +13 -0
  198. package/lib/component/sliderY.js.map +1 -0
  199. package/lib/composition/facetRect.js +4 -4
  200. package/lib/composition/facetRect.js.map +1 -1
  201. package/lib/composition/mark.js +3 -1
  202. package/lib/composition/mark.js.map +1 -1
  203. package/lib/composition/repeatMatrix.js +2 -2
  204. package/lib/composition/repeatMatrix.js.map +1 -1
  205. package/lib/data/filter.d.ts +3 -3
  206. package/lib/data/filter.js.map +1 -1
  207. package/lib/data/index.d.ts +3 -1
  208. package/lib/data/index.js +3 -1
  209. package/lib/data/index.js.map +1 -1
  210. package/lib/data/sort.d.ts +8 -0
  211. package/lib/data/sort.js +17 -0
  212. package/lib/data/sort.js.map +1 -0
  213. package/lib/interaction/builtin/brushHighlight.d.ts +1 -1
  214. package/lib/interaction/builtin/tooltip.d.ts +6 -4
  215. package/lib/interaction/index.d.ts +5 -0
  216. package/lib/interaction/index.js +11 -1
  217. package/lib/interaction/index.js.map +1 -1
  218. package/lib/interaction/native/brushHighlight.d.ts +15 -0
  219. package/lib/interaction/native/brushHighlight.js +289 -0
  220. package/lib/interaction/native/brushHighlight.js.map +1 -0
  221. package/lib/interaction/native/brushXHighlight.d.ts +1 -0
  222. package/lib/interaction/native/brushXHighlight.js +12 -0
  223. package/lib/interaction/native/brushXHighlight.js.map +1 -0
  224. package/lib/interaction/native/brushYHighlight.d.ts +1 -0
  225. package/lib/interaction/native/brushYHighlight.js +12 -0
  226. package/lib/interaction/native/brushYHighlight.js.map +1 -0
  227. package/lib/interaction/native/legendFilter.d.ts +8 -0
  228. package/lib/interaction/native/legendFilter.js +184 -0
  229. package/lib/interaction/native/legendFilter.js.map +1 -0
  230. package/lib/interaction/native/tooltip.d.ts +2 -2
  231. package/lib/interaction/native/tooltip.js +131 -41
  232. package/lib/interaction/native/tooltip.js.map +1 -1
  233. package/lib/interaction/native/utils.d.ts +5 -1
  234. package/lib/interaction/native/utils.js +30 -3
  235. package/lib/interaction/native/utils.js.map +1 -1
  236. package/lib/label-transform/contrastReverse.d.ts +9 -0
  237. package/lib/label-transform/contrastReverse.js +52 -0
  238. package/lib/label-transform/contrastReverse.js.map +1 -0
  239. package/lib/label-transform/index.d.ts +8 -8
  240. package/lib/label-transform/index.js +9 -9
  241. package/lib/label-transform/index.js.map +1 -1
  242. package/lib/label-transform/overflowHide.d.ts +7 -0
  243. package/lib/label-transform/overflowHide.js +22 -0
  244. package/lib/label-transform/overflowHide.js.map +1 -0
  245. package/lib/label-transform/overlapDodgeY.d.ts +7 -0
  246. package/lib/label-transform/{dodgeY.js → overlapDodgeY.js} +6 -6
  247. package/lib/label-transform/overlapDodgeY.js.map +1 -0
  248. package/lib/label-transform/overlapHide.d.ts +7 -0
  249. package/lib/label-transform/overlapHide.js +28 -0
  250. package/lib/label-transform/overlapHide.js.map +1 -0
  251. package/lib/mark/area.js +1 -1
  252. package/lib/mark/area.js.map +1 -1
  253. package/lib/mark/line.js +1 -1
  254. package/lib/mark/line.js.map +1 -1
  255. package/lib/runtime/component.js +29 -1
  256. package/lib/runtime/component.js.map +1 -1
  257. package/lib/runtime/plot.js +38 -13
  258. package/lib/runtime/plot.js.map +1 -1
  259. package/lib/runtime/scale.js +16 -4
  260. package/lib/runtime/scale.js.map +1 -1
  261. package/lib/runtime/transform.js +10 -4
  262. package/lib/runtime/transform.js.map +1 -1
  263. package/lib/runtime/types/common.d.ts +1 -0
  264. package/lib/runtime/types/mark.d.ts +1 -1
  265. package/lib/runtime/types/options.d.ts +2 -0
  266. package/lib/runtime/types/theme.d.ts +5 -0
  267. package/lib/shape/label/label.js +3 -3
  268. package/lib/shape/label/label.js.map +1 -1
  269. package/lib/shape/label/position/area.d.ts +13 -0
  270. package/lib/shape/label/position/area.js +32 -0
  271. package/lib/shape/label/position/area.js.map +1 -0
  272. package/lib/shape/label/position/bottom.d.ts +1 -0
  273. package/lib/shape/label/position/bottom.js +6 -0
  274. package/lib/shape/label/position/bottom.js.map +1 -0
  275. package/lib/shape/label/position/bottomLeft.d.ts +1 -0
  276. package/lib/shape/label/position/bottomLeft.js +6 -0
  277. package/lib/shape/label/position/bottomLeft.js.map +1 -0
  278. package/lib/shape/label/position/bottomRight.d.ts +1 -0
  279. package/lib/shape/label/position/bottomRight.js +6 -0
  280. package/lib/shape/label/position/bottomRight.js.map +1 -0
  281. package/lib/shape/label/position/default.d.ts +20 -0
  282. package/lib/shape/label/{position.js → position/default.js} +10 -43
  283. package/lib/shape/label/position/default.js.map +1 -0
  284. package/lib/shape/label/position/index.d.ts +13 -0
  285. package/lib/shape/label/position/index.js +30 -0
  286. package/lib/shape/label/position/index.js.map +1 -0
  287. package/lib/shape/label/position/inside.d.ts +1 -0
  288. package/lib/shape/label/position/inside.js +6 -0
  289. package/lib/shape/label/position/inside.js.map +1 -0
  290. package/lib/shape/label/position/left.d.ts +1 -0
  291. package/lib/shape/label/position/left.js +6 -0
  292. package/lib/shape/label/position/left.js.map +1 -0
  293. package/lib/shape/label/position/outside.d.ts +1 -0
  294. package/lib/shape/label/position/outside.js +6 -0
  295. package/lib/shape/label/position/outside.js.map +1 -0
  296. package/lib/shape/label/position/right.d.ts +1 -0
  297. package/lib/shape/label/position/right.js +6 -0
  298. package/lib/shape/label/position/right.js.map +1 -0
  299. package/lib/shape/label/position/spider.d.ts +7 -0
  300. package/lib/shape/label/position/spider.js +44 -0
  301. package/lib/shape/label/position/spider.js.map +1 -0
  302. package/lib/shape/label/position/surround.d.ts +7 -0
  303. package/lib/shape/label/position/surround.js +41 -0
  304. package/lib/shape/label/position/surround.js.map +1 -0
  305. package/lib/shape/label/position/top.d.ts +1 -0
  306. package/lib/shape/label/position/top.js +6 -0
  307. package/lib/shape/label/position/top.js.map +1 -0
  308. package/lib/shape/label/position/topLeft.d.ts +1 -0
  309. package/lib/shape/label/position/topLeft.js +6 -0
  310. package/lib/shape/label/position/topLeft.js.map +1 -0
  311. package/lib/shape/label/position/topRight.d.ts +1 -0
  312. package/lib/shape/label/position/topRight.js +6 -0
  313. package/lib/shape/label/position/topRight.js.map +1 -0
  314. package/lib/spec/composition.d.ts +2 -0
  315. package/lib/spec/data.d.ts +10 -3
  316. package/lib/spec/geometry.d.ts +2 -1
  317. package/lib/spec/interaction.d.ts +28 -5
  318. package/lib/spec/labelTransform.d.ts +24 -11
  319. package/lib/spec/theme.d.ts +5 -2
  320. package/lib/spec/transform.d.ts +7 -2
  321. package/lib/stdlib/index.js +3 -4
  322. package/lib/stdlib/index.js.map +1 -1
  323. package/lib/theme/academy.d.ts +3 -0
  324. package/lib/theme/academy.js +406 -0
  325. package/lib/theme/academy.js.map +1 -0
  326. package/lib/theme/dark.js +80 -29
  327. package/lib/theme/dark.js.map +1 -1
  328. package/lib/theme/index.d.ts +1 -0
  329. package/lib/theme/index.js +3 -1
  330. package/lib/theme/index.js.map +1 -1
  331. package/lib/theme/light.js +71 -19
  332. package/lib/theme/light.js.map +1 -1
  333. package/lib/transform/filter.d.ts +7 -0
  334. package/lib/transform/filter.js +46 -0
  335. package/lib/transform/filter.js.map +1 -0
  336. package/lib/transform/index.d.ts +2 -0
  337. package/lib/transform/index.js +3 -1
  338. package/lib/transform/index.js.map +1 -1
  339. package/lib/transform/maybeTooltip.js +3 -1
  340. package/lib/transform/maybeTooltip.js.map +1 -1
  341. package/lib/utils/bounds.d.ts +26 -0
  342. package/lib/utils/bounds.js +48 -0
  343. package/lib/utils/bounds.js.map +1 -0
  344. package/lib/utils/color.d.ts +6 -0
  345. package/lib/utils/color.js +11 -0
  346. package/lib/utils/color.js.map +1 -0
  347. package/lib/utils/coordinate.d.ts +1 -0
  348. package/lib/utils/coordinate.js +14 -1
  349. package/lib/utils/coordinate.js.map +1 -1
  350. package/lib/utils/helper.d.ts +1 -0
  351. package/lib/utils/helper.js +5 -1
  352. package/lib/utils/helper.js.map +1 -1
  353. package/lib/utils/selection.d.ts +1 -0
  354. package/lib/utils/selection.js.map +1 -1
  355. package/lib/utils/size.js +1 -1
  356. package/lib/utils/size.js.map +1 -1
  357. package/package.json +4 -3
  358. package/src/api/mark/mark.ts +1 -2
  359. package/src/api/mark/types.ts +1 -2
  360. package/src/component/axis.ts +56 -96
  361. package/src/component/index.ts +4 -0
  362. package/src/component/legendCategory.ts +1 -0
  363. package/src/component/slider.ts +61 -0
  364. package/src/component/sliderX.ts +16 -0
  365. package/src/component/sliderY.ts +16 -0
  366. package/src/composition/facetRect.ts +4 -2
  367. package/src/composition/mark.ts +4 -0
  368. package/src/composition/repeatMatrix.ts +8 -1
  369. package/src/data/filter.ts +3 -3
  370. package/src/data/index.ts +3 -1
  371. package/src/data/sort.ts +18 -0
  372. package/src/interaction/index.ts +6 -0
  373. package/src/interaction/native/brushHighlight.ts +346 -0
  374. package/src/interaction/native/brushXHighlight.ts +11 -0
  375. package/src/interaction/native/brushYHighlight.ts +11 -0
  376. package/src/interaction/native/legendFilter.ts +195 -0
  377. package/src/interaction/native/tooltip.ts +173 -45
  378. package/src/interaction/native/utils.ts +33 -1
  379. package/src/label-transform/contrastReverse.ts +56 -0
  380. package/src/label-transform/index.ts +8 -8
  381. package/src/label-transform/overflowHide.ts +23 -0
  382. package/src/label-transform/{dodgeY.ts → overlapDodgeY.ts} +6 -6
  383. package/src/label-transform/overlapHide.ts +32 -0
  384. package/src/mark/area.ts +1 -1
  385. package/src/mark/line.ts +1 -1
  386. package/src/runtime/component.ts +49 -2
  387. package/src/runtime/plot.ts +46 -11
  388. package/src/runtime/scale.ts +15 -7
  389. package/src/runtime/transform.ts +13 -4
  390. package/src/runtime/types/common.ts +1 -0
  391. package/src/runtime/types/mark.ts +1 -1
  392. package/src/runtime/types/options.ts +2 -0
  393. package/src/runtime/types/theme.ts +5 -0
  394. package/src/shape/label/label.ts +4 -3
  395. package/src/shape/label/position/area.ts +39 -0
  396. package/src/shape/label/position/bottom.ts +1 -0
  397. package/src/shape/label/position/bottomLeft.ts +1 -0
  398. package/src/shape/label/position/bottomRight.ts +1 -0
  399. package/src/shape/label/{position.ts → position/default.ts} +12 -56
  400. package/src/shape/label/position/index.ts +13 -0
  401. package/src/shape/label/position/inside.ts +1 -0
  402. package/src/shape/label/position/left.ts +1 -0
  403. package/src/shape/label/position/outside.ts +1 -0
  404. package/src/shape/label/position/right.ts +1 -0
  405. package/src/shape/label/position/spider.ts +46 -0
  406. package/src/shape/label/position/surround.ts +42 -0
  407. package/src/shape/label/position/top.ts +1 -0
  408. package/src/shape/label/position/topLeft.ts +1 -0
  409. package/src/shape/label/position/topRight.ts +1 -0
  410. package/src/spec/composition.ts +2 -0
  411. package/src/spec/data.ts +12 -2
  412. package/src/spec/geometry.ts +3 -1
  413. package/src/spec/interaction.ts +38 -4
  414. package/src/spec/labelTransform.ts +29 -11
  415. package/src/spec/theme.ts +6 -2
  416. package/src/spec/transform.ts +9 -1
  417. package/src/stdlib/index.ts +31 -9
  418. package/src/theme/academy.ts +408 -0
  419. package/src/theme/dark.ts +81 -29
  420. package/src/theme/index.ts +1 -0
  421. package/src/theme/light.ts +71 -19
  422. package/src/transform/filter.ts +48 -0
  423. package/src/transform/index.ts +2 -0
  424. package/src/transform/maybeTooltip.ts +3 -1
  425. package/src/utils/bounds.ts +52 -0
  426. package/src/utils/color.ts +12 -0
  427. package/src/utils/coordinate.ts +12 -0
  428. package/src/utils/helper.ts +4 -0
  429. package/src/utils/selection.ts +2 -0
  430. package/src/utils/size.ts +1 -1
  431. package/esm/label-transform/dodgeY.d.ts +0 -7
  432. package/esm/label-transform/dodgeY.js.map +0 -1
  433. package/esm/label-transform/hideOverlap.d.ts +0 -4
  434. package/esm/label-transform/hideOverlap.js +0 -48
  435. package/esm/label-transform/hideOverlap.js.map +0 -1
  436. package/esm/label-transform/spider.d.ts +0 -7
  437. package/esm/label-transform/spider.js +0 -30
  438. package/esm/label-transform/spider.js.map +0 -1
  439. package/esm/label-transform/surround.d.ts +0 -7
  440. package/esm/label-transform/surround.js +0 -30
  441. package/esm/label-transform/surround.js.map +0 -1
  442. package/esm/shape/label/position.d.ts +0 -25
  443. package/esm/shape/label/position.js.map +0 -1
  444. package/lib/label-transform/dodgeY.d.ts +0 -7
  445. package/lib/label-transform/dodgeY.js.map +0 -1
  446. package/lib/label-transform/hideOverlap.d.ts +0 -4
  447. package/lib/label-transform/hideOverlap.js +0 -52
  448. package/lib/label-transform/hideOverlap.js.map +0 -1
  449. package/lib/label-transform/spider.d.ts +0 -7
  450. package/lib/label-transform/spider.js +0 -34
  451. package/lib/label-transform/spider.js.map +0 -1
  452. package/lib/label-transform/surround.d.ts +0 -7
  453. package/lib/label-transform/surround.js +0 -34
  454. package/lib/label-transform/surround.js.map +0 -1
  455. package/lib/shape/label/position.d.ts +0 -25
  456. package/lib/shape/label/position.js.map +0 -1
  457. package/src/label-transform/hideOverlap.ts +0 -62
  458. package/src/label-transform/spider.ts +0 -37
  459. package/src/label-transform/surround.ts +0 -37
@@ -26,7 +26,6 @@ import {
26
26
  isRadial,
27
27
  } from './coordinate';
28
28
  import { useLibrary } from './library';
29
- import { isPosition } from './scale';
30
29
 
31
30
  export function inferComponent(
32
31
  scales: G2ScaleOptions[],
@@ -49,7 +48,8 @@ export function inferComponent(
49
48
  if (guide === null) return false;
50
49
  return true;
51
50
  });
52
- const components = [...partialComponents];
51
+ const sliders = createSliders(partialOptions, scales, library);
52
+ const components = [...partialComponents, ...sliders];
53
53
  if (title) {
54
54
  const { props } = createGuideComponent('title');
55
55
  const { defaultPosition, defaultOrder, defaultSize } = props;
@@ -223,3 +223,50 @@ function inferTitleComponentSize(options: G2TitleOptions) {
223
223
  // Extra 4px spacing.
224
224
  return (text ? titleSize + 4 : 0) + (subtitle ? subtitleSize + spacing : 0);
225
225
  }
226
+
227
+ function inferSliderType(
228
+ name: string,
229
+ coordinates: G2CoordinateOptions[] = [],
230
+ ) {
231
+ if (name === 'x') return isTranspose(coordinates) ? 'sliderY' : 'sliderX';
232
+ if (name === 'y') return isTranspose(coordinates) ? 'sliderX' : 'sliderY';
233
+ return null;
234
+ }
235
+
236
+ function createSliders(
237
+ partialOptions: G2View,
238
+ scales: G2ScaleOptions[],
239
+ library,
240
+ ) {
241
+ const [, createGuideComponent] = useLibrary<
242
+ G2GuideComponentOptions,
243
+ GuideComponentComponent,
244
+ GuideComponent
245
+ >('component', library);
246
+
247
+ const { marks, coordinates } = partialOptions;
248
+ const nameScale = new Map(scales.map((scale) => [scale.name, scale]));
249
+
250
+ return marks
251
+ .filter((d) => d.slider)
252
+ .flatMap((mark) => {
253
+ const { slider } = mark;
254
+ return Object.entries(slider).map(([channelName, options]) => {
255
+ const scale = nameScale.get(channelName);
256
+ const componentType = inferSliderType(channelName, coordinates);
257
+ if (!scale || !componentType) return;
258
+
259
+ const { props } = createGuideComponent(componentType);
260
+ const { defaultPosition, defaultSize, defaultOrder } = props;
261
+ return {
262
+ position: defaultPosition,
263
+ size: defaultSize,
264
+ order: defaultOrder,
265
+ type: componentType,
266
+ ...options,
267
+ scale,
268
+ };
269
+ });
270
+ })
271
+ .filter((d) => !!d);
272
+ }
@@ -1,4 +1,4 @@
1
- import { DisplayObject, IAnimation as GAnimation } from '@antv/g';
1
+ import { DisplayObject, IAnimation as GAnimation, Rect } from '@antv/g';
2
2
  import { deepMix, upperFirst } from '@antv/util';
3
3
  import { format } from 'd3-format';
4
4
  import { Vector2 } from '@antv/coord';
@@ -383,7 +383,8 @@ function initializeState(
383
383
  library,
384
384
  );
385
385
 
386
- const { key, frame = false, theme: partialTheme, style = {} } = options;
386
+ const { key, frame = false, theme: partialTheme, clip, style = {} } = options;
387
+
387
388
  const theme = useTheme(inferTheme(partialTheme));
388
389
 
389
390
  // Infer components and compute layout.
@@ -396,7 +397,7 @@ function initializeState(
396
397
  const layout = computeLayout(components, options);
397
398
  const coordinate = createCoordinate(layout, options, library);
398
399
  const framedStyle = frame
399
- ? deepMix({ mainlineWidth: 1, mainStroke: '#000' }, style)
400
+ ? deepMix({ mainLineWidth: 1, mainStroke: '#000' }, style)
400
401
  : style;
401
402
 
402
403
  // Place components and mutate their bbox.
@@ -473,6 +474,7 @@ function initializeState(
473
474
  components,
474
475
  markState,
475
476
  key,
477
+ clip,
476
478
  scale: scaleInstance,
477
479
  style: framedStyle,
478
480
  };
@@ -489,7 +491,8 @@ async function plotView(
489
491
  transitions: GAnimation[],
490
492
  library: G2Library,
491
493
  ): Promise<void> {
492
- const { components, theme, layout, markState, coordinate, key, style } = view;
494
+ const { components, theme, layout, markState, coordinate, key, style, clip } =
495
+ view;
493
496
 
494
497
  // Render background for the different areas.
495
498
  const { x, y, width, height, ...rest } = layout;
@@ -589,7 +592,8 @@ async function plotView(
589
592
  .style('fill', 'transparent')
590
593
  .attr('className', PLOT_CLASS_NAME)
591
594
  .call(updateBBox)
592
- .call(updateLayers, Array.from(markState.keys())),
595
+ .call(updateLayers, Array.from(markState.keys()))
596
+ .call(applyClip, clip),
593
597
  (update) =>
594
598
  update
595
599
  .call(updateLayers, Array.from(markState.keys()))
@@ -597,7 +601,8 @@ async function plotView(
597
601
  return animationExtent
598
602
  ? animateBBox(selection, animationExtent)
599
603
  : updateBBox(selection);
600
- }),
604
+ })
605
+ .call(applyClip, clip),
601
606
  )
602
607
  .transitions();
603
608
  transitions.push(...T.flat());
@@ -643,12 +648,16 @@ async function plotView(
643
648
  return animation;
644
649
  });
645
650
  }),
646
- (exit) =>
647
- exit
651
+ (exit) => {
652
+ return exit
653
+ .each(function () {
654
+ this.__removed__ = true;
655
+ })
648
656
  .transition(function (data) {
649
657
  return exitFunction(data, [this]);
650
658
  })
651
- .remove(),
659
+ .remove();
660
+ },
652
661
  (merge) =>
653
662
  merge
654
663
  // Append elements to be merged.
@@ -714,7 +723,9 @@ function plotLabel(
714
723
  const elements = selection
715
724
  .select(`#${key}`)
716
725
  .selectAll(className(ELEMENT_CLASS_NAME))
717
- .nodes();
726
+ .nodes()
727
+ // Only select the valid element.
728
+ .filter((n) => !n.__removed__);
718
729
  return labelOptions.flatMap((labelOption, i) => {
719
730
  const { transform = [], ...options } = labelOption;
720
731
  return elements.flatMap((e) => {
@@ -773,7 +784,16 @@ function getLabels(
773
784
  const { seriesIndex: SI, seriesKey, points, key, index } = element.__data__;
774
785
  const bounds = getLocalBounds(element);
775
786
  if (!SI) {
776
- return [{ ...label, key: `${key}-${labelIndex}`, bounds, index, points }];
787
+ return [
788
+ {
789
+ ...label,
790
+ key: `${key}-${labelIndex}`,
791
+ bounds,
792
+ index,
793
+ points,
794
+ dependentElement: element,
795
+ },
796
+ ];
777
797
  }
778
798
  const selector = normalizeLabelSelector(label);
779
799
  const F = SI.map((index: number, i: number) => ({
@@ -782,6 +802,7 @@ function getLabels(
782
802
  bounds: [points[i]],
783
803
  index,
784
804
  points,
805
+ dependentElement: element,
785
806
  }));
786
807
  return selector ? selector(F) : F;
787
808
  }
@@ -1207,6 +1228,20 @@ function className(...names: string[]): string {
1207
1228
  return names.map((d) => `.${d}`).join('');
1208
1229
  }
1209
1230
 
1231
+ function applyClip(selection, clip?: boolean) {
1232
+ if (!selection.node()) return;
1233
+ selection.style('clipPath', (data) => {
1234
+ if (!clip) return;
1235
+ const {
1236
+ paddingTop: y,
1237
+ paddingLeft: x,
1238
+ innerWidth: width,
1239
+ innerHeight: height,
1240
+ } = data;
1241
+ return new Rect({ style: { x, y, width, height } });
1242
+ });
1243
+ }
1244
+
1210
1245
  export function applyStyle(
1211
1246
  selection: Selection,
1212
1247
  style: Record<string, Primitive>,
@@ -3,7 +3,7 @@ import { extent } from 'd3-array';
3
3
  import * as d3ScaleChromatic from 'd3-scale-chromatic';
4
4
  import { upperFirst } from '@antv/util';
5
5
  import { firstOf, lastOf, unique } from '../utils/array';
6
- import { defined, identity } from '../utils/helper';
6
+ import { defined, identity, isStrictObject } from '../utils/helper';
7
7
  import { Primitive, G2Theme, G2MarkState, ChannelGroups } from './types/common';
8
8
  import {
9
9
  G2CoordinateOptions,
@@ -155,7 +155,7 @@ function inferScaleType(
155
155
  ): string | ScaleComponent {
156
156
  const { type, domain, range } = options;
157
157
  if (type !== undefined) return type;
158
-
158
+ if (isObject(values)) return 'identity';
159
159
  if (typeof range === 'string') return 'linear';
160
160
  if ((domain || range || []).length > 2) return asOrdinalType(name);
161
161
  if (domain !== undefined) {
@@ -275,11 +275,15 @@ function categoricalColors(
275
275
  );
276
276
  const { defaultCategory10: c10, defaultCategory20: c20 } = theme;
277
277
  const defaultPalette = unique(values.flat()).length <= c10.length ? c10 : c20;
278
- const { palette, offset } = options;
279
- const colors =
280
- interpolatedColors(palette, domain, offset) ||
281
- usePalette({ type: palette || defaultPalette });
282
- return colors;
278
+ const { palette = defaultPalette, offset } = options;
279
+ // Built-in palettes have higher priority.
280
+ try {
281
+ return usePalette({ type: palette });
282
+ } catch (e) {
283
+ const colors = interpolatedColors(palette, domain, offset);
284
+ if (colors) return colors;
285
+ throw new Error(`Unknown Component: ${palette} `);
286
+ }
283
287
  }
284
288
 
285
289
  function gradientColors(range: string): string[] {
@@ -446,6 +450,10 @@ function isTemporal(values: Primitive[][]): boolean {
446
450
  return some(values, (d) => d instanceof Date);
447
451
  }
448
452
 
453
+ function isObject(values: Primitive[][]): boolean {
454
+ return some(values, isStrictObject);
455
+ }
456
+
449
457
  function some(values, callback) {
450
458
  for (const V of values) {
451
459
  if (V.some(callback)) return true;
@@ -193,19 +193,28 @@ export function maybeNonAnimate(
193
193
  }
194
194
 
195
195
  function isTypedChannel(channel): boolean {
196
- if (typeof channel !== 'object' || channel instanceof Date) return false;
196
+ if (
197
+ typeof channel !== 'object' ||
198
+ channel instanceof Date ||
199
+ channel === null
200
+ ) {
201
+ return false;
202
+ }
197
203
  const { type } = channel;
198
204
  return defined(type);
199
205
  }
200
206
 
201
207
  function inferChannelType(data: Record<string, Primitive>[], channel): string {
202
208
  if (typeof channel === 'function') return 'transform';
203
- if (typeof channel === 'string' && data?.[0]?.[channel] !== undefined) {
204
- return 'field';
205
- }
209
+ if (typeof channel === 'string' && isField(data, channel)) return 'field';
206
210
  return 'constant';
207
211
  }
208
212
 
213
+ function isField(data: Record<string, Primitive>[], value: string): boolean {
214
+ if (!Array.isArray(data)) return false;
215
+ return data.some((d) => d[value] !== undefined);
216
+ }
217
+
209
218
  function normalizedDataSource(data) {
210
219
  // Return null as a placeholder.
211
220
  if (!data) return { type: 'inline', value: null };
@@ -22,6 +22,7 @@ export type G2ViewDescriptor = {
22
22
  components: G2GuideComponentOptions[];
23
23
  layout: Layout;
24
24
  key: string;
25
+ clip: boolean;
25
26
  labelTransform?: LabelTransform;
26
27
  // @todo More accurate type.
27
28
  style: Record<string, any>;
@@ -23,7 +23,7 @@ export type MarkProps = {
23
23
  interaction?: {
24
24
  shareTooltip?: boolean;
25
25
  seriesTooltip?: boolean;
26
- showCrosshairs?: boolean;
26
+ crosshairs?: boolean;
27
27
  };
28
28
  };
29
29
 
@@ -82,6 +82,7 @@ export type G2View = {
82
82
  labelTransform?: G2LabelTransformOptions[];
83
83
  style?: Record<string, any>;
84
84
  tooltip?: boolean;
85
+ clip?: boolean;
85
86
  };
86
87
 
87
88
  export type G2Mark = {
@@ -100,6 +101,7 @@ export type G2Mark = {
100
101
  facet?: boolean;
101
102
  axis?: boolean | Record<string, any>;
102
103
  legend?: boolean | Record<string, any>;
104
+ slider?: Record<string, any>;
103
105
  filter?: (i: number) => boolean;
104
106
  children?: G2MarkChildrenCallback;
105
107
  dataDomain?: number;
@@ -70,6 +70,11 @@ type InteractionTheme = {
70
70
 
71
71
  type ComponentTheme = {
72
72
  axis?: any;
73
+ axisArcY?: any;
74
+ axisTop?: any;
75
+ axisBottom?: any;
76
+ axisLeft?: any;
77
+ axisRight?: any;
73
78
  legend?: any;
74
79
  continuousLegend?: any;
75
80
  label?: LabelStyleProps;
@@ -5,7 +5,7 @@ import { applyStyle } from '../../shape/utils';
5
5
  import { isTranspose, isCircular } from '../../utils/coordinate';
6
6
  import { camelCase } from '../../utils/string';
7
7
  import { Advance } from '../text/advance';
8
- import { LabelPosition } from './position';
8
+ import { LabelPosition } from './position/default';
9
9
  import * as PositionProcessor from './position';
10
10
 
11
11
  export type LabelOptions = Record<string, any>;
@@ -22,6 +22,7 @@ function getDefaultStyle(
22
22
  value: Record<string, any>,
23
23
  coordinate: Coordinate,
24
24
  theme: G2Theme,
25
+ options: LabelOptions,
25
26
  ): Record<string, any> {
26
27
  // For non-series mark, calc position for label based on
27
28
  // position and the bounds of shape.
@@ -35,7 +36,7 @@ function getDefaultStyle(
35
36
  }
36
37
  return {
37
38
  ...t,
38
- ...processor(p, points, v, coordinate),
39
+ ...processor(p, points, v, coordinate, options),
39
40
  };
40
41
  }
41
42
 
@@ -50,7 +51,7 @@ export const Label: SC<LabelOptions> = (options) => {
50
51
  rotate = 0,
51
52
  transform = '',
52
53
  ...defaultStyle
53
- } = getDefaultStyle(points, value, coordinate, theme);
54
+ } = getDefaultStyle(points, value, coordinate, theme, options);
54
55
 
55
56
  return select(new Advance())
56
57
  .call(applyStyle, defaultStyle)
@@ -0,0 +1,39 @@
1
+ import { maxIndex } from 'd3-array';
2
+ import { Coordinate } from '@antv/coord';
3
+ import { Vector2 } from '../../../runtime';
4
+ import { sub, angle } from '../../../utils/vector';
5
+ import { LabelPosition } from './default';
6
+
7
+ /**
8
+ * Only for Area label.
9
+ */
10
+ export function area(
11
+ position: LabelPosition,
12
+ points: Vector2[],
13
+ value: Record<string, any>,
14
+ coordinate: Coordinate,
15
+ ) {
16
+ const l = points.length / 2;
17
+ const Y1 = points.slice(0, l);
18
+ const Y0 = points.slice(l);
19
+ // Get the maximal space for label.
20
+ let idx = maxIndex(Y1, (p, i) => Math.abs(p[1] - Y0[i][1]));
21
+ // Do not show label at first and last.
22
+ idx = Math.max(Math.min(idx, l - 2), 1);
23
+
24
+ const mid = (i: number): Vector2 => [Y1[i][0], (Y1[i][1] + Y0[i][1]) / 2];
25
+ const point = mid(idx);
26
+ const prev = mid(idx - 1);
27
+ const next = mid(idx + 1);
28
+
29
+ // todo: G rotate only support deg.
30
+ const rotate = (angle(sub(next, prev)) / Math.PI) * 180;
31
+
32
+ return {
33
+ x: point[0],
34
+ y: point[1],
35
+ transform: `rotate(${rotate}deg)`,
36
+ textAlign: 'center',
37
+ textBaseline: 'middle',
38
+ };
39
+ }
@@ -0,0 +1 @@
1
+ export { getDefaultStyle as bottom } from './default';
@@ -0,0 +1 @@
1
+ export { getDefaultStyle as bottomLeft } from './default';
@@ -0,0 +1 @@
1
+ export { getDefaultStyle as bottomRight } from './default';
@@ -1,10 +1,9 @@
1
- import { maxIndex } from 'd3-array';
2
1
  import { Coordinate } from '@antv/coord';
3
- import { Vector2 } from '../../runtime';
4
- import { getArcObject } from '../../shape/utils';
5
- import { isCircular, isRadial } from '../../utils/coordinate';
6
- import { maybePercentage } from '../../utils/helper';
7
- import { sub, angle, mid } from '../../utils/vector';
2
+ import { Vector2 } from '../../../runtime';
3
+ import { getArcObject } from '../../../shape/utils';
4
+ import { isCircular, isRadial } from '../../../utils/coordinate';
5
+ import { maybePercentage } from '../../../utils/helper';
6
+ import { mid } from '../../../utils/vector';
8
7
 
9
8
  export type LabelPosition =
10
9
  | 'top'
@@ -17,9 +16,11 @@ export type LabelPosition =
17
16
  | 'bottom-right'
18
17
  | 'inside'
19
18
  | 'outside'
20
- | 'area';
19
+ | 'area'
20
+ | 'spider'
21
+ | 'surround';
21
22
 
22
- function inferNonCircularStyle(
23
+ export function inferNonCircularStyle(
23
24
  position: LabelPosition,
24
25
  points: Vector2[],
25
26
  value: Record<string, any>,
@@ -66,7 +67,7 @@ function inferNonCircularStyle(
66
67
  });
67
68
  }
68
69
 
69
- function inferRadialStyle(
70
+ export function inferRadialStyle(
70
71
  position: LabelPosition,
71
72
  points: Vector2[],
72
73
  value: Record<string, any>,
@@ -114,7 +115,7 @@ function inferRotation(
114
115
  return (angle / Math.PI) * 180 + append;
115
116
  }
116
117
 
117
- function inferCircularStyle(
118
+ export function inferCircularStyle(
118
119
  position: LabelPosition,
119
120
  points: Vector2[],
120
121
  value: Record<string, any>,
@@ -193,7 +194,7 @@ function inferIdentityStyle(position, points, value, coordinate) {
193
194
  };
194
195
  }
195
196
 
196
- function getDefaultStyle(
197
+ export function getDefaultStyle(
197
198
  position: LabelPosition,
198
199
  points: Vector2[],
199
200
  value: Record<string, any>,
@@ -216,48 +217,3 @@ function getDefaultStyle(
216
217
 
217
218
  return inferDefaultStyle(position, points, value, coordinate);
218
219
  }
219
-
220
- export const top = getDefaultStyle;
221
- export const bottom = getDefaultStyle;
222
- export const right = getDefaultStyle;
223
- export const left = getDefaultStyle;
224
- export const topLeft = getDefaultStyle;
225
- export const topRight = getDefaultStyle;
226
- export const bottomLeft = getDefaultStyle;
227
- export const bottomRight = getDefaultStyle;
228
- export const inside = getDefaultStyle;
229
- export const outside = getDefaultStyle;
230
-
231
- /**
232
- * Only for Area label.
233
- */
234
- export function area(
235
- position: LabelPosition,
236
- points: Vector2[],
237
- value: Record<string, any>,
238
- coordinate: Coordinate,
239
- ) {
240
- const l = points.length / 2;
241
- const Y1 = points.slice(0, l);
242
- const Y0 = points.slice(l);
243
- // Get the maximal space for label.
244
- let idx = maxIndex(Y1, (p, i) => Math.abs(p[1] - Y0[i][1]));
245
- // Do not show label at first and last.
246
- idx = Math.max(Math.min(idx, l - 2), 1);
247
-
248
- const mid = (i: number): Vector2 => [Y1[i][0], (Y1[i][1] + Y0[i][1]) / 2];
249
- const point = mid(idx);
250
- const prev = mid(idx - 1);
251
- const next = mid(idx + 1);
252
-
253
- // todo: G rotate only support deg.
254
- const rotate = (angle(sub(next, prev)) / Math.PI) * 180;
255
-
256
- return {
257
- x: point[0],
258
- y: point[1],
259
- transform: `rotate(${rotate}deg)`,
260
- textAlign: 'center',
261
- textBaseline: 'middle',
262
- };
263
- }
@@ -0,0 +1,13 @@
1
+ export { area } from './area';
2
+ export { bottom } from './bottom';
3
+ export { bottomLeft } from './bottomLeft';
4
+ export { bottomRight } from './bottomRight';
5
+ export { inside } from './inside';
6
+ export { left } from './left';
7
+ export { outside } from './outside';
8
+ export { right } from './right';
9
+ export { spider } from './spider';
10
+ export { surround } from './surround';
11
+ export { top } from './top';
12
+ export { topLeft } from './topLeft';
13
+ export { topRight } from './topRight';
@@ -0,0 +1 @@
1
+ export { getDefaultStyle as inside } from './default';
@@ -0,0 +1 @@
1
+ export { getDefaultStyle as left } from './default';
@@ -0,0 +1 @@
1
+ export { getDefaultStyle as outside } from './default';
@@ -0,0 +1 @@
1
+ export { getDefaultStyle as right } from './default';
@@ -0,0 +1,46 @@
1
+ import { Coordinate } from '@antv/coord';
2
+ import { sub } from '../../../utils/vector';
3
+ import { Vector2 } from '../../../runtime';
4
+ import { isCircular } from '../../../utils/coordinate';
5
+ import { maybePercentage } from '../../../utils/helper';
6
+ import { inferCircularStyle, LabelPosition } from './default';
7
+
8
+ /**
9
+ * Spider label transform only suitable for the labels in polar coordinate, labels should distinguish coordinate type.
10
+ */
11
+ export function spider(
12
+ position: LabelPosition,
13
+ points: Vector2[],
14
+ value: Record<string, any>,
15
+ coordinate: Coordinate,
16
+ options,
17
+ ) {
18
+ if (!isCircular(coordinate)) return {};
19
+ const { edgeDistance = 0 } = options;
20
+
21
+ const { ...style }: any = inferCircularStyle(
22
+ 'outside',
23
+ points,
24
+ value,
25
+ coordinate,
26
+ );
27
+ const { x: coordX, width } = coordinate.getOptions();
28
+ const center = coordinate.getCenter();
29
+ // todo: How to configure spider.
30
+ const margin = maybePercentage(edgeDistance, width);
31
+
32
+ const edgeX = coordX + margin;
33
+ const edgeX1 = coordX + width - margin;
34
+
35
+ const { x: originX, x0, y0 } = style;
36
+ const dx = originX <= center[0] ? edgeX - originX : edgeX1 - originX;
37
+ style.x += dx;
38
+
39
+ const { x, y } = style;
40
+ const p0 = sub([x0, y0], center);
41
+ const p1 = sub([0, y], center);
42
+ const p1x = p0[1] ? (p0[0] * p1[1]) / p0[1] + center[0] : x;
43
+ style.connectorPoints = [[p1x - x, 0]];
44
+
45
+ return style;
46
+ }
@@ -0,0 +1,42 @@
1
+ import { Coordinate } from '@antv/coord';
2
+ import { PolarCoordinate } from 'spec';
3
+ import { Vector2 } from '../../../runtime';
4
+ import { getRadius, isCircular } from '../../../utils/coordinate';
5
+ import { angleWithQuadrant } from '../../../utils/vector';
6
+ import { inferCircularStyle, LabelPosition } from './default';
7
+
8
+ /**
9
+ * Surround label transform is used to make labels surround circular.
10
+ */
11
+ export function surround(
12
+ position: LabelPosition,
13
+ points: Vector2[],
14
+ value: Record<string, any>,
15
+ coordinate: Coordinate,
16
+ options,
17
+ ) {
18
+ if (!isCircular(coordinate)) return {};
19
+
20
+ const { offset = 12 } = options;
21
+ const { ...style }: any = inferCircularStyle(
22
+ 'outside',
23
+ points,
24
+ value,
25
+ coordinate,
26
+ );
27
+ const center = coordinate.getCenter();
28
+ const radius = getRadius(coordinate) + offset;
29
+
30
+ const { x0, y0, connector, connectorLength2 = 0 } = style;
31
+ const labelAngle = angleWithQuadrant([x0 - center[0], y0 - center[1]]);
32
+ const length2 = connector
33
+ ? connectorLength2 * (Math.sin(labelAngle) < 0 ? -1 : 1)
34
+ : 0;
35
+ const newX = center[0] + Math.sin(labelAngle) * radius;
36
+ const newY = center[1] - Math.cos(labelAngle) * radius;
37
+ style.x = newX + length2;
38
+ style.y = newY;
39
+ style.connectorPoints = [[-length2, 0]];
40
+
41
+ return style;
42
+ }
@@ -0,0 +1 @@
1
+ export { getDefaultStyle as top } from './default';
@@ -0,0 +1 @@
1
+ export { getDefaultStyle as topLeft } from './default';
@@ -0,0 +1 @@
1
+ export { getDefaultStyle as topRight } from './default';
@@ -24,6 +24,7 @@ export type Node =
24
24
 
25
25
  export type MarkComposition = Geometry & {
26
26
  title?: Title;
27
+ clip?: boolean;
27
28
  };
28
29
 
29
30
  export type ViewComposition = {
@@ -63,6 +64,7 @@ export type ViewComposition = {
63
64
  on?: Record<string, EventType | EventType[]>;
64
65
  // @todo
65
66
  style?: Record<string, any>;
67
+ clip?: boolean;
66
68
  };
67
69
 
68
70
  export type SpaceLayerComposition = {