@antv/g2 5.2.10 → 5.2.12

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 (493) hide show
  1. package/README.md +2 -2
  2. package/README.zh-CN.md +2 -2
  3. package/dist/g2.lite.min.js +22 -22
  4. package/dist/g2.min.js +22 -22
  5. package/esm/animation/scaleInY.js +2 -20
  6. package/esm/animation/scaleInY.js.map +1 -1
  7. package/esm/animation/waveIn.js +1 -1
  8. package/esm/animation/waveIn.js.map +1 -1
  9. package/esm/api/runtime.js +2 -1
  10. package/esm/api/runtime.js.map +1 -1
  11. package/esm/component/axis.js +2 -2
  12. package/esm/component/axis.js.map +1 -1
  13. package/esm/component/legendCategory.js +6 -2
  14. package/esm/component/legendCategory.js.map +1 -1
  15. package/esm/component/legendContinuous.js +1 -1
  16. package/esm/component/legendContinuous.js.map +1 -1
  17. package/esm/component/slider.js +1 -1
  18. package/esm/component/slider.js.map +1 -1
  19. package/esm/composition/d3Projection.d.ts +1 -1
  20. package/esm/composition/d3Projection.js +1 -1
  21. package/esm/composition/d3Projection.js.map +1 -1
  22. package/esm/composition/facetRect.js +1 -1
  23. package/esm/composition/facetRect.js.map +1 -1
  24. package/esm/composition/geoView.js +1 -1
  25. package/esm/composition/geoView.js.map +1 -1
  26. package/esm/data/cluster.d.ts +1 -1
  27. package/esm/data/cluster.js +1 -1
  28. package/esm/data/cluster.js.map +1 -1
  29. package/esm/data/fetch.js +1 -1
  30. package/esm/data/fetch.js.map +1 -1
  31. package/esm/data/join.js +1 -1
  32. package/esm/data/join.js.map +1 -1
  33. package/esm/data/kde.js +1 -1
  34. package/esm/data/kde.js.map +1 -1
  35. package/esm/data/tree.js +1 -1
  36. package/esm/data/tree.js.map +1 -1
  37. package/esm/data/utils/arc/arc.d.ts +25 -2
  38. package/esm/data/utils/arc/arc.js +1 -1
  39. package/esm/data/utils/arc/arc.js.map +1 -1
  40. package/esm/data/utils/arc/types.d.ts +27 -2
  41. package/esm/data/utils/d3-sankey/align.js +1 -1
  42. package/esm/data/utils/d3-sankey/align.js.map +1 -1
  43. package/esm/data/utils/d3-sankey/sankey.js +1 -1
  44. package/esm/data/utils/d3-sankey/sankey.js.map +1 -1
  45. package/esm/data/wordCloud.js +1 -1
  46. package/esm/data/wordCloud.js.map +1 -1
  47. package/esm/exports.d.ts +2 -0
  48. package/esm/exports.js +2 -0
  49. package/esm/exports.js.map +1 -1
  50. package/esm/index.d.ts +2 -0
  51. package/esm/interaction/chartIndex.js +1 -1
  52. package/esm/interaction/chartIndex.js.map +1 -1
  53. package/esm/interaction/elementHighlight.js +1 -1
  54. package/esm/interaction/elementHighlight.js.map +1 -1
  55. package/esm/interaction/elementSelect.d.ts +1 -0
  56. package/esm/interaction/elementSelect.js +32 -3
  57. package/esm/interaction/elementSelect.js.map +1 -1
  58. package/esm/interaction/event.d.ts +0 -1
  59. package/esm/interaction/event.js +2 -13
  60. package/esm/interaction/event.js.map +1 -1
  61. package/esm/interaction/legendHighlight.js +1 -1
  62. package/esm/interaction/legendHighlight.js.map +1 -1
  63. package/esm/interaction/tooltip.js +8 -35
  64. package/esm/interaction/tooltip.js.map +1 -1
  65. package/esm/interaction/treemapDrillDown.d.ts +2 -2
  66. package/esm/interaction/treemapDrillDown.js.map +1 -1
  67. package/esm/interaction/utils.js +2 -2
  68. package/esm/interaction/utils.js.map +1 -1
  69. package/esm/label-transform/contrastReverse.js +1 -1
  70. package/esm/label-transform/contrastReverse.js.map +1 -1
  71. package/esm/label-transform/overlapDodgeY.js +1 -1
  72. package/esm/label-transform/overlapDodgeY.js.map +1 -1
  73. package/esm/lib/core.d.ts +1 -0
  74. package/esm/lib/core.js +2 -1
  75. package/esm/lib/core.js.map +1 -1
  76. package/esm/lib/std.d.ts +1 -0
  77. package/esm/mark/area.js +1 -1
  78. package/esm/mark/area.js.map +1 -1
  79. package/esm/mark/boxplot.js +1 -1
  80. package/esm/mark/boxplot.js.map +1 -1
  81. package/esm/mark/forceGraph.js +1 -1
  82. package/esm/mark/forceGraph.js.map +1 -1
  83. package/esm/mark/line.js +1 -1
  84. package/esm/mark/line.js.map +1 -1
  85. package/esm/mark/pack.js +1 -1
  86. package/esm/mark/pack.js.map +1 -1
  87. package/esm/mark/utils.d.ts +1 -1
  88. package/esm/runtime/component.js +2 -2
  89. package/esm/runtime/component.js.map +1 -1
  90. package/esm/runtime/layout.js +1 -1
  91. package/esm/runtime/layout.js.map +1 -1
  92. package/esm/runtime/mark.js +1 -1
  93. package/esm/runtime/mark.js.map +1 -1
  94. package/esm/runtime/plot.js +2 -2
  95. package/esm/runtime/plot.js.map +1 -1
  96. package/esm/runtime/scale.js +2 -2
  97. package/esm/runtime/scale.js.map +1 -1
  98. package/esm/runtime/transform.d.ts +1 -0
  99. package/esm/runtime/transform.js +3 -2
  100. package/esm/runtime/transform.js.map +1 -1
  101. package/esm/runtime/types/mark.d.ts +1 -1
  102. package/esm/shape/area/area.js +1 -1
  103. package/esm/shape/area/area.js.map +1 -1
  104. package/esm/shape/area/curve.d.ts +1 -1
  105. package/esm/shape/area/curve.js +1 -1
  106. package/esm/shape/area/curve.js.map +1 -1
  107. package/esm/shape/area/hv.js +1 -1
  108. package/esm/shape/area/hv.js.map +1 -1
  109. package/esm/shape/area/hvh.js +1 -1
  110. package/esm/shape/area/hvh.js.map +1 -1
  111. package/esm/shape/area/smooth.js +1 -1
  112. package/esm/shape/area/smooth.js.map +1 -1
  113. package/esm/shape/area/vh.js +1 -1
  114. package/esm/shape/area/vh.js.map +1 -1
  115. package/esm/shape/box/box.js +1 -1
  116. package/esm/shape/box/box.js.map +1 -1
  117. package/esm/shape/box/violin.js +1 -1
  118. package/esm/shape/box/violin.js.map +1 -1
  119. package/esm/shape/connector/connector.js +1 -1
  120. package/esm/shape/connector/connector.js.map +1 -1
  121. package/esm/shape/density/density.js +1 -1
  122. package/esm/shape/density/density.js.map +1 -1
  123. package/esm/shape/heatmap/heatmap.js +2 -2
  124. package/esm/shape/heatmap/heatmap.js.map +1 -1
  125. package/esm/shape/interval/color.js +1 -1
  126. package/esm/shape/interval/color.js.map +1 -1
  127. package/esm/shape/interval/funnel.js +1 -1
  128. package/esm/shape/interval/funnel.js.map +1 -1
  129. package/esm/shape/label/position/area.js +1 -1
  130. package/esm/shape/label/position/area.js.map +1 -1
  131. package/esm/shape/label/position/utils.js +1 -1
  132. package/esm/shape/label/position/utils.js.map +1 -1
  133. package/esm/shape/line/curve.d.ts +1 -1
  134. package/esm/shape/line/curve.js +1 -1
  135. package/esm/shape/line/curve.js.map +1 -1
  136. package/esm/shape/line/hv.js +1 -1
  137. package/esm/shape/line/hv.js.map +1 -1
  138. package/esm/shape/line/hvh.js +1 -1
  139. package/esm/shape/line/hvh.js.map +1 -1
  140. package/esm/shape/line/line.js +1 -1
  141. package/esm/shape/line/line.js.map +1 -1
  142. package/esm/shape/line/smooth.js +1 -1
  143. package/esm/shape/line/smooth.js.map +1 -1
  144. package/esm/shape/line/trail.js +1 -1
  145. package/esm/shape/line/trail.js.map +1 -1
  146. package/esm/shape/line/vh.js +1 -1
  147. package/esm/shape/line/vh.js.map +1 -1
  148. package/esm/shape/lineXY/line.js +1 -1
  149. package/esm/shape/lineXY/line.js.map +1 -1
  150. package/esm/shape/link/arc.js +1 -1
  151. package/esm/shape/link/arc.js.map +1 -1
  152. package/esm/shape/link/smooth.js +1 -1
  153. package/esm/shape/link/smooth.js.map +1 -1
  154. package/esm/shape/link/vhv.js +1 -1
  155. package/esm/shape/link/vhv.js.map +1 -1
  156. package/esm/shape/polygon/polygon.js +1 -1
  157. package/esm/shape/polygon/polygon.js.map +1 -1
  158. package/esm/shape/polygon/ribbon.js +1 -1
  159. package/esm/shape/polygon/ribbon.js.map +1 -1
  160. package/esm/shape/text/advance.js +1 -1
  161. package/esm/shape/text/advance.js.map +1 -1
  162. package/esm/shape/utils.d.ts +1 -1
  163. package/esm/shape/utils.js +1 -1
  164. package/esm/shape/utils.js.map +1 -1
  165. package/esm/shape/vector/vector.js +1 -1
  166. package/esm/shape/vector/vector.js.map +1 -1
  167. package/esm/spec/interaction.d.ts +1 -0
  168. package/esm/transform/bin.js +1 -1
  169. package/esm/transform/bin.js.map +1 -1
  170. package/esm/transform/flexX.js +1 -1
  171. package/esm/transform/flexX.js.map +1 -1
  172. package/esm/transform/groupN.js +1 -1
  173. package/esm/transform/groupN.js.map +1 -1
  174. package/esm/transform/normalizeY.js +1 -1
  175. package/esm/transform/normalizeY.js.map +1 -1
  176. package/esm/transform/sample.js +1 -1
  177. package/esm/transform/sample.js.map +1 -1
  178. package/esm/transform/select.js +1 -1
  179. package/esm/transform/select.js.map +1 -1
  180. package/esm/transform/sort.d.ts +1 -1
  181. package/esm/transform/sort.js +20 -52
  182. package/esm/transform/sort.js.map +1 -1
  183. package/esm/transform/stackEnter.js +1 -1
  184. package/esm/transform/stackEnter.js.map +1 -1
  185. package/esm/transform/symmetryY.js +1 -1
  186. package/esm/transform/symmetryY.js.map +1 -1
  187. package/esm/transform/utils/order.d.ts +1 -1
  188. package/esm/transform/utils/order.js +1 -1
  189. package/esm/transform/utils/order.js.map +1 -1
  190. package/esm/utils/bounds.d.ts +4 -2
  191. package/esm/utils/bounds.js +11 -4
  192. package/esm/utils/bounds.js.map +1 -1
  193. package/esm/utils/helper.d.ts +24 -0
  194. package/esm/utils/helper.js +76 -0
  195. package/esm/utils/helper.js.map +1 -1
  196. package/esm/utils/scale.js +1 -1
  197. package/esm/utils/scale.js.map +1 -1
  198. package/esm/utils/selection.js +1 -1
  199. package/esm/utils/selection.js.map +1 -1
  200. package/esm/utils/treeDataTransform.d.ts +9 -2
  201. package/esm/utils/treeDataTransform.js +6 -2
  202. package/esm/utils/treeDataTransform.js.map +1 -1
  203. package/lib/animation/scaleInY.js +1 -19
  204. package/lib/animation/scaleInY.js.map +1 -1
  205. package/lib/animation/waveIn.js +1 -1
  206. package/lib/animation/waveIn.js.map +1 -1
  207. package/lib/api/runtime.js +2 -1
  208. package/lib/api/runtime.js.map +1 -1
  209. package/lib/component/axis.js +2 -2
  210. package/lib/component/axis.js.map +1 -1
  211. package/lib/component/legendCategory.js +6 -2
  212. package/lib/component/legendCategory.js.map +1 -1
  213. package/lib/component/legendContinuous.js +1 -1
  214. package/lib/component/legendContinuous.js.map +1 -1
  215. package/lib/component/slider.js +1 -1
  216. package/lib/component/slider.js.map +1 -1
  217. package/lib/composition/d3Projection.d.ts +1 -1
  218. package/lib/composition/d3Projection.js +1 -1
  219. package/lib/composition/d3Projection.js.map +1 -1
  220. package/lib/composition/facetRect.js +1 -1
  221. package/lib/composition/facetRect.js.map +1 -1
  222. package/lib/composition/geoView.js +1 -1
  223. package/lib/composition/geoView.js.map +1 -1
  224. package/lib/data/cluster.d.ts +1 -1
  225. package/lib/data/cluster.js +1 -1
  226. package/lib/data/cluster.js.map +1 -1
  227. package/lib/data/fetch.js +1 -1
  228. package/lib/data/fetch.js.map +1 -1
  229. package/lib/data/join.js +1 -1
  230. package/lib/data/join.js.map +1 -1
  231. package/lib/data/kde.js +1 -1
  232. package/lib/data/kde.js.map +1 -1
  233. package/lib/data/tree.js +1 -1
  234. package/lib/data/tree.js.map +1 -1
  235. package/lib/data/utils/arc/arc.d.ts +25 -2
  236. package/lib/data/utils/arc/arc.js +1 -1
  237. package/lib/data/utils/arc/arc.js.map +1 -1
  238. package/lib/data/utils/arc/types.d.ts +27 -2
  239. package/lib/data/utils/d3-sankey/align.js +1 -1
  240. package/lib/data/utils/d3-sankey/align.js.map +1 -1
  241. package/lib/data/utils/d3-sankey/sankey.js +1 -1
  242. package/lib/data/utils/d3-sankey/sankey.js.map +1 -1
  243. package/lib/data/wordCloud.js +1 -1
  244. package/lib/data/wordCloud.js.map +1 -1
  245. package/lib/exports.d.ts +2 -0
  246. package/lib/exports.js +7 -1
  247. package/lib/exports.js.map +1 -1
  248. package/lib/index.d.ts +2 -0
  249. package/lib/interaction/chartIndex.js +1 -1
  250. package/lib/interaction/chartIndex.js.map +1 -1
  251. package/lib/interaction/elementHighlight.js +1 -1
  252. package/lib/interaction/elementHighlight.js.map +1 -1
  253. package/lib/interaction/elementSelect.d.ts +1 -0
  254. package/lib/interaction/elementSelect.js +32 -3
  255. package/lib/interaction/elementSelect.js.map +1 -1
  256. package/lib/interaction/event.d.ts +0 -1
  257. package/lib/interaction/event.js +3 -15
  258. package/lib/interaction/event.js.map +1 -1
  259. package/lib/interaction/legendHighlight.js +1 -1
  260. package/lib/interaction/legendHighlight.js.map +1 -1
  261. package/lib/interaction/tooltip.js +10 -37
  262. package/lib/interaction/tooltip.js.map +1 -1
  263. package/lib/interaction/treemapDrillDown.d.ts +2 -2
  264. package/lib/interaction/treemapDrillDown.js.map +1 -1
  265. package/lib/interaction/utils.js +2 -2
  266. package/lib/interaction/utils.js.map +1 -1
  267. package/lib/label-transform/contrastReverse.js +1 -1
  268. package/lib/label-transform/contrastReverse.js.map +1 -1
  269. package/lib/label-transform/overlapDodgeY.js +1 -1
  270. package/lib/label-transform/overlapDodgeY.js.map +1 -1
  271. package/lib/lib/core.d.ts +1 -0
  272. package/lib/lib/core.js +1 -0
  273. package/lib/lib/core.js.map +1 -1
  274. package/lib/lib/std.d.ts +1 -0
  275. package/lib/mark/area.js +1 -1
  276. package/lib/mark/area.js.map +1 -1
  277. package/lib/mark/boxplot.js +1 -1
  278. package/lib/mark/boxplot.js.map +1 -1
  279. package/lib/mark/forceGraph.js +1 -1
  280. package/lib/mark/forceGraph.js.map +1 -1
  281. package/lib/mark/line.js +1 -1
  282. package/lib/mark/line.js.map +1 -1
  283. package/lib/mark/pack.js +1 -1
  284. package/lib/mark/pack.js.map +1 -1
  285. package/lib/mark/utils.d.ts +1 -1
  286. package/lib/runtime/component.js +2 -2
  287. package/lib/runtime/component.js.map +1 -1
  288. package/lib/runtime/layout.js +1 -1
  289. package/lib/runtime/layout.js.map +1 -1
  290. package/lib/runtime/mark.js +1 -1
  291. package/lib/runtime/mark.js.map +1 -1
  292. package/lib/runtime/plot.js +2 -2
  293. package/lib/runtime/plot.js.map +1 -1
  294. package/lib/runtime/scale.js +2 -2
  295. package/lib/runtime/scale.js.map +1 -1
  296. package/lib/runtime/transform.d.ts +1 -0
  297. package/lib/runtime/transform.js +4 -3
  298. package/lib/runtime/transform.js.map +1 -1
  299. package/lib/runtime/types/mark.d.ts +1 -1
  300. package/lib/shape/area/area.js +1 -1
  301. package/lib/shape/area/area.js.map +1 -1
  302. package/lib/shape/area/curve.d.ts +1 -1
  303. package/lib/shape/area/curve.js +1 -1
  304. package/lib/shape/area/curve.js.map +1 -1
  305. package/lib/shape/area/hv.js +1 -1
  306. package/lib/shape/area/hv.js.map +1 -1
  307. package/lib/shape/area/hvh.js +1 -1
  308. package/lib/shape/area/hvh.js.map +1 -1
  309. package/lib/shape/area/smooth.js +1 -1
  310. package/lib/shape/area/smooth.js.map +1 -1
  311. package/lib/shape/area/vh.js +1 -1
  312. package/lib/shape/area/vh.js.map +1 -1
  313. package/lib/shape/box/box.js +1 -1
  314. package/lib/shape/box/box.js.map +1 -1
  315. package/lib/shape/box/violin.js +1 -1
  316. package/lib/shape/box/violin.js.map +1 -1
  317. package/lib/shape/connector/connector.js +1 -1
  318. package/lib/shape/connector/connector.js.map +1 -1
  319. package/lib/shape/density/density.js +1 -1
  320. package/lib/shape/density/density.js.map +1 -1
  321. package/lib/shape/heatmap/heatmap.js +2 -2
  322. package/lib/shape/heatmap/heatmap.js.map +1 -1
  323. package/lib/shape/interval/color.js +1 -1
  324. package/lib/shape/interval/color.js.map +1 -1
  325. package/lib/shape/interval/funnel.js +1 -1
  326. package/lib/shape/interval/funnel.js.map +1 -1
  327. package/lib/shape/label/position/area.js +1 -1
  328. package/lib/shape/label/position/area.js.map +1 -1
  329. package/lib/shape/label/position/utils.js +1 -1
  330. package/lib/shape/label/position/utils.js.map +1 -1
  331. package/lib/shape/line/curve.d.ts +1 -1
  332. package/lib/shape/line/curve.js +1 -1
  333. package/lib/shape/line/curve.js.map +1 -1
  334. package/lib/shape/line/hv.js +1 -1
  335. package/lib/shape/line/hv.js.map +1 -1
  336. package/lib/shape/line/hvh.js +1 -1
  337. package/lib/shape/line/hvh.js.map +1 -1
  338. package/lib/shape/line/line.js +1 -1
  339. package/lib/shape/line/line.js.map +1 -1
  340. package/lib/shape/line/smooth.js +1 -1
  341. package/lib/shape/line/smooth.js.map +1 -1
  342. package/lib/shape/line/trail.js +1 -1
  343. package/lib/shape/line/trail.js.map +1 -1
  344. package/lib/shape/line/vh.js +1 -1
  345. package/lib/shape/line/vh.js.map +1 -1
  346. package/lib/shape/lineXY/line.js +1 -1
  347. package/lib/shape/lineXY/line.js.map +1 -1
  348. package/lib/shape/link/arc.js +1 -1
  349. package/lib/shape/link/arc.js.map +1 -1
  350. package/lib/shape/link/smooth.js +1 -1
  351. package/lib/shape/link/smooth.js.map +1 -1
  352. package/lib/shape/link/vhv.js +1 -1
  353. package/lib/shape/link/vhv.js.map +1 -1
  354. package/lib/shape/polygon/polygon.js +1 -1
  355. package/lib/shape/polygon/polygon.js.map +1 -1
  356. package/lib/shape/polygon/ribbon.js +1 -1
  357. package/lib/shape/polygon/ribbon.js.map +1 -1
  358. package/lib/shape/text/advance.js +1 -1
  359. package/lib/shape/text/advance.js.map +1 -1
  360. package/lib/shape/utils.d.ts +1 -1
  361. package/lib/shape/utils.js +1 -1
  362. package/lib/shape/utils.js.map +1 -1
  363. package/lib/shape/vector/vector.js +1 -1
  364. package/lib/shape/vector/vector.js.map +1 -1
  365. package/lib/spec/interaction.d.ts +1 -0
  366. package/lib/transform/bin.js +1 -1
  367. package/lib/transform/bin.js.map +1 -1
  368. package/lib/transform/flexX.js +1 -1
  369. package/lib/transform/flexX.js.map +1 -1
  370. package/lib/transform/groupN.js +1 -1
  371. package/lib/transform/groupN.js.map +1 -1
  372. package/lib/transform/normalizeY.js +1 -1
  373. package/lib/transform/normalizeY.js.map +1 -1
  374. package/lib/transform/sample.js +1 -1
  375. package/lib/transform/sample.js.map +1 -1
  376. package/lib/transform/select.js +1 -1
  377. package/lib/transform/select.js.map +1 -1
  378. package/lib/transform/sort.d.ts +1 -1
  379. package/lib/transform/sort.js +20 -52
  380. package/lib/transform/sort.js.map +1 -1
  381. package/lib/transform/stackEnter.js +1 -1
  382. package/lib/transform/stackEnter.js.map +1 -1
  383. package/lib/transform/symmetryY.js +1 -1
  384. package/lib/transform/symmetryY.js.map +1 -1
  385. package/lib/transform/utils/order.d.ts +1 -1
  386. package/lib/transform/utils/order.js +1 -1
  387. package/lib/transform/utils/order.js.map +1 -1
  388. package/lib/utils/bounds.d.ts +4 -2
  389. package/lib/utils/bounds.js +11 -4
  390. package/lib/utils/bounds.js.map +1 -1
  391. package/lib/utils/helper.d.ts +24 -0
  392. package/lib/utils/helper.js +81 -1
  393. package/lib/utils/helper.js.map +1 -1
  394. package/lib/utils/scale.js +1 -1
  395. package/lib/utils/scale.js.map +1 -1
  396. package/lib/utils/selection.js +1 -1
  397. package/lib/utils/selection.js.map +1 -1
  398. package/lib/utils/treeDataTransform.d.ts +9 -2
  399. package/lib/utils/treeDataTransform.js +6 -2
  400. package/lib/utils/treeDataTransform.js.map +1 -1
  401. package/package.json +7 -24
  402. package/src/animation/scaleInY.ts +2 -45
  403. package/src/animation/waveIn.ts +1 -1
  404. package/src/api/runtime.ts +3 -1
  405. package/src/component/axis.ts +2 -2
  406. package/src/component/legendCategory.ts +10 -2
  407. package/src/component/legendContinuous.ts +1 -1
  408. package/src/component/slider.ts +1 -1
  409. package/src/composition/d3Projection.ts +1 -1
  410. package/src/composition/facetRect.ts +1 -1
  411. package/src/composition/geoView.ts +1 -1
  412. package/src/data/cluster.ts +1 -1
  413. package/src/data/fetch.ts +1 -1
  414. package/src/data/join.ts +1 -1
  415. package/src/data/kde.ts +1 -1
  416. package/src/data/tree.ts +1 -1
  417. package/src/data/utils/arc/arc.ts +6 -6
  418. package/src/data/utils/arc/types.ts +28 -2
  419. package/src/data/utils/d3-sankey/align.ts +1 -1
  420. package/src/data/utils/d3-sankey/sankey.ts +1 -1
  421. package/src/data/wordCloud.ts +1 -1
  422. package/src/exports.ts +3 -0
  423. package/src/interaction/chartIndex.ts +1 -1
  424. package/src/interaction/elementHighlight.ts +1 -1
  425. package/src/interaction/elementSelect.ts +33 -3
  426. package/src/interaction/event.ts +2 -15
  427. package/src/interaction/legendHighlight.ts +4 -2
  428. package/src/interaction/tooltip.ts +10 -39
  429. package/src/interaction/treemapDrillDown.ts +2 -3
  430. package/src/interaction/utils.ts +2 -2
  431. package/src/label-transform/contrastReverse.ts +1 -1
  432. package/src/label-transform/overlapDodgeY.ts +1 -1
  433. package/src/lib/core.ts +2 -0
  434. package/src/mark/area.ts +1 -1
  435. package/src/mark/boxplot.ts +6 -1
  436. package/src/mark/forceGraph.ts +1 -1
  437. package/src/mark/line.ts +1 -1
  438. package/src/mark/pack.ts +5 -1
  439. package/src/mark/utils.ts +1 -1
  440. package/src/runtime/component.ts +2 -2
  441. package/src/runtime/layout.ts +15 -2
  442. package/src/runtime/mark.ts +1 -1
  443. package/src/runtime/plot.ts +2 -2
  444. package/src/runtime/scale.ts +2 -2
  445. package/src/runtime/transform.ts +6 -3
  446. package/src/runtime/types/mark.ts +1 -1
  447. package/src/shape/area/area.ts +1 -1
  448. package/src/shape/area/curve.ts +1 -1
  449. package/src/shape/area/hv.ts +1 -1
  450. package/src/shape/area/hvh.ts +1 -1
  451. package/src/shape/area/smooth.ts +1 -1
  452. package/src/shape/area/vh.ts +1 -1
  453. package/src/shape/box/box.ts +1 -1
  454. package/src/shape/box/violin.ts +1 -1
  455. package/src/shape/connector/connector.ts +1 -1
  456. package/src/shape/density/density.ts +1 -1
  457. package/src/shape/heatmap/heatmap.ts +2 -2
  458. package/src/shape/interval/color.ts +1 -1
  459. package/src/shape/interval/funnel.ts +1 -1
  460. package/src/shape/label/position/area.ts +1 -1
  461. package/src/shape/label/position/utils.ts +1 -1
  462. package/src/shape/line/curve.ts +6 -1
  463. package/src/shape/line/hv.ts +1 -1
  464. package/src/shape/line/hvh.ts +1 -1
  465. package/src/shape/line/line.ts +1 -1
  466. package/src/shape/line/smooth.ts +1 -1
  467. package/src/shape/line/trail.ts +1 -1
  468. package/src/shape/line/vh.ts +1 -1
  469. package/src/shape/lineXY/line.ts +1 -1
  470. package/src/shape/link/arc.ts +1 -1
  471. package/src/shape/link/smooth.ts +1 -1
  472. package/src/shape/link/vhv.ts +1 -1
  473. package/src/shape/polygon/polygon.ts +1 -1
  474. package/src/shape/polygon/ribbon.ts +1 -1
  475. package/src/shape/text/advance.ts +1 -1
  476. package/src/shape/utils.ts +2 -2
  477. package/src/shape/vector/vector.ts +1 -1
  478. package/src/spec/interaction.ts +1 -0
  479. package/src/transform/bin.ts +8 -3
  480. package/src/transform/flexX.ts +1 -1
  481. package/src/transform/groupN.ts +1 -1
  482. package/src/transform/normalizeY.ts +1 -1
  483. package/src/transform/sample.ts +1 -1
  484. package/src/transform/select.ts +1 -1
  485. package/src/transform/sort.ts +21 -43
  486. package/src/transform/stackEnter.ts +1 -1
  487. package/src/transform/symmetryY.ts +1 -1
  488. package/src/transform/utils/order.ts +1 -1
  489. package/src/utils/bounds.ts +22 -4
  490. package/src/utils/helper.ts +83 -0
  491. package/src/utils/scale.ts +1 -1
  492. package/src/utils/selection.ts +1 -1
  493. package/src/utils/treeDataTransform.ts +26 -13
