@antv/g2 4.1.49 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (481) hide show
  1. package/dist/g2.min.js +3 -31
  2. package/dist/g2.min.js.map +1 -1
  3. package/esm/animate/animation/sector-path-update.js +3 -3
  4. package/esm/animate/animation/sector-path-update.js.map +1 -1
  5. package/esm/animate/animation/util.js +2 -1
  6. package/esm/animate/animation/util.js.map +1 -1
  7. package/esm/chart/chart.js +1 -1
  8. package/esm/chart/chart.js.map +1 -1
  9. package/esm/chart/controller/annotation.js +20 -10
  10. package/esm/chart/controller/annotation.js.map +1 -1
  11. package/esm/chart/controller/coordinate.js +3 -3
  12. package/esm/chart/controller/coordinate.js.map +1 -1
  13. package/esm/chart/controller/legend.js +3 -3
  14. package/esm/chart/controller/legend.js.map +1 -1
  15. package/esm/chart/controller/scrollbar.js +8 -8
  16. package/esm/chart/controller/scrollbar.js.map +1 -1
  17. package/esm/chart/controller/slider.js +8 -8
  18. package/esm/chart/controller/slider.js.map +1 -1
  19. package/esm/chart/controller/tooltip.js +82 -34
  20. package/esm/chart/controller/tooltip.js.map +1 -1
  21. package/esm/chart/layout/auto.js +2 -2
  22. package/esm/chart/layout/auto.js.map +1 -1
  23. package/esm/chart/layout/constraint/constraint.js +2 -1
  24. package/esm/chart/layout/constraint/constraint.js.map +1 -1
  25. package/esm/chart/layout/constraint/solver.js +2 -1
  26. package/esm/chart/layout/constraint/solver.js.map +1 -1
  27. package/esm/chart/layout/padding-cal.js +4 -4
  28. package/esm/chart/layout/padding-cal.js.map +1 -1
  29. package/esm/chart/view.js +2 -2
  30. package/esm/chart/view.js.map +1 -1
  31. package/esm/component/labels.d.ts +1 -2
  32. package/esm/component/labels.js +134 -103
  33. package/esm/component/labels.js.map +1 -1
  34. package/esm/constant.d.ts +3 -1
  35. package/esm/constant.js +2 -0
  36. package/esm/constant.js.map +1 -1
  37. package/esm/core.d.ts +1 -1
  38. package/esm/core.js +1 -1
  39. package/esm/core.js.map +1 -1
  40. package/esm/facet/circle.js +2 -2
  41. package/esm/facet/circle.js.map +1 -1
  42. package/esm/facet/facet.js +3 -2
  43. package/esm/facet/facet.js.map +1 -1
  44. package/esm/facet/list.js +2 -2
  45. package/esm/facet/list.js.map +1 -1
  46. package/esm/facet/mirror.js +2 -2
  47. package/esm/facet/mirror.js.map +1 -1
  48. package/esm/facet/rect.js +2 -2
  49. package/esm/facet/rect.js.map +1 -1
  50. package/esm/facet/tree.js +20 -10
  51. package/esm/facet/tree.js.map +1 -1
  52. package/esm/geometry/base.d.ts +3 -0
  53. package/esm/geometry/base.js +151 -82
  54. package/esm/geometry/base.js.map +1 -1
  55. package/esm/geometry/element/index.js +3 -1
  56. package/esm/geometry/element/index.js.map +1 -1
  57. package/esm/geometry/heatmap.js +17 -7
  58. package/esm/geometry/heatmap.js.map +1 -1
  59. package/esm/geometry/label/base.d.ts +1 -1
  60. package/esm/geometry/label/base.js +20 -8
  61. package/esm/geometry/label/base.js.map +1 -1
  62. package/esm/geometry/label/layout/hide-overlap.d.ts +1 -1
  63. package/esm/geometry/label/layout/hide-overlap.js +65 -19
  64. package/esm/geometry/label/layout/hide-overlap.js.map +1 -1
  65. package/esm/geometry/label/layout/interval/hide-overlap.js +3 -2
  66. package/esm/geometry/label/layout/interval/hide-overlap.js.map +1 -1
  67. package/esm/geometry/label/layout/path/adjust-position.js +3 -2
  68. package/esm/geometry/label/layout/path/adjust-position.js.map +1 -1
  69. package/esm/geometry/label/layout/pie/distribute.js +14 -3
  70. package/esm/geometry/label/layout/pie/distribute.js.map +1 -1
  71. package/esm/geometry/label/layout/pie/outer.js +14 -3
  72. package/esm/geometry/label/layout/pie/outer.js.map +1 -1
  73. package/esm/geometry/label/layout/pie/spider.js +14 -3
  74. package/esm/geometry/label/layout/pie/spider.js.map +1 -1
  75. package/esm/geometry/label/layout/point/adjust-position.js +3 -2
  76. package/esm/geometry/label/layout/point/adjust-position.js.map +1 -1
  77. package/esm/geometry/label/layout/worker/hide-overlap.d.ts +2 -0
  78. package/esm/geometry/label/layout/worker/hide-overlap.js +155 -0
  79. package/esm/geometry/label/layout/worker/hide-overlap.js.map +1 -0
  80. package/esm/geometry/label/util/createWorker.d.ts +1 -0
  81. package/esm/geometry/label/util/createWorker.js +16 -0
  82. package/esm/geometry/label/util/createWorker.js.map +1 -0
  83. package/esm/geometry/label/util/index.d.ts +4 -2
  84. package/esm/geometry/label/util/index.js +3 -2
  85. package/esm/geometry/label/util/index.js.map +1 -1
  86. package/esm/geometry/path.js +65 -37
  87. package/esm/geometry/path.js.map +1 -1
  88. package/esm/geometry/shape/interval/tick.js +3 -2
  89. package/esm/geometry/shape/interval/tick.js.map +1 -1
  90. package/esm/geometry/shape/interval/util.js +14 -13
  91. package/esm/geometry/shape/interval/util.js.map +1 -1
  92. package/esm/geometry/shape/point/image.js +22 -11
  93. package/esm/geometry/shape/point/image.js.map +1 -1
  94. package/esm/geometry/shape/point/util.js +17 -7
  95. package/esm/geometry/shape/point/util.js.map +1 -1
  96. package/esm/geometry/shape/util/path.js +3 -1
  97. package/esm/geometry/shape/util/path.js.map +1 -1
  98. package/esm/geometry/util/group-data.js +17 -6
  99. package/esm/geometry/util/group-data.js.map +1 -1
  100. package/esm/index.js +7 -0
  101. package/esm/index.js.map +1 -1
  102. package/esm/interaction/action/active-region.js +42 -14
  103. package/esm/interaction/action/active-region.js.map +1 -1
  104. package/esm/interaction/action/component/axis/axis-description.d.ts +9 -0
  105. package/esm/interaction/action/component/axis/axis-description.js +77 -0
  106. package/esm/interaction/action/component/axis/axis-description.js.map +1 -0
  107. package/esm/interaction/action/component/list-focus.js +50 -13
  108. package/esm/interaction/action/component/list-focus.js.map +1 -1
  109. package/esm/interaction/action/data/filter.js +2 -2
  110. package/esm/interaction/action/data/filter.js.map +1 -1
  111. package/esm/interaction/action/data/range-filter.js +2 -2
  112. package/esm/interaction/action/data/range-filter.js.map +1 -1
  113. package/esm/interaction/action/element/filter.js +2 -2
  114. package/esm/interaction/action/element/filter.js.map +1 -1
  115. package/esm/interface.d.ts +6 -2
  116. package/esm/interface.js.map +1 -1
  117. package/esm/theme/style-sheet/dark.d.ts +2 -0
  118. package/esm/theme/style-sheet/dark.js +2 -0
  119. package/esm/theme/style-sheet/dark.js.map +1 -1
  120. package/esm/theme/style-sheet/light.d.ts +2 -0
  121. package/esm/theme/style-sheet/light.js +2 -0
  122. package/esm/theme/style-sheet/light.js.map +1 -1
  123. package/esm/theme/util/create-by-style-sheet.js +3 -0
  124. package/esm/theme/util/create-by-style-sheet.js.map +1 -1
  125. package/esm/util/attr.js +2 -2
  126. package/esm/util/attr.js.map +1 -1
  127. package/esm/util/bbox.js +3 -2
  128. package/esm/util/bbox.js.map +1 -1
  129. package/esm/util/collision-detect.d.ts +8 -4
  130. package/esm/util/collision-detect.js +13 -11
  131. package/esm/util/collision-detect.js.map +1 -1
  132. package/esm/util/color.js +2 -1
  133. package/esm/util/color.js.map +1 -1
  134. package/esm/util/helper.js +16 -5
  135. package/esm/util/helper.js.map +1 -1
  136. package/esm/util/padding.js +3 -3
  137. package/esm/util/padding.js.map +1 -1
  138. package/esm/util/scale.js +2 -2
  139. package/esm/util/scale.js.map +1 -1
  140. package/esm/util/stat.js +2 -2
  141. package/esm/util/stat.js.map +1 -1
  142. package/esm/util/text.js +2 -2
  143. package/esm/util/text.js.map +1 -1
  144. package/esm/util/tooltip.js +109 -59
  145. package/esm/util/tooltip.js.map +1 -1
  146. package/lib/animate/animation/sector-path-update.js +4 -4
  147. package/lib/animate/animation/sector-path-update.js.map +1 -1
  148. package/lib/animate/animation/util.js +2 -1
  149. package/lib/animate/animation/util.js.map +1 -1
  150. package/lib/animate/animation/wave-in.js +1 -1
  151. package/lib/animate/animation/wave-in.js.map +1 -1
  152. package/lib/animate/animation/zoom.js +1 -1
  153. package/lib/animate/animation/zoom.js.map +1 -1
  154. package/lib/animate/index.js +1 -1
  155. package/lib/animate/index.js.map +1 -1
  156. package/lib/api.js +1 -1
  157. package/lib/api.js.map +1 -1
  158. package/lib/base.js +2 -2
  159. package/lib/base.js.map +1 -1
  160. package/lib/chart/chart.js +4 -4
  161. package/lib/chart/chart.js.map +1 -1
  162. package/lib/chart/controller/annotation.js +52 -42
  163. package/lib/chart/controller/annotation.js.map +1 -1
  164. package/lib/chart/controller/axis.js +4 -4
  165. package/lib/chart/controller/axis.js.map +1 -1
  166. package/lib/chart/controller/coordinate.js +4 -4
  167. package/lib/chart/controller/coordinate.js.map +1 -1
  168. package/lib/chart/controller/gesture.js +1 -1
  169. package/lib/chart/controller/gesture.js.map +1 -1
  170. package/lib/chart/controller/legend.js +3 -3
  171. package/lib/chart/controller/legend.js.map +1 -1
  172. package/lib/chart/controller/scrollbar.js +15 -15
  173. package/lib/chart/controller/scrollbar.js.map +1 -1
  174. package/lib/chart/controller/slider.js +13 -13
  175. package/lib/chart/controller/slider.js.map +1 -1
  176. package/lib/chart/controller/tooltip.js +87 -39
  177. package/lib/chart/controller/tooltip.js.map +1 -1
  178. package/lib/chart/layout/auto.js +1 -1
  179. package/lib/chart/layout/auto.js.map +1 -1
  180. package/lib/chart/layout/constraint/constraint.js +2 -1
  181. package/lib/chart/layout/constraint/constraint.js.map +1 -1
  182. package/lib/chart/layout/constraint/solver.js +2 -1
  183. package/lib/chart/layout/constraint/solver.js.map +1 -1
  184. package/lib/chart/layout/padding-cal.js +3 -3
  185. package/lib/chart/layout/padding-cal.js.map +1 -1
  186. package/lib/chart/view.js +13 -13
  187. package/lib/chart/view.js.map +1 -1
  188. package/lib/component/labels.d.ts +1 -2
  189. package/lib/component/labels.js +137 -106
  190. package/lib/component/labels.js.map +1 -1
  191. package/lib/constant.d.ts +3 -1
  192. package/lib/constant.js +2 -0
  193. package/lib/constant.js.map +1 -1
  194. package/lib/core.d.ts +1 -1
  195. package/lib/core.js +7 -7
  196. package/lib/core.js.map +1 -1
  197. package/lib/facet/circle.js +2 -2
  198. package/lib/facet/circle.js.map +1 -1
  199. package/lib/facet/facet.js +3 -2
  200. package/lib/facet/facet.js.map +1 -1
  201. package/lib/facet/list.js +4 -4
  202. package/lib/facet/list.js.map +1 -1
  203. package/lib/facet/matrix.js +5 -5
  204. package/lib/facet/matrix.js.map +1 -1
  205. package/lib/facet/mirror.js +3 -3
  206. package/lib/facet/mirror.js.map +1 -1
  207. package/lib/facet/rect.js +8 -8
  208. package/lib/facet/rect.js.map +1 -1
  209. package/lib/facet/tree.js +22 -12
  210. package/lib/facet/tree.js.map +1 -1
  211. package/lib/geometry/area.js +2 -2
  212. package/lib/geometry/area.js.map +1 -1
  213. package/lib/geometry/base.d.ts +3 -0
  214. package/lib/geometry/base.js +155 -86
  215. package/lib/geometry/base.js.map +1 -1
  216. package/lib/geometry/edge.js +2 -2
  217. package/lib/geometry/edge.js.map +1 -1
  218. package/lib/geometry/element/index.js +8 -6
  219. package/lib/geometry/element/index.js.map +1 -1
  220. package/lib/geometry/heatmap.js +20 -10
  221. package/lib/geometry/heatmap.js.map +1 -1
  222. package/lib/geometry/interval.js +2 -2
  223. package/lib/geometry/interval.js.map +1 -1
  224. package/lib/geometry/label/base.d.ts +1 -1
  225. package/lib/geometry/label/base.js +22 -10
  226. package/lib/geometry/label/base.js.map +1 -1
  227. package/lib/geometry/label/interval.js +5 -5
  228. package/lib/geometry/label/interval.js.map +1 -1
  229. package/lib/geometry/label/layout/hide-overlap.d.ts +1 -1
  230. package/lib/geometry/label/layout/hide-overlap.js +62 -16
  231. package/lib/geometry/label/layout/hide-overlap.js.map +1 -1
  232. package/lib/geometry/label/layout/interval/hide-overlap.js +3 -2
  233. package/lib/geometry/label/layout/interval/hide-overlap.js.map +1 -1
  234. package/lib/geometry/label/layout/path/adjust-position.js +3 -2
  235. package/lib/geometry/label/layout/path/adjust-position.js.map +1 -1
  236. package/lib/geometry/label/layout/pie/distribute.js +14 -3
  237. package/lib/geometry/label/layout/pie/distribute.js.map +1 -1
  238. package/lib/geometry/label/layout/pie/outer.js +14 -3
  239. package/lib/geometry/label/layout/pie/outer.js.map +1 -1
  240. package/lib/geometry/label/layout/pie/spider.js +14 -3
  241. package/lib/geometry/label/layout/pie/spider.js.map +1 -1
  242. package/lib/geometry/label/layout/point/adjust-position.js +3 -2
  243. package/lib/geometry/label/layout/point/adjust-position.js.map +1 -1
  244. package/lib/geometry/label/layout/worker/hide-overlap.d.ts +2 -0
  245. package/lib/geometry/label/layout/worker/hide-overlap.js +158 -0
  246. package/lib/geometry/label/layout/worker/hide-overlap.js.map +1 -0
  247. package/lib/geometry/label/pie.js +3 -3
  248. package/lib/geometry/label/pie.js.map +1 -1
  249. package/lib/geometry/label/polar.js +4 -4
  250. package/lib/geometry/label/polar.js.map +1 -1
  251. package/lib/geometry/label/util/createWorker.d.ts +1 -0
  252. package/lib/geometry/label/util/createWorker.js +20 -0
  253. package/lib/geometry/label/util/createWorker.js.map +1 -0
  254. package/lib/geometry/label/util/index.d.ts +4 -2
  255. package/lib/geometry/label/util/index.js +5 -4
  256. package/lib/geometry/label/util/index.js.map +1 -1
  257. package/lib/geometry/line.js +2 -2
  258. package/lib/geometry/line.js.map +1 -1
  259. package/lib/geometry/path.js +67 -39
  260. package/lib/geometry/path.js.map +1 -1
  261. package/lib/geometry/point.js +3 -3
  262. package/lib/geometry/point.js.map +1 -1
  263. package/lib/geometry/polygon.js +2 -2
  264. package/lib/geometry/polygon.js.map +1 -1
  265. package/lib/geometry/schema.js +2 -2
  266. package/lib/geometry/schema.js.map +1 -1
  267. package/lib/geometry/shape/base.js +2 -2
  268. package/lib/geometry/shape/base.js.map +1 -1
  269. package/lib/geometry/shape/edge/arc.js +3 -3
  270. package/lib/geometry/shape/edge/arc.js.map +1 -1
  271. package/lib/geometry/shape/edge/index.js +1 -1
  272. package/lib/geometry/shape/edge/index.js.map +1 -1
  273. package/lib/geometry/shape/edge/smooth.js +1 -1
  274. package/lib/geometry/shape/edge/smooth.js.map +1 -1
  275. package/lib/geometry/shape/edge/vhv.js +1 -1
  276. package/lib/geometry/shape/edge/vhv.js.map +1 -1
  277. package/lib/geometry/shape/interval/funnel.js +1 -1
  278. package/lib/geometry/shape/interval/funnel.js.map +1 -1
  279. package/lib/geometry/shape/interval/hollow-rect.js +2 -2
  280. package/lib/geometry/shape/interval/hollow-rect.js.map +1 -1
  281. package/lib/geometry/shape/interval/index.js +2 -2
  282. package/lib/geometry/shape/interval/index.js.map +1 -1
  283. package/lib/geometry/shape/interval/line.js +2 -2
  284. package/lib/geometry/shape/interval/line.js.map +1 -1
  285. package/lib/geometry/shape/interval/pyramid.js +1 -1
  286. package/lib/geometry/shape/interval/pyramid.js.map +1 -1
  287. package/lib/geometry/shape/interval/tick.js +3 -2
  288. package/lib/geometry/shape/interval/tick.js.map +1 -1
  289. package/lib/geometry/shape/interval/util.js +13 -12
  290. package/lib/geometry/shape/interval/util.js.map +1 -1
  291. package/lib/geometry/shape/line/step.js +1 -1
  292. package/lib/geometry/shape/line/step.js.map +1 -1
  293. package/lib/geometry/shape/point/image.js +22 -11
  294. package/lib/geometry/shape/point/image.js.map +1 -1
  295. package/lib/geometry/shape/point/util.js +17 -7
  296. package/lib/geometry/shape/point/util.js.map +1 -1
  297. package/lib/geometry/shape/polygon/index.js +1 -1
  298. package/lib/geometry/shape/polygon/index.js.map +1 -1
  299. package/lib/geometry/shape/polygon/square.js +1 -1
  300. package/lib/geometry/shape/polygon/square.js.map +1 -1
  301. package/lib/geometry/shape/schema/box.js +1 -1
  302. package/lib/geometry/shape/schema/box.js.map +1 -1
  303. package/lib/geometry/shape/schema/candle.js +1 -1
  304. package/lib/geometry/shape/schema/candle.js.map +1 -1
  305. package/lib/geometry/shape/util/get-style.js +1 -1
  306. package/lib/geometry/shape/util/get-style.js.map +1 -1
  307. package/lib/geometry/shape/util/path.js +3 -1
  308. package/lib/geometry/shape/util/path.js.map +1 -1
  309. package/lib/geometry/shape/violin/hollow.js +2 -2
  310. package/lib/geometry/shape/violin/hollow.js.map +1 -1
  311. package/lib/geometry/shape/violin/index.js +1 -1
  312. package/lib/geometry/shape/violin/index.js.map +1 -1
  313. package/lib/geometry/shape/violin/smooth.js +1 -1
  314. package/lib/geometry/shape/violin/smooth.js.map +1 -1
  315. package/lib/geometry/util/group-data.js +17 -6
  316. package/lib/geometry/util/group-data.js.map +1 -1
  317. package/lib/geometry/violin.js +2 -2
  318. package/lib/geometry/violin.js.map +1 -1
  319. package/lib/index.js +76 -69
  320. package/lib/index.js.map +1 -1
  321. package/lib/interaction/action/active-region.js +44 -16
  322. package/lib/interaction/action/active-region.js.map +1 -1
  323. package/lib/interaction/action/callback.js +2 -2
  324. package/lib/interaction/action/callback.js.map +1 -1
  325. package/lib/interaction/action/component/axis/axis-description.d.ts +9 -0
  326. package/lib/interaction/action/component/axis/axis-description.js +79 -0
  327. package/lib/interaction/action/component/axis/axis-description.js.map +1 -0
  328. package/lib/interaction/action/component/list-active.js +2 -2
  329. package/lib/interaction/action/component/list-active.js.map +1 -1
  330. package/lib/interaction/action/component/list-checked.js +2 -2
  331. package/lib/interaction/action/component/list-checked.js.map +1 -1
  332. package/lib/interaction/action/component/list-focus.js +51 -14
  333. package/lib/interaction/action/component/list-focus.js.map +1 -1
  334. package/lib/interaction/action/component/list-highlight.js +2 -2
  335. package/lib/interaction/action/component/list-highlight.js.map +1 -1
  336. package/lib/interaction/action/component/list-radio.js +3 -3
  337. package/lib/interaction/action/component/list-radio.js.map +1 -1
  338. package/lib/interaction/action/component/list-selected.js +2 -2
  339. package/lib/interaction/action/component/list-selected.js.map +1 -1
  340. package/lib/interaction/action/component/list-state.js +2 -2
  341. package/lib/interaction/action/component/list-state.js.map +1 -1
  342. package/lib/interaction/action/component/list-unchecked.js +2 -2
  343. package/lib/interaction/action/component/list-unchecked.js.map +1 -1
  344. package/lib/interaction/action/component/tooltip/ellipsis-text.js +4 -4
  345. package/lib/interaction/action/component/tooltip/ellipsis-text.js.map +1 -1
  346. package/lib/interaction/action/component/tooltip/geometry.js +2 -2
  347. package/lib/interaction/action/component/tooltip/geometry.js.map +1 -1
  348. package/lib/interaction/action/component/tooltip/sibling.js +2 -2
  349. package/lib/interaction/action/component/tooltip/sibling.js.map +1 -1
  350. package/lib/interaction/action/cursor.js +2 -2
  351. package/lib/interaction/action/cursor.js.map +1 -1
  352. package/lib/interaction/action/data/filter.js +3 -3
  353. package/lib/interaction/action/data/filter.js.map +1 -1
  354. package/lib/interaction/action/data/range-filter.js +3 -3
  355. package/lib/interaction/action/data/range-filter.js.map +1 -1
  356. package/lib/interaction/action/data/sibling-filter.js +2 -2
  357. package/lib/interaction/action/data/sibling-filter.js.map +1 -1
  358. package/lib/interaction/action/element/active.js +2 -2
  359. package/lib/interaction/action/element/active.js.map +1 -1
  360. package/lib/interaction/action/element/filter.js +3 -3
  361. package/lib/interaction/action/element/filter.js.map +1 -1
  362. package/lib/interaction/action/element/highlight-by-color.js +2 -2
  363. package/lib/interaction/action/element/highlight-by-color.js.map +1 -1
  364. package/lib/interaction/action/element/highlight-by-x.js +2 -2
  365. package/lib/interaction/action/element/highlight-by-x.js.map +1 -1
  366. package/lib/interaction/action/element/highlight.js +2 -2
  367. package/lib/interaction/action/element/highlight.js.map +1 -1
  368. package/lib/interaction/action/element/link-by-color.js +3 -3
  369. package/lib/interaction/action/element/link-by-color.js.map +1 -1
  370. package/lib/interaction/action/element/range-active.js +2 -2
  371. package/lib/interaction/action/element/range-active.js.map +1 -1
  372. package/lib/interaction/action/element/range-highlight.js +2 -2
  373. package/lib/interaction/action/element/range-highlight.js.map +1 -1
  374. package/lib/interaction/action/element/range-selected.js +2 -2
  375. package/lib/interaction/action/element/range-selected.js.map +1 -1
  376. package/lib/interaction/action/element/range-state.js +2 -2
  377. package/lib/interaction/action/element/range-state.js.map +1 -1
  378. package/lib/interaction/action/element/selected.js +2 -2
  379. package/lib/interaction/action/element/selected.js.map +1 -1
  380. package/lib/interaction/action/element/sibling-filter.js +2 -2
  381. package/lib/interaction/action/element/sibling-filter.js.map +1 -1
  382. package/lib/interaction/action/element/single-active.js +2 -2
  383. package/lib/interaction/action/element/single-active.js.map +1 -1
  384. package/lib/interaction/action/element/single-highlight.js +2 -2
  385. package/lib/interaction/action/element/single-highlight.js.map +1 -1
  386. package/lib/interaction/action/element/single-selected.js +2 -2
  387. package/lib/interaction/action/element/single-selected.js.map +1 -1
  388. package/lib/interaction/action/element/single-state.js +2 -2
  389. package/lib/interaction/action/element/single-state.js.map +1 -1
  390. package/lib/interaction/action/element/state-base.js +2 -2
  391. package/lib/interaction/action/element/state-base.js.map +1 -1
  392. package/lib/interaction/action/element/state.js +2 -2
  393. package/lib/interaction/action/element/state.js.map +1 -1
  394. package/lib/interaction/action/mask/base.js +3 -3
  395. package/lib/interaction/action/mask/base.js.map +1 -1
  396. package/lib/interaction/action/mask/circle.js +2 -2
  397. package/lib/interaction/action/mask/circle.js.map +1 -1
  398. package/lib/interaction/action/mask/dim-rect.js +2 -2
  399. package/lib/interaction/action/mask/dim-rect.js.map +1 -1
  400. package/lib/interaction/action/mask/path.js +2 -2
  401. package/lib/interaction/action/mask/path.js.map +1 -1
  402. package/lib/interaction/action/mask/rect.js +2 -2
  403. package/lib/interaction/action/mask/rect.js.map +1 -1
  404. package/lib/interaction/action/mask/smooth-path.js +2 -2
  405. package/lib/interaction/action/mask/smooth-path.js.map +1 -1
  406. package/lib/interaction/action/register.js +1 -1
  407. package/lib/interaction/action/register.js.map +1 -1
  408. package/lib/interaction/action/view/button.js +4 -4
  409. package/lib/interaction/action/view/button.js.map +1 -1
  410. package/lib/interaction/action/view/drag.js +2 -2
  411. package/lib/interaction/action/view/drag.js.map +1 -1
  412. package/lib/interaction/action/view/mousewheel-scroll.js +1 -1
  413. package/lib/interaction/action/view/mousewheel-scroll.js.map +1 -1
  414. package/lib/interaction/action/view/move.js +1 -1
  415. package/lib/interaction/action/view/move.js.map +1 -1
  416. package/lib/interaction/action/view/scale-transform.js +1 -1
  417. package/lib/interaction/action/view/scale-transform.js.map +1 -1
  418. package/lib/interaction/action/view/scale-translate.js +2 -2
  419. package/lib/interaction/action/view/scale-translate.js.map +1 -1
  420. package/lib/interaction/action/view/scale-zoom.js +2 -2
  421. package/lib/interaction/action/view/scale-zoom.js.map +1 -1
  422. package/lib/interaction/grammar-interaction.js +3 -3
  423. package/lib/interaction/grammar-interaction.js.map +1 -1
  424. package/lib/interaction/index.js +2 -2
  425. package/lib/interaction/index.js.map +1 -1
  426. package/lib/interface.d.ts +6 -2
  427. package/lib/interface.js.map +1 -1
  428. package/lib/theme/style-sheet/dark.d.ts +2 -0
  429. package/lib/theme/style-sheet/dark.js +3 -1
  430. package/lib/theme/style-sheet/dark.js.map +1 -1
  431. package/lib/theme/style-sheet/light.d.ts +2 -0
  432. package/lib/theme/style-sheet/light.js +3 -1
  433. package/lib/theme/style-sheet/light.js.map +1 -1
  434. package/lib/theme/util/create-by-style-sheet.js +11 -8
  435. package/lib/theme/util/create-by-style-sheet.js.map +1 -1
  436. package/lib/theme/util/create-theme.js +1 -1
  437. package/lib/theme/util/create-theme.js.map +1 -1
  438. package/lib/util/attr.js +1 -1
  439. package/lib/util/attr.js.map +1 -1
  440. package/lib/util/bbox.js +3 -2
  441. package/lib/util/bbox.js.map +1 -1
  442. package/lib/util/collision-detect.d.ts +8 -4
  443. package/lib/util/collision-detect.js +14 -12
  444. package/lib/util/collision-detect.js.map +1 -1
  445. package/lib/util/color.js +2 -2
  446. package/lib/util/color.js.map +1 -1
  447. package/lib/util/helper.js +16 -5
  448. package/lib/util/helper.js.map +1 -1
  449. package/lib/util/legend.js +2 -2
  450. package/lib/util/legend.js.map +1 -1
  451. package/lib/util/padding.js +2 -2
  452. package/lib/util/padding.js.map +1 -1
  453. package/lib/util/scale.js +2 -2
  454. package/lib/util/scale.js.map +1 -1
  455. package/lib/util/stat.js +1 -1
  456. package/lib/util/stat.js.map +1 -1
  457. package/lib/util/text.js +1 -1
  458. package/lib/util/text.js.map +1 -1
  459. package/lib/util/tooltip.js +109 -59
  460. package/lib/util/tooltip.js.map +1 -1
  461. package/package.json +2 -2
  462. package/src/chart/chart.ts +1 -1
  463. package/src/component/labels.ts +37 -40
  464. package/src/constant.ts +3 -0
  465. package/src/core.ts +1 -1
  466. package/src/geometry/base.ts +42 -30
  467. package/src/geometry/element/index.ts +2 -2
  468. package/src/geometry/label/base.ts +3 -3
  469. package/src/geometry/label/layout/hide-overlap.ts +73 -21
  470. package/src/geometry/label/layout/path/adjust-position.ts +1 -2
  471. package/src/geometry/label/layout/worker/hide-overlap.ts +192 -0
  472. package/src/geometry/label/util/createWorker.ts +15 -0
  473. package/src/geometry/label/util/index.ts +5 -4
  474. package/src/index.ts +8 -0
  475. package/src/interaction/action/component/axis/axis-description.ts +86 -0
  476. package/src/interface.ts +6 -3
  477. package/src/theme/style-sheet/dark.ts +2 -0
  478. package/src/theme/style-sheet/light.ts +2 -0
  479. package/src/theme/util/create-by-style-sheet.ts +3 -0
  480. package/src/util/collision-detect.ts +24 -14
  481. package/CHANGELOG.md +0 -1331