@@ -1,6 +1,6 @@
1
1
  import { Linear, createInterpolateValue } from '@antv/scale';
2
- import { extent, max, rollups } from 'd3-array';
3
- import * as d3ScaleChromatic from 'd3-scale-chromatic';
2
+ import { extent, max, rollups } from '@antv/vendor/d3-array';
3
+ import * as d3ScaleChromatic from '@antv/vendor/d3-scale-chromatic';
4
4
  import { deepMix, omit, upperFirst } from '@antv/util';
5
5
  import { firstOf, lastOf, unique } from '../utils/array';
6
6
  import { defined, identity, isStrictObject } from '../utils/helper';
@@ -1,6 +1,6 @@
1
- import { Primitive } from 'd3-array';
1
+ import { Primitive } from '@antv/vendor/d3-array';
2
2
  import { deepMix, isNumber } from '@antv/util';
3
- import { format } from 'd3-format';
3
+ import { format } from '@antv/vendor/d3-format';
4
4
  import { indexOf, mapObject } from '../utils/array';
5
5
  import {
6
6
  composeAsync,
@@ -15,6 +15,8 @@ import { Data, DataComponent } from './types/data';
15
15
  import { G2Mark, G2DataOptions, G2Context } from './types/options';
16
16
  import { isPosition } from './scale';
17
17
 
18
+ export const CALLBACK_ITEM_SYMBOL = Symbol('CALLBACK_ITEM');
19
+
18
20
  // @todo Add more defaults.
19
21
  export function applyDefaults(
20
22
  I: number[],
@@ -192,7 +194,8 @@ export function extractTooltip(
192
194
  const values = [];
193
195
  for (const i of I) {
194
196
  const v = item(data[i], i, data, encode);
195
- if (isStrictObject(v)) values[i] = v;
197
+ if (isStrictObject(v))
198
+ values[i] = { ...v, [CALLBACK_ITEM_SYMBOL]: true };
196
199
  else values[i] = { value: v };
197
200
  }
198
201
  return values;
@@ -1,5 +1,5 @@
1
1
  import { Coordinate, Vector2 } from '@antv/coord';
2
- import { Primitive } from 'd3-array';
2
+ import { Primitive } from '@antv/vendor/d3-array';
3
3
  import { Channel } from './common';
4
4
  import { Scale } from './component';
5
5
  import { TransformSpec } from './transform';
@@ -1,4 +1,4 @@
1
- import { curveLinearClosed, curveLinear } from 'd3-shape';
1
+ import { curveLinearClosed, curveLinear } from '@antv/vendor/d3-shape';
2
2
  import { isPolar } from '../../utils/coordinate';
3
3
  import { ShapeComponent as SC } from '../../runtime';
4
4
  import { Curve } from './curve';
@@ -1,4 +1,4 @@
1
- import { area, areaRadial, CurveFactory } from 'd3-shape';
1
+ import { area, areaRadial, CurveFactory } from '@antv/vendor/d3-shape';
2
2
  import { select } from '../../utils/selection';
3
3
  import { isPolar, isTranspose } from '../../utils/coordinate';
4
4
  import { Vector2, ShapeComponent as SC } from '../../runtime';
@@ -1,4 +1,4 @@
1
- import { curveStepAfter } from 'd3-shape';
1
+ import { curveStepAfter } from '@antv/vendor/d3-shape';
2
2
  import { ShapeComponent as SC } from '../../runtime';
3
3
  import { Curve } from './curve';
4
4
 
@@ -1,4 +1,4 @@
1
- import { curveStep } from 'd3-shape';
1
+ import { curveStep } from '@antv/vendor/d3-shape';
2
2
  import { ShapeComponent as SC } from '../../runtime';
3
3
  import { Curve } from './curve';
4
4
 
@@ -2,7 +2,7 @@ import {
2
2
  curveCatmullRomClosed,
3
3
  curveMonotoneX,
4
4
  curveMonotoneY,
5
- } from 'd3-shape';
5
+ } from '@antv/vendor/d3-shape';
6
6
  import { isPolar, isTranspose } from '../../utils/coordinate';
7
7
  import { ShapeComponent as SC } from '../../runtime';
8
8
  import { Curve } from './curve';
@@ -1,4 +1,4 @@
1
- import { curveStepBefore } from 'd3-shape';
1
+ import { curveStepBefore } from '@antv/vendor/d3-shape';
2
2
  import { ShapeComponent as SC } from '../../runtime';
3
3
  import { Curve } from './curve';
4
4
 
@@ -1,4 +1,4 @@
1
- import { path as d3path } from 'd3-path';
1
+ import { path as d3path } from '@antv/vendor/d3-path';
2
2
  import { Coordinate } from '@antv/coord';
3
3
  import { applyStyle } from '../utils';
4
4
  import { select } from '../../utils/selection';
@@ -1,4 +1,4 @@
1
- import { path as d3path } from 'd3-path';
1
+ import { path as d3path } from '@antv/vendor/d3-path';
2
2
  import { Coordinate } from '@antv/coord';
3
3
  import { applyStyle } from '../utils';
4
4
  import { select } from '../../utils/selection';
@@ -2,7 +2,7 @@ import { Coordinate } from '@antv/coord';
2
2
  import type { PathArray } from '@antv/util';
3
3
  import { PathStyleProps, Path } from '@antv/g';
4
4
  import { Marker } from '@antv/component';
5
- import { line as d3line } from 'd3-shape';
5
+ import { line as d3line } from '@antv/vendor/d3-shape';
6
6
  import { ShapeComponent as SC, Vector2, WithPrefix } from '../../runtime';
7
7
  import { isTranspose } from '../../utils/coordinate';
8
8
  import { subObject } from '../../utils/helper';
@@ -1,4 +1,4 @@
1
- import { path as d3path } from 'd3-path';
1
+ import { path as d3path } from '@antv/vendor/d3-path';
2
2
  import { applyStyle } from '../utils';
3
3
  import { select } from '../../utils/selection';
4
4
  import { ShapeComponent as SC } from '../../runtime';
@@ -1,4 +1,4 @@
1
- import { max as d3max, min as d3min } from 'd3-array';
1
+ import { max as d3max, min as d3min } from '@antv/vendor/d3-array';
2
2
  import { applyStyle } from '../utils';
3
3
  import { select } from '../../utils/selection';
4
4
  import { ShapeComponent as SC } from '../../runtime';
@@ -66,7 +66,7 @@ export const Heatmap: SC<HeatmapOptions> = (options, context) => {
66
66
  .style('y', 0)
67
67
  .style('width', width)
68
68
  .style('height', height)
69
- .style('src', ctx.canvas)
69
+ .style('src', ctx.canvas.toDataURL())
70
70
  .style('transform', transform)
71
71
  .call(applyStyle, style)
72
72
  .node();
@@ -1,4 +1,4 @@
1
- import { arc } from 'd3-shape';
1
+ import { arc } from '@antv/vendor/d3-shape';
2
2
  import { Vector2, ShapeComponent as SC } from '../../runtime';
3
3
  import { isPolar, isHelix, isTranspose } from '../../utils/coordinate';
4
4
  import { select } from '../../utils/selection';
@@ -1,4 +1,4 @@
1
- import { line, curveLinearClosed } from 'd3-shape';
1
+ import { line, curveLinearClosed } from '@antv/vendor/d3-shape';
2
2
  import { Coordinate } from '@antv/coord';
3
3
  import { isTranspose } from '../../utils/coordinate';
4
4
  import { ShapeComponent as SC, Vector2 } from '../../runtime';
@@ -1,4 +1,4 @@
1
- import { maxIndex } from 'd3-array';
1
+ import { maxIndex } from '@antv/vendor/d3-array';
2
2
  import { Coordinate } from '@antv/coord';
3
3
  import { Vector2 } from '../../../runtime';
4
4
  import { sub, angle } from '../../../utils/vector';
@@ -1,4 +1,4 @@
1
- import { sort } from 'd3-array';
1
+ import { sort } from '@antv/vendor/d3-array';
2
2
 
3
3
  // Optimize antiCollision from: https://github.com/antvis/G2/blob/master/src/geometry/label/layout/pie/util.ts
4
4
  export function dodgeY(
@@ -1,4 +1,9 @@
1
- import { line, lineRadial, CurveFactory, CurveFactoryLineOnly } from 'd3-shape';
1
+ import {
2
+ line,
3
+ lineRadial,
4
+ CurveFactory,
5
+ CurveFactoryLineOnly,
6
+ } from '@antv/vendor/d3-shape';
2
7
  import { Vector2 } from '@antv/coord';
3
8
  import { isPolar, isTranspose } from '../../utils/coordinate';
4
9
  import { select } from '../../utils/selection';
@@ -1,4 +1,4 @@
1
- import { curveStepAfter } from 'd3-shape';
1
+ import { curveStepAfter } from '@antv/vendor/d3-shape';
2
2
  import { ShapeComponent as SC } from '../../runtime';
3
3
  import { Curve } from './curve';
4
4
 
@@ -1,4 +1,4 @@
1
- import { curveStep } from 'd3-shape';
1
+ import { curveStep } from '@antv/vendor/d3-shape';
2
2
  import { ShapeComponent as SC } from '../../runtime';
3
3
  import { Curve } from './curve';
4
4
 
@@ -1,4 +1,4 @@
1
- import { curveLinear, curveLinearClosed } from 'd3-shape';
1
+ import { curveLinear, curveLinearClosed } from '@antv/vendor/d3-shape';
2
2
  import { isPolar } from '../../utils/coordinate';
3
3
  import { ShapeComponent as SC } from '../../runtime';
4
4
  import { Curve } from './curve';
@@ -2,7 +2,7 @@ import {
2
2
  curveMonotoneX,
3
3
  curveMonotoneY,
4
4
  curveCatmullRomClosed,
5
- } from 'd3-shape';
5
+ } from '@antv/vendor/d3-shape';
6
6
  import { isPolar, isTranspose } from '../../utils/coordinate';
7
7
  import { ShapeComponent as SC } from '../../runtime';
8
8
  import { Curve } from './curve';
@@ -1,4 +1,4 @@
1
- import { path as d3path } from 'd3-path';
1
+ import { path as d3path } from '@antv/vendor/d3-path';
2
2
  import { ShapeComponent as SC } from '../../runtime';
3
3
  import { select } from '../../utils/selection';
4
4
  import { applyStyle } from '../utils';
@@ -1,4 +1,4 @@
1
- import { curveStepBefore } from 'd3-shape';
1
+ import { curveStepBefore } from '@antv/vendor/d3-shape';
2
2
  import { ShapeComponent as SC } from '../../runtime';
3
3
  import { Curve } from './curve';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import { IDocument } from '@antv/g';
2
2
  import { Coordinate } from '@antv/coord';
3
- import { arc, line } from 'd3-shape';
3
+ import { arc, line } from '@antv/vendor/d3-shape';
4
4
  import { isPolar } from '../../utils/coordinate';
5
5
  import { select } from '../../utils/selection';
6
6
  import { dist } from '../../utils/vector';
@@ -1,4 +1,4 @@
1
- import { path as d3path } from 'd3-path';
1
+ import { path as d3path } from '@antv/vendor/d3-path';
2
2
  import { appendArc, applyStyle } from '../utils';
3
3
  import { select } from '../../utils/selection';
4
4
  import { isPolar } from '../../utils/coordinate';
@@ -1,4 +1,4 @@
1
- import { path as d3path } from 'd3-path';
1
+ import { path as d3path } from '@antv/vendor/d3-path';
2
2
  import { applyStyle } from '../utils';
3
3
  import { select } from '../../utils/selection';
4
4
  import { ShapeComponent as SC } from '../../runtime';
@@ -1,4 +1,4 @@
1
- import { path as d3path } from 'd3-path';
1
+ import { path as d3path } from '@antv/vendor/d3-path';
2
2
  import { Coordinate } from '@antv/coord';
3
3
  import { appendArc, applyStyle } from '../utils';
4
4
  import { select } from '../../utils/selection';
@@ -1,5 +1,5 @@
1
1
  import { Coordinate } from '@antv/coord';
2
- import { path as d3path } from 'd3-path';
2
+ import { path as d3path } from '@antv/vendor/d3-path';
3
3
  import { isPolar } from '../../utils/coordinate';
4
4
  import { applyStyle, appendPolygon, appendArc } from '../utils';
5
5
  import { select } from '../../utils/selection';
@@ -1,4 +1,4 @@
1
- import { path as d3path } from 'd3-path';
1
+ import { path as d3path } from '@antv/vendor/d3-path';
2
2
  import { Coordinate } from '@antv/coord';
3
3
  import { appendArc, applyStyle } from '../utils';
4
4
  import { select } from '../../utils/selection';
@@ -9,7 +9,7 @@ import {
9
9
  } from '@antv/g';
10
10
  import { isNumber } from '@antv/util';
11
11
  import { Marker } from '@antv/component';
12
- import { line } from 'd3-shape';
12
+ import { line } from '@antv/vendor/d3-shape';
13
13
  import { WithPrefix } from '../../runtime';
14
14
  import { createElement } from '../../utils/createElement';
15
15
  import { applyStyle } from '../utils';
@@ -1,8 +1,8 @@
1
1
  import { Coordinate } from '@antv/coord';
2
2
  import { Linear } from '@antv/scale';
3
3
  import { isNumber, lowerFirst } from '@antv/util';
4
- import { extent } from 'd3-array';
5
- import { Path as D3Path } from 'd3-path';
4
+ import { extent } from '@antv/vendor/d3-array';
5
+ import { Path as D3Path } from '@antv/vendor/d3-path';
6
6
  import { Primitive, Vector2, Vector3 } from '../runtime';
7
7
  import { indexOf } from '../utils/array';
8
8
  import { isPolar, isTranspose } from '../utils/coordinate';
@@ -1,4 +1,4 @@
1
- import { path as d3path } from 'd3-path';
1
+ import { path as d3path } from '@antv/vendor/d3-path';
2
2
  import { applyStyle, arrowPoints, ArrowOptions } from '../utils';
3
3
  import { select } from '../../utils/selection';
4
4
  import { ShapeComponent as SC } from '../../runtime';
@@ -107,6 +107,7 @@ export type ElementSelectInteraction = {
107
107
  single?: boolean;
108
108
  background?: boolean;
109
109
  offset?: number;
110
+ multipleSelectHotkey?: string;
110
111
  } & Record<`${'link' | 'background'}${any}`, any>;
111
112
 
112
113
  export type ElementSelectByColorInteraction = {
@@ -1,4 +1,9 @@
1
- import { bin as d3Bin, group, thresholdScott, extent } from 'd3-array';
1
+ import {
2
+ bin as d3Bin,
3
+ group,
4
+ thresholdScott,
5
+ extent,
6
+ } from '@antv/vendor/d3-array';
2
7
  import { defined, subObject } from '../utils/helper';
3
8
  import { TransformComponent as TC } from '../runtime';
4
9
  import { BinTransform } from '../spec';
@@ -34,7 +39,7 @@ export const Bin: TC<BinOptions> = (options = {}) => {
34
39
  const channelIndexKey = {};
35
40
 
36
41
  // Group indexes and update channelIndexKey.
37
- const groupBy = (I, mark) => {
42
+ const groupBy = (I, mark): number[][] => {
38
43
  const { encode } = mark;
39
44
  const binValues = binChannels.map((channel) => {
40
45
  const [V] = columnOf(encode, channel);
@@ -75,7 +80,7 @@ export const Bin: TC<BinOptions> = (options = {}) => {
75
80
 
76
81
  // Group by indexes by channel keys.
77
82
  const key = (i: number) => groupKeys.map((key) => key(i)).join('-');
78
- return Array.from(group(DI, key).values());
83
+ return Array.from(group(DI, key).values()) as number[][];
79
84
  };
80
85
 
81
86
  return GroupN({
@@ -1,5 +1,5 @@
1
1
  import { deepMix } from '@antv/util';
2
- import { rollups, sum, Primitive } from 'd3-array';
2
+ import { rollups, sum, Primitive } from '@antv/vendor/d3-array';
3
3
  import { TransformComponent as TC } from '../runtime';
4
4
  import { FlexXTransform } from '../spec';
5
5
  import { columnOf } from './utils/helper';
@@ -5,7 +5,7 @@ import {
5
5
  sum as d3Sum,
6
6
  min as d3Min,
7
7
  median as d3Median,
8
- } from 'd3-array';
8
+ } from '@antv/vendor/d3-array';
9
9
  import { TransformComponent as TC, Primitive, G2Mark } from '../runtime';
10
10
  import { GroupTransform, Reducer } from '../spec';
11
11
  import { indexOf } from '../utils/array';
@@ -1,5 +1,5 @@
1
1
  import { deepMix } from '@antv/util';
2
- import { mean, deviation, median, sum, max, min } from 'd3-array';
2
+ import { mean, deviation, median, sum, max, min } from '@antv/vendor/d3-array';
3
3
  import { isUnset } from '../utils/helper';
4
4
  import { TransformComponent as TC } from '../runtime';
5
5
  import { NormalizeYTransform } from '../spec';
@@ -1,5 +1,5 @@
1
1
  // @ts-ignore medianIndex exist in d3-array@3.2.0, but @types/d3-array Expired.
2
- import { maxIndex, minIndex, medianIndex } from 'd3-array';
2
+ import { maxIndex, minIndex, medianIndex } from '@antv/vendor/d3-array';
3
3
  import { TransformComponent as TC, Primitive } from '../runtime';
4
4
  import { SampleTransform, SampleFunction } from '../spec';
5
5
  import { createGroups } from './utils/order';
@@ -1,4 +1,4 @@
1
- import { maxIndex, minIndex } from 'd3-array';
1
+ import { maxIndex, minIndex } from '@antv/vendor/d3-array';
2
2
  import { TransformComponent as TC } from '../runtime';
3
3
  import { SelectTransform, Selector } from '../spec';
4
4
  import { columnOf } from './utils/helper';
@@ -8,7 +8,7 @@ import {
8
8
  mean,
9
9
  median,
10
10
  sort,
11
- } from 'd3-array';
11
+ } from '@antv/vendor/d3-array';
12
12
  import { G2Mark, TransformComponent as TC } from '../runtime';
13
13
  import { columnOf } from './utils/helper';
14
14
 
@@ -43,16 +43,6 @@ export type SortOptions = {
43
43
  | ((I: number[], V: Primitive[]) => Primitive);
44
44
  };
45
45
 
46
- function sortQuantitative(I, mark, options): [number[], G2Mark] {
47
- const { reverse, channel } = options;
48
- const { encode } = mark;
49
- const [V] = columnOf(encode, channel);
50
- const sortedI = sort(I, (i: number) => V[i]);
51
- if (reverse) sortedI.reverse();
52
- // const s = typeof slice === 'number' ? [0, slice] : slice;
53
- return [sortedI, mark];
54
- }
55
-
56
46
  // If domain is specified, only sort data in the domain.
57
47
  function filterIndex(I, values, specifiedDomain): number[] {
58
48
  if (!Array.isArray(specifiedDomain)) return I;
@@ -60,44 +50,32 @@ function filterIndex(I, values, specifiedDomain): number[] {
60
50
  return I.filter((i) => domain.has(values[i]));
61
51
  }
62
52
 
63
- function sortOrdinal(I, mark, options): [number[], G2Mark] {
64
- const { reverse, slice, channel, ...rest } = options;
65
- const { encode, scale = {} } = mark;
66
- const domain = scale[channel]?.domain;
67
- const [T] = columnOf(encode, channel);
68
- const normalizeReducer = createReducer(channel, rest, encode);
69
- const SI = filterIndex(I, T, domain);
70
- const sortedDomain = groupSort(SI, normalizeReducer, (i: number) => T[i]);
71
- if (reverse) sortedDomain.reverse();
72
- const s = typeof slice === 'number' ? [0, slice] : slice;
73
- const slicedDomain = slice ? sortedDomain.slice(...s) : sortedDomain;
74
- return [
75
- I,
76
- deepMix(mark, {
77
- scale: {
78
- [channel]: {
79
- domain: slicedDomain,
80
- },
81
- },
82
- }),
83
- ];
84
- }
85
-
86
53
  /**
87
54
  * Sort marks groups by groups.
88
55
  */
89
56
  export const Sort: TC<SortOptions> = (options = {}) => {
90
- const { reverse = false, slice, channel, ordinal = true, ...rest } = options;
91
57
  return (I, mark) => {
92
- if (!ordinal) {
93
- return sortQuantitative(I, mark, {
94
- reverse,
95
- slice,
96
- channel,
97
- ...rest,
98
- });
58
+ const { reverse, slice, channel, by, ordinal = true, reducer } = options;
59
+ const { encode, scale = {} } = mark;
60
+ const domain = scale[channel].domain;
61
+ const [V] = columnOf(encode, by ?? channel);
62
+ const [T] = columnOf(encode, channel);
63
+ const normalizeReducer = createReducer(channel, { by, reducer }, encode);
64
+ const SI = filterIndex(I, T, domain);
65
+ const sortedDomain = groupSort(SI, normalizeReducer, (i: number) => T[i]);
66
+
67
+ // when ordinal is true, do not change the index of the data.
68
+ const sortedI = !ordinal ? sort(I, (i: number) => V[i]) : I;
69
+ if (reverse) {
70
+ !ordinal && sortedI.reverse();
71
+ sortedDomain.reverse();
99
72
  }
100
- return sortOrdinal(I, mark, { reverse, slice, channel, ...rest });
73
+ const s = typeof slice === 'number' ? [0, slice] : slice;
74
+ const slicedDomain = slice ? sortedDomain.slice(...s) : sortedDomain;
75
+ return [
76
+ sortedI,
77
+ deepMix(mark, { scale: { [channel]: { domain: slicedDomain } } }),
78
+ ];
101
79
  };
102
80
  };
103
81
 
@@ -1,5 +1,5 @@
1
1
  import { deepMix } from '@antv/util';
2
- import { group, max } from 'd3-array';
2
+ import { group, max } from '@antv/vendor/d3-array';
3
3
  import { TransformComponent as TC } from '../runtime';
4
4
  import { StackEnterTransform } from '../spec';
5
5
  import {
@@ -1,5 +1,5 @@
1
1
  import { deepMix } from '@antv/util';
2
- import { extent } from 'd3-array';
2
+ import { extent } from '@antv/vendor/d3-array';
3
3
  import { TransformComponent as TC } from '../runtime';
4
4
  import { SymmetryYTransform } from '../spec';
5
5
  import { columnOf, column } from './utils/helper';
@@ -1,4 +1,4 @@
1
- import { group, ascending, maxIndex, Primitive } from 'd3-array';
1
+ import { group, ascending, maxIndex, Primitive } from '@antv/vendor/d3-array';
2
2
  import { defined } from '../../utils/helper';
3
3
  import { TabularData, G2Mark } from '../../runtime';
4
4
  import { indexOf } from '../../utils/array';
@@ -5,6 +5,9 @@ type Min = Vector2;
5
5
  type Max = Vector2;
6
6
  export type Bounds = [Min, Max];
7
7
 
8
+ // There is a certain error in the calculation of text bounds.
9
+ const EPSILON = 1e-2;
10
+
8
11
  export function parseAABB(min2: AABB): Bounds {
9
12
  const { min, max } = min2;
10
13
  return [
@@ -17,21 +20,36 @@ export function parseAABB(min2: AABB): Bounds {
17
20
  * Whether the `point` in `bounds`.
18
21
  * @param point
19
22
  * @param bounds
23
+ * @param threshold
20
24
  */
21
- export function isInBounds(point: Vector2, bounds: Bounds): boolean {
25
+ export function isInBounds(
26
+ point: Vector2,
27
+ bounds: Bounds,
28
+ threshold = EPSILON,
29
+ ): boolean {
22
30
  const [x, y] = point;
23
31
  const [min, max] = bounds;
24
- return x >= min[0] && x <= max[0] && y >= min[1] && y <= max[1];
32
+ return (
33
+ x >= min[0] - threshold &&
34
+ x <= max[0] + threshold &&
35
+ y >= min[1] - threshold &&
36
+ y <= max[1] + threshold
37
+ );
25
38
  }
26
39
 
27
40
  /**
28
41
  * Whether `b1` is overflow from `b2`.
29
42
  * @param b1
30
43
  * @param b2
44
+ * @param threshold The threshold to determine whether the bounds is overflowed, default is 0.
31
45
  */
32
- export function isOverflow(b1: Bounds, b2: Bounds): boolean {
46
+ export function isOverflow(
47
+ b1: Bounds,
48
+ b2: Bounds,
49
+ threshold = EPSILON,
50
+ ): boolean {
33
51
  const [min, max] = b1;
34
- return !(isInBounds(min, b2) && isInBounds(max, b2));
52
+ return !(isInBounds(min, b2, threshold) && isInBounds(max, b2, threshold));
35
53
  }
36
54
 
37
55
  /**
@@ -1,5 +1,88 @@
1
1
  import { DisplayObject } from '@antv/g';
2
2
  import { lowerFirst, upperFirst, isPlainObject } from '@antv/util';
3
+ import { Band, Base, Constant } from '@antv/scale';
4
+ import { G2Element } from './selection';
5
+
6
+ /**
7
+ * @description Get element's ancestor view node.
8
+ * @param elemenet G2 element.
9
+ * @returns Element's ancestor view node.
10
+ */
11
+ export function getViewFromElement(element: G2Element) {
12
+ let current = element as G2Element;
13
+ while (current) {
14
+ if (current.attributes?.class === 'view') return current;
15
+ current = current.parentNode as G2Element;
16
+ }
17
+ return null;
18
+ }
19
+
20
+ /**
21
+ * @description Get element's original data.
22
+ * @param elemenet G2 element.
23
+ * @returns The original data of the element.
24
+ */
25
+ export function dataOf(element: G2Element) {
26
+ const view = getViewFromElement(element);
27
+ const datum = element.__data__;
28
+ const { markKey, index, seriesIndex } = datum;
29
+ const { markState } = view.__data__;
30
+ const selectedMark: any = Array.from(markState.keys()).find(
31
+ (mark) => (mark as any).key === markKey,
32
+ );
33
+ if (!selectedMark) return;
34
+ if (seriesIndex) {
35
+ return seriesIndex.map((i) => selectedMark.data[i]);
36
+ }
37
+ return selectedMark.data[index];
38
+ }
39
+
40
+ /**
41
+ * @description Get element's series name.
42
+ * @param elemenet G2 element.
43
+ * @returns The series name of the element.
44
+ */
45
+ export function seriesOf(elemenet: G2Element): string {
46
+ const viewData = getViewFromElement(elemenet).__data__;
47
+ const { scale } = viewData;
48
+ return groupNameOf(scale, elemenet.__data__);
49
+ }
50
+
51
+ /**
52
+ * Get group name with view's scale and element's datum.
53
+ */
54
+ export function groupNameOf(scale: Record<string, Base<any>>, datum) {
55
+ const { color: scaleColor, series: scaleSeries, facet = false } = scale;
56
+ const { color, series } = datum;
57
+ const invertAble = (scale) => {
58
+ return (
59
+ scale &&
60
+ scale.invert &&
61
+ !(scale instanceof Band) &&
62
+ !(scale instanceof Constant)
63
+ );
64
+ };
65
+ // For non constant color channel.
66
+ if (invertAble(scaleSeries)) {
67
+ const cloned = scaleSeries.clone();
68
+ return cloned.invert(series);
69
+ }
70
+ if (
71
+ series &&
72
+ scaleSeries instanceof Band &&
73
+ scaleSeries.invert(series) !== color &&
74
+ !facet
75
+ ) {
76
+ return scaleSeries.invert(series);
77
+ }
78
+ if (invertAble(scaleColor)) {
79
+ const name = scaleColor.invert(color);
80
+ // For threshold scale.
81
+ if (Array.isArray(name)) return null;
82
+ return name;
83
+ }
84
+ return null;
85
+ }
3
86
 
4
87
  export function identity<T>(x: T): T {
5
88
  return x;