@@ -1,33 +1,85 @@
1
- import { get } from '@antv/util';
1
+ import { get, each } from '@antv/util';
2
2
  import { BBox, IGroup, IShape } from '../../../dependents';
3
- import { isIntersect } from '../../../util/collision-detect';
3
+ import { intersect } from '../../../util/collision-detect';
4
4
  import { LabelItem } from '../interface';
5
- import { getlLabelBackgroundInfo } from '../util';
5
+ import { getLabelBackgroundInfo } from '../util';
6
+ import { createWorker } from '../util/createWorker';
7
+ import { code as layoutCode } from './worker/hide-overlap';
8
+
9
+ type Item = {
10
+ x: number;
11
+ y: number;
12
+ width: number;
13
+ height: number;
14
+ rotation?: number;
15
+ visible?: boolean;
16
+ };
17
+
18
+ const layout = (items: Item[]): Item[] => {
19
+ const boxes = items.slice();
20
+ for (let i = 0; i < boxes.length; i++) {
21
+ const box1 = boxes[i];
22
+ if (box1.visible) {
23
+ for (let j = i + 1; j < boxes.length; j++) {
24
+ const box2 = boxes[j];
25
+ if (box1 !== box2 && box2.visible) {
26
+ if (intersect(box1, box2)) {
27
+ box2.visible = false;
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ return boxes;
34
+ }
35
+
36
+ const cache: Map<string, any> = new Map();
37
+ const worker = createWorker(layoutCode);
6
38
 
7
39
  /**
8
40
  * label 防遮挡布局:在不改变 label 位置的情况下对相互重叠的 label 进行隐藏(非移除)
9
41
  * 不同于 'overlap' 类型的布局,该布局不会对 label 的位置进行偏移调整。
10
42
  * @param labels 参与布局调整的 label 数组集合
11
43
  */
12
- export function hideOverlap(items: LabelItem[], labels: IGroup[], shapes: IShape[] | IGroup[], region: BBox) {
13
- // todo 添加 labelrank
14
- // each label will hide the next one because the next one always has lower rank.
15
-
16
- // Detect overlapping labels
17
- for (let i = 0; i < labels.length; i++) {
18
- const label1 = labels[i];
19
- if (labels[i].get('visible')) {
20
- for (let j = i + 1; j < labels.length; j++) {
21
- const label2 = labels[j];
22
- if (label1 && label2 && label1 !== label2 && label2.get('visible')) {
23
- const box1 = getlLabelBackgroundInfo(label1, items[i], get(items[i], 'background.padding'));
24
- const box2 = getlLabelBackgroundInfo(label2, items[j], get(items[j], 'background.padding'));
25
-
26
- if (isIntersect(box1, box2)) {
27
- labels[j].set('visible', false);
28
- }
44
+ export function hideOverlap(labelItems: LabelItem[], labels: IGroup[], shapes: IShape[] | IGroup[], region: BBox) {
45
+ // todo 添加 label rank
46
+ return new Promise((resolve) => {
47
+ const boxes = labels.map((d, idx) => ({
48
+ ...getLabelBackgroundInfo(d, labelItems[idx], get(labelItems[idx], 'background.padding')),
49
+ visible: true,
50
+ }));
51
+ const memoKey = JSON.stringify(boxes);
52
+ const cb = (items: Item[]) => {
53
+ cache.set(memoKey, items);
54
+ each(items, ({ visible }, idx) => {
55
+ const labelShape = labels[idx];
56
+ if (visible) {
57
+ labelShape?.show()
58
+ } else {
59
+ labelShape?.hide();
29
60
  }
61
+ });
62
+ return resolve(items);
63
+ }
64
+ if (cache.get(memoKey)) {
65
+ cb(cache.get(memoKey))
66
+ } else if (worker) {
67
+ // Do layout in worker.
68
+ try {
69
+ worker.postMessage(JSON.stringify({ type: 'hide-overlap', items: boxes }));
70
+ worker.onmessage = (e) => cb(Array.isArray(e.data) ? e.data : []);
71
+ worker.onmessageerror = (e) => {
72
+ console.warn('[AntV G2] Web worker is not available');
73
+ // Normal layout in main thread.
74
+ cb(layout(boxes));
75
+ };
76
+ } catch (e) {
77
+ console.error(e);
78
+ cb(layout(boxes));
30
79
  }
80
+ } else {
81
+ // Normal layout in main thread.
82
+ cb(layout(boxes));
31
83
  }
32
- }
84
+ });
33
85
  }
@@ -1,6 +1,5 @@
1
1
  import { groupBy, keys, map } from '@antv/util';
2
- import { IElement, IGroup, IShape, BBox } from '../../../../dependents';
3
- import { isIntersect } from '../../../../util/collision-detect';
2
+ import { IGroup, IShape, BBox } from '../../../../dependents';
4
3
  import Geometry from '../../../base';
5
4
  import Element from '../../../element';
6
5
  import { LabelItem } from '../../interface';
@@ -0,0 +1,192 @@
1
+ const onmessage = function (e) {
2
+ type Item = {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ rotation?: number;
8
+ visible?: boolean;
9
+ };
10
+
11
+ // Copy from src/util/collision-detect.ts
12
+ function generateUtils() {
13
+ type Vec2 = [number, number];
14
+
15
+ type Point = { x: number; y: number };
16
+
17
+ /**
18
+ * 定义投影对象
19
+ */
20
+ type Projection = { min: number; max: number };
21
+
22
+ function dot(a, b) {
23
+ return (a[0] || 0) * (b[0] || 0) + (a[1] || 0) * (b[1] || 0) + (a[2] || 0) * (b[2] || 0);
24
+ }
25
+ /**
26
+ * 1. 获取投影轴
27
+ */
28
+ function getAxes(points: Point[] /** 多边形的关键点 */): Vec2[] {
29
+ // 目前先处理 平行矩形 的场景, 其他多边形不处理
30
+ if (points.length > 4) {
31
+ return [];
32
+ }
33
+ // 获取向量
34
+ const vector = (start: Point, end: Point): Vec2 => {
35
+ return [end.x - start.x, end.y - start.y];
36
+ };
37
+
38
+ // 由于 矩形的平行原理,所以只有 2 条投影轴: A -> B, B -> C
39
+ const AB = vector(points[0], points[1]);
40
+ const BC = vector(points[1], points[2]);
41
+
42
+ return [AB, BC];
43
+ }
44
+
45
+ /**
46
+ * 绕指定点顺时针旋转后的点坐标
47
+ * 默认绕原点旋转
48
+ */
49
+ function rotateAtPoint(point: Point, deg = 0, origin = { x: 0, y: 0 }): Point {
50
+ const { x, y } = point;
51
+ return {
52
+ x: (x - origin.x) * Math.cos(-deg) + (y - origin.y) * Math.sin(-deg) + origin.x,
53
+ y: (origin.x - x) * Math.sin(-deg) + (y - origin.y) * Math.cos(-deg) + origin.y,
54
+ };
55
+ }
56
+
57
+ /**
58
+ * @private
59
+ * 转化为顶点坐标数组
60
+ *
61
+ * @param {Object} box
62
+ */
63
+ function getRectPoints(box: Item): Point[] {
64
+ const points = [
65
+ { x: box.x, y: box.y },
66
+ { x: box.x + box.width, y: box.y },
67
+ { x: box.x + box.width, y: box.y + box.height },
68
+ { x: box.x, y: box.y + box.height },
69
+ ];
70
+
71
+ const rotation = box.rotation;
72
+ if (rotation) {
73
+ return [
74
+ rotateAtPoint(points[0], rotation, points[0]),
75
+ rotateAtPoint(points[1], rotation, points[0]),
76
+ rotateAtPoint(points[2], rotation, points[0]),
77
+ rotateAtPoint(points[3], rotation, points[0]),
78
+ ];
79
+ }
80
+
81
+ return points;
82
+ }
83
+
84
+ /**
85
+ * 2. 获取多边形在投影轴上的投影
86
+ *
87
+ * 向量的点积的其中一个几何含义是:一个向量在平行于另一个向量方向上的投影的数值乘积。
88
+ * 由于投影轴是单位向量(长度为1),投影的长度为 x1 * x2 + y1 * y2
89
+ */
90
+ function getProjection(points: Point[] /** 多边形的关键点 */, axis: Vec2): Projection {
91
+ // 目前先处理矩形的场景
92
+ if (points.length > 4) {
93
+ return { min: 0, max: 0 };
94
+ }
95
+
96
+ const scalars = [];
97
+ points.forEach((point) => {
98
+ scalars.push(dot([point.x, point.y], axis));
99
+ });
100
+
101
+ return { min: Math.min.apply(null, scalars), max: Math.max.apply(null, scalars) };
102
+ }
103
+
104
+ function isProjectionOverlap(projection1: Projection, projection2: Projection): boolean {
105
+ return projection1.max > projection2.min && projection1.min < projection2.max;
106
+ }
107
+
108
+ function isValidNumber(d: number) {
109
+ return typeof d === 'number' && !Number.isNaN(d) && d !== Infinity && d !== -Infinity;
110
+ }
111
+
112
+ function isValidBox(box: Item) {
113
+ return ['x', 'y', 'width', 'height'].every(attr => isValidNumber(box[attr]))
114
+ }
115
+
116
+ function isIntersectRect(box1: Item, box2: Item, margin: number = 0): boolean {
117
+ return !(
118
+ box2.x > box1.x + box1.width + margin ||
119
+ box2.x + box2.width < box1.x - margin ||
120
+ box2.y > box1.y + box1.height + margin ||
121
+ box2.y + box2.height < box1.y - margin
122
+ );
123
+ }
124
+ function intersect(box1: Item, box2: Item, margin: number = 0) {
125
+ if (!isValidBox(box1) || !isValidBox(box2)) return false;
126
+
127
+ // Quick detect, if rotation is null or zero.
128
+ if (!box1.rotation && !box2.rotation) {
129
+ return isIntersectRect(box1, box2, margin);
130
+ }
131
+
132
+ // 分别获取 4 个关键点
133
+ const rect1Points = getRectPoints(box1);
134
+ const rect2Points = getRectPoints(box2);
135
+
136
+ // 获取所有投影轴
137
+ const axes = getAxes(rect1Points).concat(getAxes(rect2Points));
138
+
139
+ for (let i = 0; i < axes.length; i++) {
140
+ const axis = axes[i];
141
+ const projection1 = getProjection(rect1Points, axis);
142
+ const projection2 = getProjection(rect2Points, axis);
143
+
144
+ if (!isProjectionOverlap(projection1, projection2)) return false;
145
+ }
146
+
147
+ return true;
148
+ }
149
+ return { intersect }
150
+ }
151
+ const { intersect } = generateUtils();
152
+
153
+ // Label layouts.
154
+ function hideOverlap(items: Item[]) {
155
+ const boxes = items.slice();
156
+ for (let i = 0; i < boxes.length; i++) {
157
+ const box1 = boxes[i];
158
+ if (box1.visible) {
159
+ for (let j = i + 1; j < boxes.length; j++) {
160
+ const box2 = boxes[j];
161
+ if (box1 !== box2 && box2.visible) {
162
+ if (intersect(box1, box2)) {
163
+ box2.visible = false;
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+ return boxes;
170
+ }
171
+
172
+ const methods = {
173
+ 'hide-overlap': hideOverlap,
174
+ }
175
+
176
+ // Main
177
+ try {
178
+ const eventData = JSON.parse(e.data);
179
+ if (!eventData || !eventData.type || !methods[eventData.type]) return;
180
+
181
+ const { type, items } = eventData;
182
+ const result = methods[type](items);
183
+ self.postMessage(result);
184
+ } catch (e) {
185
+ throw e;
186
+ }
187
+ }
188
+
189
+ const code = `
190
+ self.onmessage = ${onmessage.toString()}
191
+ `
192
+ export { code };
@@ -0,0 +1,15 @@
1
+ export function createWorker(f: any) {
2
+ if (typeof window === "undefined") return;
3
+
4
+ let blob;
5
+ try {
6
+ blob = new Blob([f.toString()], { type: 'application/javascript' });
7
+ } catch (e) {
8
+ // @ts-ignore
9
+ blob = new window.BlobBuilder();
10
+ blob.append(f.toString());
11
+ blob = blob.getBlob();
12
+ }
13
+
14
+ return new Worker(URL.createObjectURL(blob));
15
+ }
@@ -5,7 +5,6 @@
5
5
  import { isNil, isNumber, some } from '@antv/util';
6
6
  import { IElement, IGroup, BBox } from '../../../dependents';
7
7
  import { rotate } from '../../../util/transform';
8
- import { LabelItem } from '../interface';
9
8
 
10
9
  /**
11
10
  * 查找 Label Group 中的文本 shape 对象
@@ -18,12 +17,12 @@ export function findLabelTextShape(label: IGroup): IElement {
18
17
  /**
19
18
  * 获取标签背景信息: box (无旋转) + rotation (旋转角度)
20
19
  */
21
- export function getlLabelBackgroundInfo(
20
+ export function getLabelBackgroundInfo(
22
21
  labelGroup: IGroup,
23
- labelItem: LabelItem,
22
+ labelItem: { rotate?: number;[key: string]: any },
24
23
  padding: number | number[] = [0, 0, 0, 0]
25
24
  ): { x: number; y: number; width: number; height: number; rotation: number } {
26
- const content = labelGroup.getChildren()[0];
25
+ const content = labelGroup && labelGroup.getChildren()[0];
27
26
  if (content) {
28
27
  const labelShape = content.clone();
29
28
 
@@ -52,6 +51,8 @@ export function getlLabelBackgroundInfo(
52
51
  rotation: labelItem?.rotate || 0,
53
52
  };
54
53
  }
54
+
55
+ return { x: 0, y: 0, width: 0, height: 0, rotation: 0 };
55
56
  }
56
57
 
57
58
  /**
package/src/index.ts CHANGED
@@ -220,6 +220,7 @@ import ViewMove from './interaction/action/view/move';
220
220
  import ScaleTranslate from './interaction/action/view/scale-translate';
221
221
  import ScaleZoom from './interaction/action/view/scale-zoom';
222
222
  import MousewheelScroll from './interaction/action/view/mousewheel-scroll';
223
+ import AxisDescription from './interaction/action/component/axis/axis-description'
223
224
 
224
225
  registerAction('tooltip', TooltipAction);
225
226
  registerAction('sibling-tooltip', SiblingTooltip);
@@ -260,6 +261,7 @@ registerAction('legend-item-highlight', ListHighlight, {
260
261
  registerAction('axis-label-highlight', ListHighlight, {
261
262
  componentNames: ['axis'],
262
263
  });
264
+ registerAction('axis-description', AxisDescription)
263
265
 
264
266
  registerAction('rect-mask', RectMask);
265
267
  registerAction('x-rect-mask', DimMask, { dim: 'x' });
@@ -615,6 +617,12 @@ registerInteraction('active-region', {
615
617
  end: [{ trigger: 'plot:mouseleave', action: 'active-region:hide' }],
616
618
  });
617
619
 
620
+ // 显示坐标轴标题详情信息
621
+ registerInteraction('axis-description', {
622
+ start: [{ trigger: 'axis-description:mousemove', action: 'axis-description:show' }],
623
+ end: [{ trigger: 'axis-description:mouseleave', action: 'axis-description:hide' }]
624
+ })
625
+
618
626
  function isWheelDown(event) {
619
627
  event.gEvent.preventDefault();
620
628
  return event.gEvent.originalEvent.deltaY > 0;
@@ -0,0 +1,86 @@
1
+ import { TOOLTIP_CSS_CONST } from "@antv/component";
2
+ import { deepMix } from "@antv/util";
3
+ import { HtmlTooltip } from "../../../../dependents";
4
+ import Action from "../../base";
5
+ import { getDelegationObject } from "../../util";
6
+
7
+ const AXIS_DESCRIPTION_TOOLTIP = 'aixs-description-tooltip'
8
+
9
+ class AxisDescription extends Action {
10
+ private tooltip;
11
+
12
+ public show() {
13
+ const context = this.context;
14
+ const { axis } = getDelegationObject(context);
15
+ const { description, text } = axis.cfg.title;
16
+ const { x, y } = context.event;
17
+ if(!this.tooltip) {
18
+ this.renderTooltip()
19
+ };
20
+ this.tooltip.update({
21
+ title: text || '',
22
+ customContent: () => {
23
+ return (`
24
+ <div class="${TOOLTIP_CSS_CONST.CONTAINER_CLASS}">
25
+ <div class="${TOOLTIP_CSS_CONST.TITLE_CLASS}">
26
+ ${text}
27
+ </div>
28
+ <div class="${TOOLTIP_CSS_CONST.LIST_CLASS}">
29
+ ${description}
30
+ </div>
31
+ </div>
32
+ `)
33
+ },
34
+ x,
35
+ y
36
+ });
37
+ this.tooltip.show()
38
+ }
39
+
40
+ public destroy() {
41
+ super.destroy();
42
+ this.tooltip && this.tooltip.destroy();
43
+ }
44
+
45
+ public hide() {
46
+ this.tooltip && this.tooltip.hide()
47
+ }
48
+
49
+ public renderTooltip() {
50
+ const view = this.context.view;
51
+ const canvas = view.canvas;
52
+ const region = {
53
+ start: { x: 0, y: 0 },
54
+ end: { x: canvas.get('width'), y: canvas.get('height') },
55
+ };
56
+ const tooltip = new HtmlTooltip({
57
+ parent: canvas.get('el').parentNode,
58
+ region,
59
+ visible: false,
60
+ containerId: AXIS_DESCRIPTION_TOOLTIP,
61
+ domStyles: {
62
+ ...deepMix({}, {
63
+ // 超长的时候,tooltip tip 最大宽度为 50%,然后可以换行
64
+ [TOOLTIP_CSS_CONST.CONTAINER_CLASS]: {
65
+ 'max-width': '50%',
66
+ 'padding': '5px',
67
+ 'line-height': '15px'
68
+ },
69
+ [TOOLTIP_CSS_CONST.TITLE_CLASS]: {
70
+ 'word-break': 'break-all',
71
+ 'font-size': '14px',
72
+ 'margin-bottom': '3px'
73
+ },
74
+ [TOOLTIP_CSS_CONST.LIST_CLASS]: {
75
+ 'word-break': 'break-all',
76
+ 'opacity': '.5'
77
+ }
78
+ }),
79
+ },
80
+ });
81
+ tooltip.init();
82
+ tooltip.setCapture(false);
83
+ this.tooltip = tooltip
84
+ }
85
+ }
86
+ export default AxisDescription
package/src/interface.ts CHANGED
@@ -1066,8 +1066,8 @@ export interface ScaleOption extends ScaleConfig {
1066
1066
  */
1067
1067
  sync?: boolean | string;
1068
1068
  /**
1069
- * @title 是否显示最后日期
1070
- * @description 只对 type: 'time' 的 scale 生效,强制显示最后的日期 tick。
1069
+ * @title 是否显示最后的 tick
1070
+ * @description 只对 `type: 'cat'` 以及 `type: 'time-cat'` 的 scale 生效,强制显示最后的日期 tick。
1071
1071
  */
1072
1072
  showLast?: boolean;
1073
1073
  /**
@@ -2768,7 +2768,10 @@ export interface StyleSheet {
2768
2768
  * @title 坐标轴标题距离坐标轴文本的间距
2769
2769
  */
2770
2770
  axisTitleSpacing?: number;
2771
-
2771
+ /**
2772
+ * @title 坐标轴详细说明icon颜色
2773
+ */
2774
+ axisDescriptionIconFillColor?: string;
2772
2775
  /**
2773
2776
  * @title 坐标轴刻度线颜色
2774
2777
  */
@@ -117,6 +117,8 @@ export const createDarkStyleSheet = (cfg: StyleSheetCfg = {}) => {
117
117
  axisTitleTextFontWeight: 'normal',
118
118
  /** 坐标轴标题距离坐标轴文本的间距 */
119
119
  axisTitleSpacing: 12,
120
+ /** 坐标轴标题详细说明icon颜色 */
121
+ axisDescriptionIconFillColor: WHITE_COLORS[85],
120
122
 
121
123
  /** 坐标轴刻度线颜色 */
122
124
  axisTickLineBorderColor: BLACK_COLORS[25],
@@ -117,6 +117,8 @@ export const createLightStyleSheet = (cfg: StyleSheetCfg = {}) => {
117
117
  axisTitleTextFontWeight: 'normal',
118
118
  /** 坐标轴标题距离坐标轴文本的间距 */
119
119
  axisTitleSpacing: 12,
120
+ /** 坐标轴标题详细说明icon颜色 */
121
+ axisDescriptionIconFillColor: WHITE_COLORS[85],
120
122
 
121
123
  /** 坐标轴刻度线颜色 */
122
124
  axisTickLineBorderColor: BLACK_COLORS[25],
@@ -22,6 +22,9 @@ function createAxisStyles(styleSheet: StyleSheet): LooseObject {
22
22
  textBaseline: 'middle',
23
23
  fontFamily: styleSheet.fontFamily,
24
24
  },
25
+ iconStyle: {
26
+ fill: styleSheet.axisDescriptionIconFillColor
27
+ }
25
28
  },
26
29
  label: {
27
30
  autoRotate: false,
@@ -1,17 +1,25 @@
1
1
  import { isNumber } from '@antv/util';
2
- import { vec2 } from '@antv/matrix-util';
3
- import { BBox, Point } from '../dependents';
2
+ import { Point } from '../dependents';
4
3
 
5
- const { dot } = vec2;
6
4
  type Vec2 = [number, number];
7
5
 
8
- type Box = Pick<BBox, 'x' | 'y' | 'width' | 'height'> & { rotation?: number };
9
-
6
+ type Item = {
7
+ x: number;
8
+ y: number;
9
+ width: number;
10
+ height: number;
11
+ rotation?: number;
12
+ visible?: boolean;
13
+ };
10
14
  /**
11
15
  * 定义投影对象
12
16
  */
13
17
  type Projection = { min: number; max: number };
14
18
 
19
+ function dot(a, b) {
20
+ return (a[0] || 0) * (b[0] || 0) + (a[1] || 0) * (b[1] || 0) + (a[2] || 0) * (b[2] || 0);
21
+ }
22
+
15
23
  /**
16
24
  * @private
17
25
  * 1. 获取投影轴
@@ -52,7 +60,7 @@ function rotateAtPoint(point: Point, deg = 0, origin = { x: 0, y: 0 }): Point {
52
60
  *
53
61
  * @param {Object} box
54
62
  */
55
- function getRectPoints(box: Box): Point[] {
63
+ function getRectPoints(box: Item): Point[] {
56
64
  const points = [
57
65
  { x: box.x, y: box.y },
58
66
  { x: box.x + box.width, y: box.y },
@@ -99,17 +107,17 @@ function isProjectionOverlap(projection1: Projection, projection2: Projection):
99
107
  }
100
108
 
101
109
  function isValidNumber(d: number) {
102
- return isNumber(d) && !Number.isNaN(d) && d !== Infinity && d !== -Infinity;
110
+ return typeof d === 'number' && !Number.isNaN(d) && d !== Infinity && d !== -Infinity;
103
111
  }
104
112
 
105
- function isValidBox(box: Box) {
106
- return Object.values(box).every(isValidNumber);
113
+ function isValidBox(box: Item) {
114
+ return ['x', 'y', 'width', 'height'].every(attr => isValidNumber(box[attr]))
107
115
  }
108
116
 
109
117
  /**
110
118
  * 快速判断两个无旋转矩形是否遮挡
111
119
  */
112
- export function isIntersectRect(box1: Box, box2: Box, margin: number = 0): boolean {
120
+ export function isIntersectRect(box1: Item, box2: Item, margin: number = 0): boolean {
113
121
  return !(
114
122
  box2.x > box1.x + box1.width + margin ||
115
123
  box2.x + box2.width < box1.x - margin ||
@@ -124,13 +132,13 @@ export function isIntersectRect(box1: Box, box2: Box, margin: number = 0): boole
124
132
  *
125
133
  * - 原理: 分离轴定律
126
134
  */
127
- export function isIntersect(box1: Box, box2: Box) {
135
+ export function intersect(box1: Item, box2: Item, margin: number = 0) {
128
136
  // 如果两个 box 中有一个是不合法的 box,也就是不会被渲染出来的,那么它们就不相交。
129
137
  if (!isValidBox(box1) || !isValidBox(box2)) return false;
130
138
 
131
139
  // 如果两个矩形没有旋转,使用快速判断
132
140
  if (!box1.rotation && !box2.rotation) {
133
- return isIntersectRect(box1, box2);
141
+ return isIntersectRect(box1, box2, margin);
134
142
  }
135
143
 
136
144
  // 分别获取 4 个关键点
@@ -138,7 +146,7 @@ export function isIntersect(box1: Box, box2: Box) {
138
146
  const rect2Points = getRectPoints(box2);
139
147
 
140
148
  // 获取所有投影轴
141
- const axes = [...getAxes(rect1Points), ...getAxes(rect2Points)];
149
+ const axes = getAxes(rect1Points).concat(getAxes(rect2Points));
142
150
 
143
151
  for (let i = 0; i < axes.length; i++) {
144
152
  const axis = axes[i];
@@ -146,7 +154,9 @@ export function isIntersect(box1: Box, box2: Box) {
146
154
  const projection2 = getProjection(rect2Points, axis);
147
155
 
148
156
  // 判断投影轴上的投影是否存在重叠,若检测到存在间隙则立刻退出判断,消除不必要的运算。
149
- if (!isProjectionOverlap(projection1, projection2)) return false;
157
+ if (!isProjectionOverlap(projection1, projection2)) {
158
+ return false;
159
+ }
150
160
  }
151
161
 
152
162
  return true;