@antv/g2 5.4.3 → 5.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (591) hide show
  1. package/dist/g2.lite.min.js +10 -10
  2. package/dist/g2.min.js +10 -10
  3. package/esm/animation/morphing.js.map +1 -1
  4. package/esm/animation/scaleInY.js.map +1 -1
  5. package/esm/animation/utils.js.map +1 -1
  6. package/esm/animation/waveIn.js.map +1 -1
  7. package/esm/api/composition.js.map +1 -1
  8. package/esm/api/define.js.map +1 -1
  9. package/esm/api/mark.js.map +1 -1
  10. package/esm/api/node.js.map +1 -1
  11. package/esm/api/runtime.js +6 -2
  12. package/esm/api/runtime.js.map +1 -1
  13. package/esm/api/utils.js.map +1 -1
  14. package/esm/component/axis.js +3 -2
  15. package/esm/component/axis.js.map +1 -1
  16. package/esm/component/axisRadar.js.map +1 -1
  17. package/esm/component/constant.d.ts +8 -0
  18. package/esm/component/constant.js +10 -0
  19. package/esm/component/constant.js.map +1 -1
  20. package/esm/component/legendCategory.js +4 -1
  21. package/esm/component/legendCategory.js.map +1 -1
  22. package/esm/component/legendContinuous.js +4 -3
  23. package/esm/component/legendContinuous.js.map +1 -1
  24. package/esm/component/scrollbar.js +2 -1
  25. package/esm/component/scrollbar.js.map +1 -1
  26. package/esm/component/slider.js.map +1 -1
  27. package/esm/component/title.js.map +1 -1
  28. package/esm/component/utils.d.ts +1 -1
  29. package/esm/component/utils.js.map +1 -1
  30. package/esm/composition/facetRect.js.map +1 -1
  31. package/esm/composition/geoView.js.map +1 -1
  32. package/esm/composition/repeatMatrix.js.map +1 -1
  33. package/esm/composition/spaceFlex.js.map +1 -1
  34. package/esm/composition/timingKeyframe.js.map +1 -1
  35. package/esm/composition/utils.js.map +1 -1
  36. package/esm/data/cluster.d.ts +1 -1
  37. package/esm/data/ema.js.map +1 -1
  38. package/esm/data/fetch.js.map +1 -1
  39. package/esm/data/pick.js.map +1 -1
  40. package/esm/data/sankey.js.map +1 -1
  41. package/esm/data/sortBy.js.map +1 -1
  42. package/esm/data/utils/arc/arc.d.ts +6 -6
  43. package/esm/data/utils/arc/arc.js.map +1 -1
  44. package/esm/data/utils/d3-cloud/index.js.map +1 -1
  45. package/esm/data/utils/d3-sankey/sankey.d.ts +5 -5
  46. package/esm/data/utils/d3-sankey/sankey.js.map +1 -1
  47. package/esm/data/utils/fields.js.map +1 -1
  48. package/esm/data/utils/memo.js +1 -1
  49. package/esm/data/utils/memo.js.map +1 -1
  50. package/esm/data/utils/venn/circleintersection.js.map +1 -1
  51. package/esm/data/utils/venn/diagram.js.map +1 -1
  52. package/esm/data/utils/venn/fmin/bisect.js.map +1 -1
  53. package/esm/data/utils/venn/fmin/blas1.js.map +1 -1
  54. package/esm/data/utils/venn/fmin/conjugateGradient.js.map +1 -1
  55. package/esm/data/utils/venn/fmin/gradientDescent.js.map +1 -1
  56. package/esm/data/utils/venn/fmin/linesearch.js.map +1 -1
  57. package/esm/data/utils/venn/fmin/nelderMead.js.map +1 -1
  58. package/esm/data/utils/venn/layout.js.map +1 -1
  59. package/esm/data/wordCloud.js.map +1 -1
  60. package/esm/index.d.ts +6 -0
  61. package/esm/interaction/adaptiveFilter.js.map +1 -1
  62. package/esm/interaction/brushAxisHighlight.js +1 -1
  63. package/esm/interaction/brushAxisHighlight.js.map +1 -1
  64. package/esm/interaction/brushFilter.js.map +1 -1
  65. package/esm/interaction/brushHighlight.js.map +1 -1
  66. package/esm/interaction/chartIndex.js.map +1 -1
  67. package/esm/interaction/drillDown.d.ts +6 -0
  68. package/esm/interaction/drillDown.js +210 -0
  69. package/esm/interaction/drillDown.js.map +1 -0
  70. package/esm/interaction/elementHighlight.js.map +1 -1
  71. package/esm/interaction/elementHoverScale.d.ts +23 -0
  72. package/esm/interaction/elementHoverScale.js +222 -0
  73. package/esm/interaction/elementHoverScale.js.map +1 -0
  74. package/esm/interaction/elementPointMove.js.map +1 -1
  75. package/esm/interaction/elementSelect.js.map +1 -1
  76. package/esm/interaction/event.js +10 -2
  77. package/esm/interaction/event.js.map +1 -1
  78. package/esm/interaction/fisheye.js.map +1 -1
  79. package/esm/interaction/index.d.ts +2 -0
  80. package/esm/interaction/index.js +2 -0
  81. package/esm/interaction/index.js.map +1 -1
  82. package/esm/interaction/legendFilter.js +38 -16
  83. package/esm/interaction/legendFilter.js.map +1 -1
  84. package/esm/interaction/legendHighlight.js.map +1 -1
  85. package/esm/interaction/poptip.js.map +1 -1
  86. package/esm/interaction/scrollbarFilter.js +2 -1
  87. package/esm/interaction/scrollbarFilter.js.map +1 -1
  88. package/esm/interaction/sliderFilter.js.map +1 -1
  89. package/esm/interaction/sliderWheel.js.map +1 -1
  90. package/esm/interaction/tooltip.js +6 -5
  91. package/esm/interaction/tooltip.js.map +1 -1
  92. package/esm/interaction/treemapDrillDown.js.map +1 -1
  93. package/esm/interaction/utils.d.ts +16 -2
  94. package/esm/interaction/utils.js +57 -9
  95. package/esm/interaction/utils.js.map +1 -1
  96. package/esm/label-transform/exceedAdjust.js +17 -0
  97. package/esm/label-transform/exceedAdjust.js.map +1 -1
  98. package/esm/label-transform/overflowStroke.js.map +1 -1
  99. package/esm/label-transform/overlapDodgeY.js.map +1 -1
  100. package/esm/lib/core.d.ts +3 -1
  101. package/esm/lib/core.js +3 -1
  102. package/esm/lib/core.js.map +1 -1
  103. package/esm/lib/graph.d.ts +1 -0
  104. package/esm/lib/graph.js +2 -1
  105. package/esm/lib/graph.js.map +1 -1
  106. package/esm/lib/std.d.ts +3 -0
  107. package/esm/mark/area.js.map +1 -1
  108. package/esm/mark/box.js +3 -3
  109. package/esm/mark/box.js.map +1 -1
  110. package/esm/mark/boxplot.js.map +1 -1
  111. package/esm/mark/chord.js +2 -2
  112. package/esm/mark/chord.js.map +1 -1
  113. package/esm/mark/density.js +1 -1
  114. package/esm/mark/density.js.map +1 -1
  115. package/esm/mark/gauge.js.map +1 -1
  116. package/esm/mark/index.d.ts +1 -0
  117. package/esm/mark/index.js +1 -0
  118. package/esm/mark/index.js.map +1 -1
  119. package/esm/mark/line.js.map +1 -1
  120. package/esm/mark/partition.d.ts +42 -0
  121. package/esm/mark/partition.js +217 -0
  122. package/esm/mark/partition.js.map +1 -0
  123. package/esm/mark/polygon.js.map +1 -1
  124. package/esm/mark/sankey.js.map +1 -1
  125. package/esm/mark/utils.js.map +1 -1
  126. package/esm/runtime/component.js.map +1 -1
  127. package/esm/runtime/coordinate.js.map +1 -1
  128. package/esm/runtime/layout.js.map +1 -1
  129. package/esm/runtime/mark.js +2 -2
  130. package/esm/runtime/mark.js.map +1 -1
  131. package/esm/runtime/option-preprocess/axis-breaks.js.map +1 -1
  132. package/esm/runtime/option-preprocess/index.js.map +1 -1
  133. package/esm/runtime/option-preprocess/style.js.map +1 -1
  134. package/esm/runtime/plot.js +13 -2
  135. package/esm/runtime/plot.js.map +1 -1
  136. package/esm/runtime/render.js.map +1 -1
  137. package/esm/runtime/scale.js.map +1 -1
  138. package/esm/runtime/transform.js.map +1 -1
  139. package/esm/shape/area/curve.js.map +1 -1
  140. package/esm/shape/axis-breaks/axis-breaks.js.map +1 -1
  141. package/esm/shape/box/box.js.map +1 -1
  142. package/esm/shape/box/violin.js.map +1 -1
  143. package/esm/shape/connector/connector.js.map +1 -1
  144. package/esm/shape/heatmap/renderer/gradient.js.map +1 -1
  145. package/esm/shape/heatmap/renderer/index.js.map +1 -1
  146. package/esm/shape/interval/color.js.map +1 -1
  147. package/esm/shape/interval/funnel.js.map +1 -1
  148. package/esm/shape/interval/pyramid.js.map +1 -1
  149. package/esm/shape/label/label.js.map +1 -1
  150. package/esm/shape/label/position/default.js.map +1 -1
  151. package/esm/shape/label/position/outside.js.map +1 -1
  152. package/esm/shape/label/position/utils.js.map +1 -1
  153. package/esm/shape/line/curve.js.map +1 -1
  154. package/esm/shape/line/trail.js.map +1 -1
  155. package/esm/shape/link/arc.js.map +1 -1
  156. package/esm/shape/link/vhv.js.map +1 -1
  157. package/esm/shape/liquid/liquid.js.map +1 -1
  158. package/esm/shape/liquid/wave.js.map +1 -1
  159. package/esm/shape/point/color.js.map +1 -1
  160. package/esm/shape/polygon/polygon.js.map +1 -1
  161. package/esm/shape/polygon/ribbon.js.map +1 -1
  162. package/esm/shape/text/advance.d.ts +1 -1
  163. package/esm/shape/text/advance.js.map +1 -1
  164. package/esm/shape/utils.js.map +1 -1
  165. package/esm/shape/vector/vector.js.map +1 -1
  166. package/esm/spec/interaction.d.ts +23 -2
  167. package/esm/spec/mark.d.ts +13 -2
  168. package/esm/theme/create.d.ts +1 -1
  169. package/esm/theme/create.js +3 -2
  170. package/esm/theme/create.js.map +1 -1
  171. package/esm/theme/dark.js +5 -4
  172. package/esm/theme/dark.js.map +1 -1
  173. package/esm/transform/diffY.js.map +1 -1
  174. package/esm/transform/dodgeX.js.map +1 -1
  175. package/esm/transform/filter.js.map +1 -1
  176. package/esm/transform/maybeDefaultX.js.map +1 -1
  177. package/esm/transform/maybeDefaultY.js.map +1 -1
  178. package/esm/transform/maybeTitle.js.map +1 -1
  179. package/esm/transform/maybeVisualPosition.js +1 -1
  180. package/esm/transform/maybeVisualPosition.js.map +1 -1
  181. package/esm/transform/normalizeY.js.map +1 -1
  182. package/esm/transform/pack.js.map +1 -1
  183. package/esm/transform/sample.js.map +1 -1
  184. package/esm/transform/sort.js.map +1 -1
  185. package/esm/transform/stackEnter.js.map +1 -1
  186. package/esm/transform/stackY.js +2 -2
  187. package/esm/transform/stackY.js.map +1 -1
  188. package/esm/transform/symmetryY.js.map +1 -1
  189. package/esm/transform/utils/helper.js.map +1 -1
  190. package/esm/transform/utils/lttb.js.map +1 -1
  191. package/esm/transform/utils/order.js.map +1 -1
  192. package/esm/utils/angle.js.map +1 -1
  193. package/esm/utils/array.js.map +1 -1
  194. package/esm/utils/coordinate.d.ts +0 -1
  195. package/esm/utils/coordinate.js.map +1 -1
  196. package/esm/utils/expr.js.map +1 -1
  197. package/esm/utils/helper.js +6 -6
  198. package/esm/utils/helper.js.map +1 -1
  199. package/esm/utils/marker.d.ts +1 -1
  200. package/esm/utils/scale.js.map +1 -1
  201. package/esm/utils/selection.js.map +1 -1
  202. package/esm/utils/style.js.map +1 -1
  203. package/esm/utils/traverse-elements.js.map +1 -1
  204. package/esm/utils/treeDataTransform.js.map +1 -1
  205. package/esm/utils/vector.js.map +1 -1
  206. package/lib/animation/morphing.js.map +1 -1
  207. package/lib/animation/scaleInY.js.map +1 -1
  208. package/lib/animation/utils.js +2 -2
  209. package/lib/animation/utils.js.map +1 -1
  210. package/lib/animation/waveIn.js.map +1 -1
  211. package/lib/api/composition.js +2 -2
  212. package/lib/api/composition.js.map +1 -1
  213. package/lib/api/define.js +2 -3
  214. package/lib/api/define.js.map +1 -1
  215. package/lib/api/extend.js +1 -2
  216. package/lib/api/extend.js.map +1 -1
  217. package/lib/api/library.js +2 -2
  218. package/lib/api/library.js.map +1 -1
  219. package/lib/api/mark.js +2 -2
  220. package/lib/api/mark.js.map +1 -1
  221. package/lib/api/node.js.map +1 -1
  222. package/lib/api/runtime.js +6 -2
  223. package/lib/api/runtime.js.map +1 -1
  224. package/lib/api/utils.js +9 -9
  225. package/lib/api/utils.js.map +1 -1
  226. package/lib/component/axis.js +5 -4
  227. package/lib/component/axis.js.map +1 -1
  228. package/lib/component/axisRadar.js.map +1 -1
  229. package/lib/component/axisX.js +2 -2
  230. package/lib/component/axisX.js.map +1 -1
  231. package/lib/component/constant.d.ts +8 -0
  232. package/lib/component/constant.js +12 -1
  233. package/lib/component/constant.js.map +1 -1
  234. package/lib/component/legendCategory.js +4 -1
  235. package/lib/component/legendCategory.js.map +1 -1
  236. package/lib/component/legendContinuous.js +4 -3
  237. package/lib/component/legendContinuous.js.map +1 -1
  238. package/lib/component/scrollbar.js +2 -1
  239. package/lib/component/scrollbar.js.map +1 -1
  240. package/lib/component/slider.js.map +1 -1
  241. package/lib/component/title.js.map +1 -1
  242. package/lib/component/utils.d.ts +1 -1
  243. package/lib/component/utils.js +11 -11
  244. package/lib/component/utils.js.map +1 -1
  245. package/lib/composition/facetRect.js +2 -2
  246. package/lib/composition/facetRect.js.map +1 -1
  247. package/lib/composition/geoView.js +17 -7
  248. package/lib/composition/geoView.js.map +1 -1
  249. package/lib/composition/repeatMatrix.js.map +1 -1
  250. package/lib/composition/spaceFlex.js.map +1 -1
  251. package/lib/composition/timingKeyframe.js.map +1 -1
  252. package/lib/composition/utils.js +4 -5
  253. package/lib/composition/utils.js.map +1 -1
  254. package/lib/data/cluster.d.ts +1 -1
  255. package/lib/data/ema.js +2 -2
  256. package/lib/data/ema.js.map +1 -1
  257. package/lib/data/fetch.js.map +1 -1
  258. package/lib/data/filter.js +2 -2
  259. package/lib/data/filter.js.map +1 -1
  260. package/lib/data/fold.js +2 -2
  261. package/lib/data/fold.js.map +1 -1
  262. package/lib/data/kde.js +2 -2
  263. package/lib/data/kde.js.map +1 -1
  264. package/lib/data/pick.js.map +1 -1
  265. package/lib/data/rename.js +2 -2
  266. package/lib/data/rename.js.map +1 -1
  267. package/lib/data/sankey.js.map +1 -1
  268. package/lib/data/sort.js +2 -2
  269. package/lib/data/sort.js.map +1 -1
  270. package/lib/data/sortBy.js.map +1 -1
  271. package/lib/data/utils/arc/arc.d.ts +6 -6
  272. package/lib/data/utils/arc/arc.js +18 -9
  273. package/lib/data/utils/arc/arc.js.map +1 -1
  274. package/lib/data/utils/arc/sort.js +4 -5
  275. package/lib/data/utils/arc/sort.js.map +1 -1
  276. package/lib/data/utils/d3-cloud/index.js +1 -2
  277. package/lib/data/utils/d3-cloud/index.js.map +1 -1
  278. package/lib/data/utils/d3-sankey/align.js +4 -5
  279. package/lib/data/utils/d3-sankey/align.js.map +1 -1
  280. package/lib/data/utils/d3-sankey/constant.js +1 -2
  281. package/lib/data/utils/d3-sankey/constant.js.map +1 -1
  282. package/lib/data/utils/d3-sankey/sankey.d.ts +5 -5
  283. package/lib/data/utils/d3-sankey/sankey.js +1 -2
  284. package/lib/data/utils/d3-sankey/sankey.js.map +1 -1
  285. package/lib/data/utils/fields.js +1 -2
  286. package/lib/data/utils/fields.js.map +1 -1
  287. package/lib/data/utils/flow.js +1 -2
  288. package/lib/data/utils/flow.js.map +1 -1
  289. package/lib/data/utils/memo.js +4 -5
  290. package/lib/data/utils/memo.js.map +1 -1
  291. package/lib/data/utils/venn/circleintersection.js +7 -8
  292. package/lib/data/utils/venn/circleintersection.js.map +1 -1
  293. package/lib/data/utils/venn/diagram.js +1 -2
  294. package/lib/data/utils/venn/diagram.js.map +1 -1
  295. package/lib/data/utils/venn/fmin/bisect.js +1 -2
  296. package/lib/data/utils/venn/fmin/bisect.js.map +1 -1
  297. package/lib/data/utils/venn/fmin/blas1.js +7 -8
  298. package/lib/data/utils/venn/fmin/blas1.js.map +1 -1
  299. package/lib/data/utils/venn/fmin/conjugateGradient.js +2 -3
  300. package/lib/data/utils/venn/fmin/conjugateGradient.js.map +1 -1
  301. package/lib/data/utils/venn/fmin/gradientDescent.js +2 -3
  302. package/lib/data/utils/venn/fmin/gradientDescent.js.map +1 -1
  303. package/lib/data/utils/venn/fmin/linesearch.js +1 -2
  304. package/lib/data/utils/venn/fmin/linesearch.js.map +1 -1
  305. package/lib/data/utils/venn/fmin/nelderMead.js +1 -2
  306. package/lib/data/utils/venn/fmin/nelderMead.js.map +1 -1
  307. package/lib/data/utils/venn/layout.js +10 -11
  308. package/lib/data/utils/venn/layout.js.map +1 -1
  309. package/lib/data/wordCloud.js +3 -3
  310. package/lib/data/wordCloud.js.map +1 -1
  311. package/lib/index.d.ts +6 -0
  312. package/lib/interaction/adaptiveFilter.js +7 -8
  313. package/lib/interaction/adaptiveFilter.js.map +1 -1
  314. package/lib/interaction/brushAxisHighlight.js +4 -4
  315. package/lib/interaction/brushAxisHighlight.js.map +1 -1
  316. package/lib/interaction/brushFilter.js +2 -3
  317. package/lib/interaction/brushFilter.js.map +1 -1
  318. package/lib/interaction/brushHighlight.js +3 -4
  319. package/lib/interaction/brushHighlight.js.map +1 -1
  320. package/lib/interaction/brushXFilter.js +1 -2
  321. package/lib/interaction/brushXFilter.js.map +1 -1
  322. package/lib/interaction/brushXHighlight.js +2 -3
  323. package/lib/interaction/brushXHighlight.js.map +1 -1
  324. package/lib/interaction/brushYFilter.js +1 -2
  325. package/lib/interaction/brushYFilter.js.map +1 -1
  326. package/lib/interaction/brushYHighlight.js +2 -3
  327. package/lib/interaction/brushYHighlight.js.map +1 -1
  328. package/lib/interaction/chartIndex.js +1 -2
  329. package/lib/interaction/chartIndex.js.map +1 -1
  330. package/lib/interaction/drillDown.d.ts +6 -0
  331. package/lib/interaction/drillDown.js +213 -0
  332. package/lib/interaction/drillDown.js.map +1 -0
  333. package/lib/interaction/elementHighlight.js +2 -3
  334. package/lib/interaction/elementHighlight.js.map +1 -1
  335. package/lib/interaction/elementHighlightByColor.js +1 -2
  336. package/lib/interaction/elementHighlightByColor.js.map +1 -1
  337. package/lib/interaction/elementHighlightByX.js +1 -2
  338. package/lib/interaction/elementHighlightByX.js.map +1 -1
  339. package/lib/interaction/elementHoverScale.d.ts +23 -0
  340. package/lib/interaction/elementHoverScale.js +226 -0
  341. package/lib/interaction/elementHoverScale.js.map +1 -0
  342. package/lib/interaction/elementPointMove.js +1 -2
  343. package/lib/interaction/elementPointMove.js.map +1 -1
  344. package/lib/interaction/elementSelect.js +2 -3
  345. package/lib/interaction/elementSelect.js.map +1 -1
  346. package/lib/interaction/elementSelectByColor.js +1 -2
  347. package/lib/interaction/elementSelectByColor.js.map +1 -1
  348. package/lib/interaction/elementSelectByX.js +1 -2
  349. package/lib/interaction/elementSelectByX.js.map +1 -1
  350. package/lib/interaction/event.js +11 -4
  351. package/lib/interaction/event.js.map +1 -1
  352. package/lib/interaction/fisheye.js +1 -2
  353. package/lib/interaction/fisheye.js.map +1 -1
  354. package/lib/interaction/index.d.ts +2 -0
  355. package/lib/interaction/index.js +5 -1
  356. package/lib/interaction/index.js.map +1 -1
  357. package/lib/interaction/legendFilter.js +50 -28
  358. package/lib/interaction/legendFilter.js.map +1 -1
  359. package/lib/interaction/legendHighlight.js +1 -2
  360. package/lib/interaction/legendHighlight.js.map +1 -1
  361. package/lib/interaction/poptip.js +1 -2
  362. package/lib/interaction/poptip.js.map +1 -1
  363. package/lib/interaction/scrollbarFilter.js +4 -3
  364. package/lib/interaction/scrollbarFilter.js.map +1 -1
  365. package/lib/interaction/sliderFilter.js +2 -2
  366. package/lib/interaction/sliderFilter.js.map +1 -1
  367. package/lib/interaction/sliderWheel.js +1 -2
  368. package/lib/interaction/sliderWheel.js.map +1 -1
  369. package/lib/interaction/tooltip.js +12 -12
  370. package/lib/interaction/tooltip.js.map +1 -1
  371. package/lib/interaction/treemapDrillDown.js +1 -2
  372. package/lib/interaction/treemapDrillDown.js.map +1 -1
  373. package/lib/interaction/utils.d.ts +16 -2
  374. package/lib/interaction/utils.js +91 -43
  375. package/lib/interaction/utils.js.map +1 -1
  376. package/lib/label-transform/exceedAdjust.js +17 -0
  377. package/lib/label-transform/exceedAdjust.js.map +1 -1
  378. package/lib/label-transform/overflowStroke.js.map +1 -1
  379. package/lib/label-transform/overlapDodgeY.js.map +1 -1
  380. package/lib/label-transform/utils.js +2 -3
  381. package/lib/label-transform/utils.js.map +1 -1
  382. package/lib/lib/builtinlib.js +1 -2
  383. package/lib/lib/builtinlib.js.map +1 -1
  384. package/lib/lib/core.d.ts +3 -1
  385. package/lib/lib/core.js +3 -2
  386. package/lib/lib/core.js.map +1 -1
  387. package/lib/lib/geo.js +1 -2
  388. package/lib/lib/geo.js.map +1 -1
  389. package/lib/lib/graph.d.ts +1 -0
  390. package/lib/lib/graph.js +2 -2
  391. package/lib/lib/graph.js.map +1 -1
  392. package/lib/lib/lite.js +1 -2
  393. package/lib/lib/lite.js.map +1 -1
  394. package/lib/lib/plot.js +1 -2
  395. package/lib/lib/plot.js.map +1 -1
  396. package/lib/lib/std.d.ts +3 -0
  397. package/lib/lib/std.js +1 -2
  398. package/lib/lib/std.js.map +1 -1
  399. package/lib/mark/area.js.map +1 -1
  400. package/lib/mark/box.js +3 -3
  401. package/lib/mark/box.js.map +1 -1
  402. package/lib/mark/boxplot.js.map +1 -1
  403. package/lib/mark/chord.js +2 -2
  404. package/lib/mark/chord.js.map +1 -1
  405. package/lib/mark/density.js +1 -1
  406. package/lib/mark/density.js.map +1 -1
  407. package/lib/mark/gauge.js.map +1 -1
  408. package/lib/mark/index.d.ts +1 -0
  409. package/lib/mark/index.js +3 -1
  410. package/lib/mark/index.js.map +1 -1
  411. package/lib/mark/line.js.map +1 -1
  412. package/lib/mark/partition.d.ts +42 -0
  413. package/lib/mark/partition.js +223 -0
  414. package/lib/mark/partition.js.map +1 -0
  415. package/lib/mark/polygon.js.map +1 -1
  416. package/lib/mark/range.js +2 -2
  417. package/lib/mark/range.js.map +1 -1
  418. package/lib/mark/sankey.js.map +1 -1
  419. package/lib/mark/utils.js +16 -17
  420. package/lib/mark/utils.js.map +1 -1
  421. package/lib/runtime/component.js +10 -11
  422. package/lib/runtime/component.js.map +1 -1
  423. package/lib/runtime/coordinate.js +12 -13
  424. package/lib/runtime/coordinate.js.map +1 -1
  425. package/lib/runtime/layout.js +4 -5
  426. package/lib/runtime/layout.js.map +1 -1
  427. package/lib/runtime/library.js +2 -3
  428. package/lib/runtime/library.js.map +1 -1
  429. package/lib/runtime/mark.js +4 -5
  430. package/lib/runtime/mark.js.map +1 -1
  431. package/lib/runtime/option-preprocess/axis-breaks.js +2 -2
  432. package/lib/runtime/option-preprocess/axis-breaks.js.map +1 -1
  433. package/lib/runtime/option-preprocess/index.js +1 -2
  434. package/lib/runtime/option-preprocess/index.js.map +1 -1
  435. package/lib/runtime/option-preprocess/style.js +1 -2
  436. package/lib/runtime/option-preprocess/style.js.map +1 -1
  437. package/lib/runtime/plot.js +15 -5
  438. package/lib/runtime/plot.js.map +1 -1
  439. package/lib/runtime/render.js +3 -4
  440. package/lib/runtime/render.js.map +1 -1
  441. package/lib/runtime/scale.js +27 -18
  442. package/lib/runtime/scale.js.map +1 -1
  443. package/lib/runtime/transform.js +13 -13
  444. package/lib/runtime/transform.js.map +1 -1
  445. package/lib/shape/area/curve.js.map +1 -1
  446. package/lib/shape/axis-breaks/axis-breaks.js.map +1 -1
  447. package/lib/shape/box/box.js.map +1 -1
  448. package/lib/shape/box/violin.js.map +1 -1
  449. package/lib/shape/connector/connector.js.map +1 -1
  450. package/lib/shape/heatmap/renderer/gradient.js +1 -2
  451. package/lib/shape/heatmap/renderer/gradient.js.map +1 -1
  452. package/lib/shape/heatmap/renderer/index.js +1 -2
  453. package/lib/shape/heatmap/renderer/index.js.map +1 -1
  454. package/lib/shape/interval/color.js +2 -2
  455. package/lib/shape/interval/color.js.map +1 -1
  456. package/lib/shape/interval/funnel.js.map +1 -1
  457. package/lib/shape/interval/pyramid.js.map +1 -1
  458. package/lib/shape/label/label.js +17 -7
  459. package/lib/shape/label/label.js.map +1 -1
  460. package/lib/shape/label/position/area.js +1 -2
  461. package/lib/shape/label/position/area.js.map +1 -1
  462. package/lib/shape/label/position/default.js +6 -7
  463. package/lib/shape/label/position/default.js.map +1 -1
  464. package/lib/shape/label/position/outside.js +5 -6
  465. package/lib/shape/label/position/outside.js.map +1 -1
  466. package/lib/shape/label/position/spider.js +1 -2
  467. package/lib/shape/label/position/spider.js.map +1 -1
  468. package/lib/shape/label/position/surround.js +1 -2
  469. package/lib/shape/label/position/surround.js.map +1 -1
  470. package/lib/shape/label/position/utils.js +2 -3
  471. package/lib/shape/label/position/utils.js.map +1 -1
  472. package/lib/shape/line/curve.js.map +1 -1
  473. package/lib/shape/line/trail.js.map +1 -1
  474. package/lib/shape/link/arc.js.map +1 -1
  475. package/lib/shape/link/vhv.js.map +1 -1
  476. package/lib/shape/liquid/liquid.js.map +1 -1
  477. package/lib/shape/liquid/wave.js +1 -2
  478. package/lib/shape/liquid/wave.js.map +1 -1
  479. package/lib/shape/point/color.js +2 -2
  480. package/lib/shape/point/color.js.map +1 -1
  481. package/lib/shape/polygon/polygon.js.map +1 -1
  482. package/lib/shape/polygon/ribbon.js.map +1 -1
  483. package/lib/shape/text/advance.d.ts +1 -1
  484. package/lib/shape/text/advance.js.map +1 -1
  485. package/lib/shape/utils.js +11 -12
  486. package/lib/shape/utils.js.map +1 -1
  487. package/lib/shape/vector/vector.js.map +1 -1
  488. package/lib/spec/interaction.d.ts +23 -2
  489. package/lib/spec/mark.d.ts +13 -2
  490. package/lib/theme/create.d.ts +1 -1
  491. package/lib/theme/create.js +4 -4
  492. package/lib/theme/create.js.map +1 -1
  493. package/lib/theme/dark.js +5 -4
  494. package/lib/theme/dark.js.map +1 -1
  495. package/lib/transform/diffY.js.map +1 -1
  496. package/lib/transform/dodgeX.js.map +1 -1
  497. package/lib/transform/filter.js.map +1 -1
  498. package/lib/transform/jitter.js +3 -3
  499. package/lib/transform/jitter.js.map +1 -1
  500. package/lib/transform/maybeDefaultX.js.map +1 -1
  501. package/lib/transform/maybeDefaultY.js.map +1 -1
  502. package/lib/transform/maybeTitle.js.map +1 -1
  503. package/lib/transform/maybeVisualPosition.js +1 -1
  504. package/lib/transform/maybeVisualPosition.js.map +1 -1
  505. package/lib/transform/normalizeY.js.map +1 -1
  506. package/lib/transform/pack.js.map +1 -1
  507. package/lib/transform/sample.js.map +1 -1
  508. package/lib/transform/sort.js.map +1 -1
  509. package/lib/transform/stackEnter.js.map +1 -1
  510. package/lib/transform/stackY.js +2 -2
  511. package/lib/transform/stackY.js.map +1 -1
  512. package/lib/transform/symmetryY.js.map +1 -1
  513. package/lib/transform/utils/helper.js +8 -9
  514. package/lib/transform/utils/helper.js.map +1 -1
  515. package/lib/transform/utils/lttb.js +1 -2
  516. package/lib/transform/utils/lttb.js.map +1 -1
  517. package/lib/transform/utils/order.js +4 -5
  518. package/lib/transform/utils/order.js.map +1 -1
  519. package/lib/utils/angle.js +3 -4
  520. package/lib/utils/angle.js.map +1 -1
  521. package/lib/utils/array.js +9 -10
  522. package/lib/utils/array.js.map +1 -1
  523. package/lib/utils/bounds.js +4 -5
  524. package/lib/utils/bounds.js.map +1 -1
  525. package/lib/utils/color.js +1 -2
  526. package/lib/utils/color.js.map +1 -1
  527. package/lib/utils/coordinate.d.ts +0 -1
  528. package/lib/utils/coordinate.js +14 -15
  529. package/lib/utils/coordinate.js.map +1 -1
  530. package/lib/utils/createElement.js +1 -2
  531. package/lib/utils/createElement.js.map +1 -1
  532. package/lib/utils/dateFormat.js +1 -2
  533. package/lib/utils/dateFormat.js.map +1 -1
  534. package/lib/utils/expr.js +2 -2
  535. package/lib/utils/expr.js.map +1 -1
  536. package/lib/utils/flow.js +1 -2
  537. package/lib/utils/flow.js.map +1 -1
  538. package/lib/utils/helper.js +30 -31
  539. package/lib/utils/helper.js.map +1 -1
  540. package/lib/utils/lru.js +1 -2
  541. package/lib/utils/lru.js.map +1 -1
  542. package/lib/utils/mark.js +4 -5
  543. package/lib/utils/mark.js.map +1 -1
  544. package/lib/utils/marker.d.ts +1 -1
  545. package/lib/utils/marker.js +4 -4
  546. package/lib/utils/marker.js.map +1 -1
  547. package/lib/utils/number.js +2 -3
  548. package/lib/utils/number.js.map +1 -1
  549. package/lib/utils/scale.js +7 -7
  550. package/lib/utils/scale.js.map +1 -1
  551. package/lib/utils/selection.js +2 -2
  552. package/lib/utils/selection.js.map +1 -1
  553. package/lib/utils/size.js +2 -3
  554. package/lib/utils/size.js.map +1 -1
  555. package/lib/utils/string.js +2 -3
  556. package/lib/utils/string.js.map +1 -1
  557. package/lib/utils/style.js +4 -5
  558. package/lib/utils/style.js.map +1 -1
  559. package/lib/utils/traverse-elements.js +1 -2
  560. package/lib/utils/traverse-elements.js.map +1 -1
  561. package/lib/utils/treeDataTransform.js +1 -2
  562. package/lib/utils/treeDataTransform.js.map +1 -1
  563. package/lib/utils/vector.js +8 -9
  564. package/lib/utils/vector.js.map +1 -1
  565. package/package.json +6 -5
  566. package/src/api/runtime.ts +5 -0
  567. package/src/component/axis.ts +3 -0
  568. package/src/component/constant.ts +12 -0
  569. package/src/component/legendCategory.ts +4 -1
  570. package/src/component/legendContinuous.ts +2 -0
  571. package/src/component/scrollbar.ts +2 -1
  572. package/src/interaction/drillDown.ts +258 -0
  573. package/src/interaction/elementHoverScale.ts +285 -0
  574. package/src/interaction/event.ts +10 -2
  575. package/src/interaction/index.ts +2 -0
  576. package/src/interaction/legendFilter.ts +42 -7
  577. package/src/interaction/scrollbarFilter.ts +2 -1
  578. package/src/interaction/tooltip.ts +6 -5
  579. package/src/interaction/utils.ts +65 -8
  580. package/src/label-transform/exceedAdjust.ts +22 -0
  581. package/src/lib/core.ts +4 -0
  582. package/src/lib/graph.ts +10 -1
  583. package/src/mark/index.ts +1 -0
  584. package/src/mark/partition.ts +312 -0
  585. package/src/runtime/mark.ts +2 -2
  586. package/src/runtime/plot.ts +11 -1
  587. package/src/spec/interaction.ts +28 -1
  588. package/src/spec/mark.ts +18 -0
  589. package/src/theme/create.ts +3 -1
  590. package/src/theme/dark.ts +5 -4
  591. package/src/utils/helper.ts +6 -6
@@ -1,5 +1,6 @@
1
1
  import { DisplayObject } from '@antv/g';
2
2
  import { deepMix, throttle } from '@antv/util';
3
+ import { Base } from '@antv/scale';
3
4
  import { subObject } from '../utils/helper';
4
5
  import { ANNOTATION_MARKS } from '../component/constant';
5
6
  import { useState, setCursor, restoreCursor } from './utils';
@@ -69,6 +70,21 @@ export function attributesOf(root) {
69
70
  return child.attributes;
70
71
  }
71
72
 
73
+ function getScaleByMarkKey(
74
+ scale: Record<string, Base<any>>,
75
+ markKey: string,
76
+ channelName: string,
77
+ ) {
78
+ const seriesKey = Object.keys(scale).find((channel) => {
79
+ if (channel.startsWith(channelName)) {
80
+ const options = scale[channel].getOptions();
81
+ return options.name === channelName && options.markKey === markKey;
82
+ }
83
+ });
84
+
85
+ return scale[seriesKey] ?? scale[channelName];
86
+ }
87
+
72
88
  function legendFilterOrdinal(
73
89
  root: DisplayObject,
74
90
  {
@@ -493,9 +509,20 @@ async function filterView(
493
509
  const { marks } = viewOptions;
494
510
  // Add filter transform for every marks,
495
511
  // which will skip for mark without color channel.
512
+
513
+ const channelScale = legend.attributes?.scales?.find(
514
+ (s) => s.name === channel,
515
+ );
496
516
  const newMarks = marks.map((mark) => {
497
- if (mark.type === 'legends') return mark;
517
+ // Only filter marks with the same scale key.
518
+ if (
519
+ // if key is not defined, use default channel name.
520
+ (mark.scale[channel].key ?? channel) !==
521
+ (channelScale?.key ?? channelScale?.name)
522
+ )
523
+ return mark;
498
524
 
525
+ if (mark.type === 'legends') return mark;
499
526
  // Skip Annotation marks.
500
527
  if (ANNOTATION_MARKS.includes(mark.type)) return mark;
501
528
 
@@ -508,16 +535,24 @@ async function filterView(
508
535
  if (data.length) {
509
536
  newTransform.splice(index + 1, 0, {
510
537
  type: 'filter',
511
- [channel]: { value, ordinal },
538
+ [channel]: {
539
+ value,
540
+ ordinal,
541
+ },
512
542
  });
513
543
  }
514
544
 
515
545
  // Set domain of scale to preserve encoding.
516
546
  const newScale = Object.fromEntries(
517
- channels.map((channel) => [
518
- channel,
519
- { domain: view.scale[channel].getOptions().domain },
520
- ]),
547
+ channels.map((channel) => {
548
+ const matchScale = getScaleByMarkKey(
549
+ view.scale,
550
+ viewOptions.key,
551
+ channel,
552
+ );
553
+
554
+ return [channel, { domain: matchScale.getOptions().domain }];
555
+ }),
521
556
  );
522
557
  return deepMix({}, mark, {
523
558
  transform: newTransform,
@@ -570,7 +605,7 @@ export function LegendFilter() {
570
605
  };
571
606
 
572
607
  if (legend.className === CATEGORY_LEGEND_CLASS_NAME) {
573
- return legendFilterOrdinal(container, {
608
+ return legendFilterOrdinal(legend, {
574
609
  legends: itemsOf,
575
610
  marker: markerOf,
576
611
  label: labelOf,
@@ -1,6 +1,7 @@
1
+ import { G2_CLASS_PREFIX } from '../component/constant';
1
2
  import { SliderFilter } from './sliderFilter';
2
3
 
3
- export const SCROLLBAR_CLASS_NAME = 'g2-scrollbar';
4
+ export const SCROLLBAR_CLASS_NAME = `${G2_CLASS_PREFIX}scrollbar`;
4
5
 
5
6
  export function ScrollbarFilter(options: any = {}) {
6
7
  return (context, _, emitter) => {
@@ -14,6 +14,7 @@ import { angle, sub, dist } from '../utils/vector';
14
14
  import { invert } from '../utils/scale';
15
15
  import { BBox } from '../runtime';
16
16
  import { CALLBACK_ITEM_SYMBOL } from '../runtime/transform';
17
+ import { G2_CLASS_PREFIX, g2Selector } from '../component/constant';
17
18
  import {
18
19
  selectG2Elements,
19
20
  createXKey,
@@ -79,8 +80,8 @@ function createTooltip(
79
80
  offset: [number, number] = [10, 10],
80
81
  ) {
81
82
  const defaults = {
82
- '.g2-tooltip': {},
83
- '.g2-tooltip-title': {
83
+ [g2Selector('tooltip')]: {},
84
+ [g2Selector('tooltip-title')]: {
84
85
  overflow: 'hidden',
85
86
  'white-space': 'nowrap',
86
87
  'text-overflow': 'ellipsis',
@@ -99,7 +100,7 @@ function createTooltip(
99
100
  title: '',
100
101
  offset,
101
102
  template: {
102
- prefixCls: 'g2-',
103
+ prefixCls: G2_CLASS_PREFIX,
103
104
  },
104
105
  style: deepMix(defaults, css),
105
106
  },
@@ -529,7 +530,7 @@ function updateMarker(root, { data, style, theme }) {
529
530
  const fill = type === 'hollow' ? 'transparent' : originColor;
530
531
  const stroke = type === 'hollow' ? originColor : '#fff';
531
532
  const shape = new Circle({
532
- className: 'g2-tooltip-marker',
533
+ className: `${G2_CLASS_PREFIX}tooltip-marker`,
533
534
  style: {
534
535
  cx: point[0],
535
536
  cy: point[1],
@@ -1111,7 +1112,7 @@ export function seriesTooltip(
1111
1112
  const scaleX = scale.x;
1112
1113
  const x1 = scaleX.map(x);
1113
1114
  const [x2, y2] = coordinate.map([x1, 0.5]);
1114
- const rootBounds = root.getRenderBounds();
1115
+ const rootBounds = bboxOf(root);
1115
1116
  const minX = rootBounds.min[0];
1116
1117
  const minY = rootBounds.min[1];
1117
1118
  update({
@@ -830,17 +830,47 @@ export function extractChannelValues(view: G2ViewDescriptor): {
830
830
  };
831
831
  }
832
832
 
833
+ /**
834
+ * Check if there are multiple independent axis for a given channel.
835
+ * Multi-axis can be defined by:
836
+ * 1. Explicit `independent: true` in scale configuration
837
+ * 2. Different `scale.key` values for the same channel name
838
+ *
839
+ * @param channel1 - Channel name (x or y)
840
+ * @param marks - Array of marks to check
841
+ * @returns true if multiple independent axis exist
842
+ */
833
843
  export function hasIndependentXYScale(
834
844
  channel1: string,
835
845
  marks: readonly unknown[],
836
846
  ): boolean {
837
- return marks.some((mark) => {
847
+ const scaleKeys = new Set<string>();
848
+
849
+ for (const mark of marks) {
838
850
  const { scale: markScale } = mark as Record<string, unknown>;
839
851
  const channelScale = (markScale as Record<string, unknown>)?.[channel1] as
840
852
  | Record<string, unknown>
841
853
  | undefined;
842
- return !!channelScale?.independent;
843
- });
854
+
855
+ if (!channelScale) continue;
856
+
857
+ // Early return if explicit independent flag is found
858
+ if (channelScale.independent) {
859
+ return true;
860
+ }
861
+
862
+ // Collect scale keys, treating undefined/missing key as 'default'
863
+ const key = (channelScale.key as string | undefined) || 'default';
864
+ scaleKeys.add(key);
865
+
866
+ // Early return if multiple different keys are detected
867
+ if (scaleKeys.size > 1) {
868
+ return true;
869
+ }
870
+ }
871
+
872
+ // No multiple axes detected
873
+ return false;
844
874
  }
845
875
 
846
876
  /**
@@ -928,6 +958,10 @@ export interface IndependentScaleInfo {
928
958
  * This function performs a single traversal to compute all independent scale related information,
929
959
  * avoiding repeated calculations throughout the codebase.
930
960
  *
961
+ * Multi-axis detection logic:
962
+ * 1. Explicit independent: scale.y.independent = true
963
+ * 2. Different scale keys: scale.y.key = 'left' vs scale.y.key = 'right'
964
+ *
931
965
  * @param view The view object containing markState
932
966
  * @returns Complete independent scale information
933
967
  */
@@ -946,26 +980,49 @@ export function calculateAllIndependentScaleInfo(
946
980
  const markToXScaleMap = new Map<string, string>();
947
981
  const markToYScaleMap = new Map<string, string>();
948
982
 
949
- // Single traversal to compute all classifications and mappings
983
+ // Track scale key assignments
984
+ const xScaleKeyMap = new Map<string, number>(); // key -> index
985
+ const yScaleKeyMap = new Map<string, number>(); // key -> index
950
986
  let xIndex = 1;
951
987
  let yIndex = 1;
952
988
 
989
+ // Single traversal to compute all classifications and mappings
953
990
  for (const [mark] of view.markState.entries()) {
954
991
  const markKey = mark.key;
955
992
 
956
993
  // X axis processing
957
- if (mark?.scale?.x?.independent) {
994
+ const xScaleKey = (mark?.scale?.x?.key as string) || 'x';
995
+ const hasExplicitIndependentX = !!mark?.scale?.x?.independent;
996
+
997
+ if (hasExplicitIndependentX || (hasIndependentX && xScaleKey !== 'x')) {
958
998
  marksWithIndependentX.push(markKey);
959
- markToXScaleMap.set(markKey, `x${xIndex++}`);
999
+
1000
+ // Assign scale name based on key
1001
+ // Always use indexed names (x1, x2, ...) to avoid collision with shared 'x'
1002
+ if (!xScaleKeyMap.has(xScaleKey)) {
1003
+ xScaleKeyMap.set(xScaleKey, xIndex++);
1004
+ }
1005
+ const scaleIndex = xScaleKeyMap.get(xScaleKey);
1006
+ markToXScaleMap.set(markKey, `x${scaleIndex}`);
960
1007
  } else {
961
1008
  marksWithSharedX.push(markKey);
962
1009
  markToXScaleMap.set(markKey, 'x');
963
1010
  }
964
1011
 
965
1012
  // Y axis processing
966
- if (mark?.scale?.y?.independent) {
1013
+ const yScaleKey = (mark?.scale?.y?.key as string) || 'y';
1014
+ const hasExplicitIndependentY = !!mark?.scale?.y?.independent;
1015
+
1016
+ if (hasExplicitIndependentY || (hasIndependentY && yScaleKey !== 'y')) {
967
1017
  marksWithIndependentY.push(markKey);
968
- markToYScaleMap.set(markKey, `y${yIndex++}`);
1018
+
1019
+ // Assign scale name based on key
1020
+ // Always use indexed names (y1, y2, ...) to avoid collision with shared 'y'
1021
+ if (!yScaleKeyMap.has(yScaleKey)) {
1022
+ yScaleKeyMap.set(yScaleKey, yIndex++);
1023
+ }
1024
+ const scaleIndex = yScaleKeyMap.get(yScaleKey);
1025
+ markToYScaleMap.set(markKey, `y${scaleIndex}`);
969
1026
  } else {
970
1027
  marksWithSharedY.push(markKey);
971
1028
  markToYScaleMap.set(markKey, 'y');
@@ -29,6 +29,17 @@ const adjustPosition = (target: Bounds, edge: Bounds) => {
29
29
  };
30
30
 
31
31
  const union = (a: AABB, b: AABB) => {
32
+ // Handle null bounds by returning the non-null one, or a default AABB
33
+ if (!a || !a.min || !a.max) {
34
+ if (!b || !b.min || !b.max) {
35
+ return { min: [0, 0], max: [0, 0] };
36
+ }
37
+ return b;
38
+ }
39
+ if (!b || !b.min || !b.max) {
40
+ return a;
41
+ }
42
+
32
43
  return {
33
44
  min: [Math.min(a.min[0], b.min[0]), Math.min(a.min[1], b.min[1])],
34
45
  max: [Math.max(a.max[0], b.max[0]), Math.max(a.max[1], b.max[1])],
@@ -93,6 +104,17 @@ export const ExceedAdjust: LLC<ExceedAdjustOptions> = (options = {}) => {
93
104
  labels.forEach((l) => {
94
105
  show(l);
95
106
  const { max, min } = union(l.getRenderBounds(), l.getBounds());
107
+
108
+ // Skip labels with invalid bounds (filtered out data points)
109
+ // When bounds are all zeros or invalid, it means the label shouldn't be displayed
110
+ if (
111
+ !max ||
112
+ !min ||
113
+ (max[0] === 0 && max[1] === 0 && min[0] === 0 && min[1] === 0)
114
+ ) {
115
+ return;
116
+ }
117
+
96
118
  const [xMax, yMax] = max,
97
119
  [xMin, yMin] = min;
98
120
  const changeValue = adjustPosition(
package/src/lib/core.ts CHANGED
@@ -85,6 +85,7 @@ import {
85
85
  ElementHighlight,
86
86
  ElementHighlightByX,
87
87
  ElementHighlightByColor,
88
+ ElementHoverScale,
88
89
  ElementSelect,
89
90
  ElementSelectByX,
90
91
  ElementSelectByColor,
@@ -105,6 +106,7 @@ import {
105
106
  Poptip,
106
107
  ScrollbarFilter,
107
108
  TreemapDrillDown,
109
+ DrillDown,
108
110
  ElementPointMove,
109
111
  } from '../interaction';
110
112
  import {
@@ -296,6 +298,7 @@ export function corelib() {
296
298
  'interaction.elementHighlight': ElementHighlight,
297
299
  'interaction.elementHighlightByX': ElementHighlightByX,
298
300
  'interaction.elementHighlightByColor': ElementHighlightByColor,
301
+ 'interaction.elementHoverScale': ElementHoverScale,
299
302
  'interaction.elementSelect': ElementSelect,
300
303
  'interaction.elementSelectByX': ElementSelectByX,
301
304
  'interaction.elementSelectByColor': ElementSelectByColor,
@@ -316,6 +319,7 @@ export function corelib() {
316
319
  'interaction.scrollbarFilter': ScrollbarFilter,
317
320
  'interaction.poptip': Poptip,
318
321
  'interaction.treemapDrillDown': TreemapDrillDown,
322
+ 'interaction.drillDown': DrillDown,
319
323
  'interaction.elementPointMove': ElementPointMove,
320
324
  'composition.spaceLayer': SpaceLayer,
321
325
  'composition.spaceFlex': SpaceFlex,
package/src/lib/graph.ts CHANGED
@@ -1,4 +1,12 @@
1
- import { Sankey, Treemap, Pack, ForceGraph, Tree, Chord } from '../mark';
1
+ import {
2
+ Sankey,
3
+ Treemap,
4
+ Pack,
5
+ ForceGraph,
6
+ Tree,
7
+ Chord,
8
+ Partition,
9
+ } from '../mark';
2
10
  import { Arc, Cluster } from '../data';
3
11
 
4
12
  export function graphlib() {
@@ -11,5 +19,6 @@ export function graphlib() {
11
19
  'mark.sankey': Sankey,
12
20
  'mark.chord': Chord,
13
21
  'mark.treemap': Treemap,
22
+ 'mark.partition': Partition,
14
23
  } as const;
15
24
  }
package/src/mark/index.ts CHANGED
@@ -31,6 +31,7 @@ export { Density } from './density';
31
31
  export { Heatmap } from './heatmap';
32
32
  export { Liquid } from './liquid';
33
33
  export { Beeswarm } from './beeswarm';
34
+ export { Partition } from './partition';
34
35
 
35
36
  export type { IntervalOptions } from './interval';
36
37
  export type { RectOptions } from './rect';
@@ -0,0 +1,312 @@
1
+ import { deepMix, pick } from '@antv/util';
2
+ import { CompositeMarkComponent } from '../runtime';
3
+ import { BaseMark, ChannelTypes, PartitionNode } from '../spec';
4
+ export type PartitionMark = BaseMark<'rect', 'value' | ChannelTypes>;
5
+
6
+ export interface PartitionDataNode {
7
+ data: PartitionNode;
8
+ depth: number;
9
+ parent: PartitionDataNode | null;
10
+ children: PartitionDataNode[];
11
+ x0: number;
12
+ x1: number;
13
+ value: number;
14
+ }
15
+
16
+ export interface LayoutOptions {
17
+ valueField?: string;
18
+ sort?: (a: PartitionNode, b: PartitionNode) => number;
19
+ fillParent?: boolean; // Whether child nodes fill parent width.
20
+ nameField?: string;
21
+ }
22
+
23
+ /**
24
+ * Partition layout algorithm.
25
+ * Child nodes start layout from the parent's starting position to show parent-child relationships.
26
+ *
27
+ * @param data Hierarchical data
28
+ * @param options Configuration options
29
+ */
30
+ export function partitionLayout(
31
+ data: PartitionNode[],
32
+ options: LayoutOptions = {},
33
+ ) {
34
+ const {
35
+ valueField = 'value',
36
+ sort,
37
+ fillParent = true,
38
+ nameField = 'name',
39
+ } = options;
40
+
41
+ if (!data || data.length === 0) return [];
42
+
43
+ // Build hierarchical structure
44
+ const buildPartition = (
45
+ node: PartitionNode,
46
+ parent: PartitionDataNode | null = null,
47
+ depth = 0,
48
+ ): PartitionDataNode => {
49
+ const partitionNode: PartitionDataNode = {
50
+ data: node,
51
+ depth,
52
+ parent,
53
+ children: [],
54
+ x0: 0,
55
+ x1: 0,
56
+ value: node[valueField] || 0,
57
+ };
58
+
59
+ if (node.children && node.children.length > 0) {
60
+ partitionNode.children = node.children.map((child: PartitionNode) =>
61
+ buildPartition(child, partitionNode, depth + 1),
62
+ );
63
+ }
64
+
65
+ return partitionNode;
66
+ };
67
+
68
+ // Process each root node
69
+ const result: Array<Record<string, any>> = [];
70
+ let currentRootStartX = 0; // Track the starting position for the next root node
71
+
72
+ data.forEach((rootData: PartitionNode) => {
73
+ const root = buildPartition(rootData);
74
+
75
+ // Calculate position for each node - key point: child nodes start layout from parent's starting position
76
+ const calculateLayout = (
77
+ node: PartitionDataNode,
78
+ parentStartX = 0,
79
+ isRootNode = false,
80
+ parentWidth = 0, // Parent node actual width.
81
+ ): void => {
82
+ if (isRootNode || node.depth === 0) {
83
+ // Root node: start from current root position
84
+ node.x0 = isRootNode ? parentStartX : 0;
85
+ node.x1 = node.x0 + node.value;
86
+ } else {
87
+ // Child node: start layout from parent's starting position
88
+ node.x0 = parentStartX;
89
+ if (fillParent && parentWidth > 0) {
90
+ // If fillParent is true, calculate width based on parent width and value ratio.
91
+ const siblingsTotalValue = node.parent
92
+ ? node.parent.children.reduce((acc, child) => acc + child.value, 0)
93
+ : node.value;
94
+ const siblingsCount = node.parent ? node.parent.children.length : 1;
95
+ const ratio =
96
+ siblingsTotalValue > 0
97
+ ? node.value / siblingsTotalValue
98
+ : 1 / siblingsCount;
99
+ node.x1 = parentStartX + parentWidth * ratio;
100
+ } else {
101
+ // If fillParent is false, use node own value as width.
102
+ node.x1 = parentStartX + node.value;
103
+ }
104
+ }
105
+
106
+ // Calculate position for child nodes - start from current node's starting position
107
+ let childStartX = node.x0;
108
+ const nodeWidth = node.x1 - node.x0;
109
+
110
+ const sortedChildren = sort
111
+ ? [...node.children].sort(
112
+ (a: PartitionDataNode, b: PartitionDataNode) =>
113
+ sort(a.data, b.data),
114
+ )
115
+ : node.children;
116
+
117
+ if (fillParent && sortedChildren.length > 0) {
118
+ // fillParent mode: child nodes fill parent width proportionally.
119
+ const childrenTotalValue = node.children.reduce(
120
+ (sum, c) => sum + c.value,
121
+ 0,
122
+ );
123
+ sortedChildren.forEach((child: PartitionDataNode) => {
124
+ calculateLayout(child, childStartX, false, nodeWidth);
125
+ const ratio =
126
+ childrenTotalValue > 0
127
+ ? child.value / childrenTotalValue
128
+ : 1 / sortedChildren.length;
129
+ childStartX += nodeWidth * ratio;
130
+ });
131
+ } else {
132
+ // Non-fillParent mode: child nodes layout independently based on own value.
133
+ sortedChildren.forEach((child: PartitionDataNode) => {
134
+ calculateLayout(child, childStartX, false, 0);
135
+ // Next child node starts from current child node's end position.
136
+ childStartX += child.x1 - child.x0;
137
+ });
138
+ }
139
+ };
140
+
141
+ // Start layout calculation from root node, using current root start position.
142
+ calculateLayout(root, currentRootStartX, true);
143
+
144
+ // Update the starting position for the next root node.
145
+ currentRootStartX += root.value;
146
+
147
+ // Convert to final format.
148
+ const processNode = (node: PartitionDataNode): Record<string, any> => {
149
+ const getName = (d: PartitionNode) => d[nameField] ?? d.name;
150
+ const path = [getName(node.data)];
151
+ let ancestorNode = node;
152
+ while (ancestorNode.parent) {
153
+ path.unshift(getName(ancestorNode.parent.data));
154
+ ancestorNode = ancestorNode.parent;
155
+ }
156
+
157
+ return {
158
+ ...pick(node.data, [valueField]),
159
+ [PARTITION_PATH_FIELD]: path,
160
+ [PARTITION_ANCESTOR_FIELD]:
161
+ ancestorNode.parent?.data?.[nameField] ?? node.data[nameField],
162
+ name: node.data[nameField],
163
+ depth: node.depth,
164
+ value: node.value,
165
+ x: [node.x0, node.x1],
166
+ y: [node.depth, node.depth + 1],
167
+ // Add child node count attribute for drill-down interaction judgment.
168
+ [CHILD_NODE_COUNT]: node.children.length,
169
+ };
170
+ };
171
+
172
+ // Collect all nodes.
173
+ const collectResultNodes = (node: PartitionDataNode): void => {
174
+ result.push(processNode(node));
175
+ node.children.forEach(collectResultNodes);
176
+ };
177
+
178
+ collectResultNodes(root);
179
+ });
180
+
181
+ return result;
182
+ }
183
+
184
+ export type PartitionData = PartitionNode[];
185
+
186
+ export type PartitionOptions = Omit<PartitionMark, 'type'> & {
187
+ fillParent?: boolean; // Whether child nodes fill parent width.
188
+ };
189
+
190
+ export const PARTITION_TYPE = 'partition';
191
+ export const PARTITION_TYPE_FIELD = 'markType';
192
+ export const PARTITION_PATH_FIELD = 'path';
193
+ export const PARTITION_ANCESTOR_FIELD = 'ancestor-node';
194
+ export const CHILD_NODE_COUNT = 'childNodeCount';
195
+
196
+ export function transformData(
197
+ options: Pick<PartitionOptions, 'data' | 'encode'> & {
198
+ fillParent?: boolean;
199
+ sort?: (a: PartitionNode, b: PartitionNode) => number;
200
+ },
201
+ ) {
202
+ const { data, encode, fillParent, sort } = options;
203
+ const { color, value, name } = encode as any;
204
+
205
+ const nodes = partitionLayout(data, {
206
+ valueField: value,
207
+ fillParent,
208
+ nameField: name,
209
+ sort,
210
+ });
211
+
212
+ return nodes.map((node: Record<string, any>) => {
213
+ // Handle color mapping.
214
+ const nodeInfo = { ...node };
215
+ if (color && color !== PARTITION_ANCESTOR_FIELD) {
216
+ nodeInfo[color] = node[color];
217
+ }
218
+ return nodeInfo;
219
+ });
220
+ }
221
+
222
+ const DEFAULT_OPTIONS = {
223
+ id: PARTITION_TYPE,
224
+ encode: {
225
+ x: 'x',
226
+ y: 'y',
227
+ key: PARTITION_PATH_FIELD,
228
+ color: PARTITION_ANCESTOR_FIELD,
229
+ value: 'value',
230
+ name: 'name',
231
+ },
232
+ labels: [
233
+ {
234
+ style: {
235
+ pointerEvents: 'none',
236
+ },
237
+ text: 'value',
238
+ position: 'inside',
239
+ transform: [
240
+ {
241
+ type: 'overflowHide',
242
+ },
243
+ ],
244
+ },
245
+ ],
246
+ axis: {
247
+ x: { title: 'Time/Order', label: true },
248
+ y: false,
249
+ },
250
+ style: {
251
+ [PARTITION_TYPE_FIELD]: PARTITION_TYPE,
252
+ [CHILD_NODE_COUNT]: 'childNodeCount', // Add child node count attribute for drill-down interaction.
253
+ },
254
+ state: {
255
+ active: { zIndex: 2 },
256
+ inactive: { zIndex: 1 },
257
+ },
258
+ legend: false,
259
+ coordinate: {
260
+ type: 'cartesian',
261
+ grid: false, // Remove grid lines.
262
+ },
263
+ interaction: {
264
+ drillDown: true,
265
+ },
266
+ };
267
+
268
+ export const Partition: CompositeMarkComponent<PartitionOptions> = (
269
+ options,
270
+ ) => {
271
+ const {
272
+ encode: encodeOption,
273
+ data = [],
274
+ layout = {},
275
+ ...resOptions
276
+ } = options;
277
+
278
+ const { fillParent = true, sort } = layout as {
279
+ fillParent?: boolean;
280
+ sort?: (a: PartitionNode, b: PartitionNode) => number;
281
+ };
282
+
283
+ const encode = { ...DEFAULT_OPTIONS.encode, ...encodeOption };
284
+ const { value } = encode;
285
+ const rectData = transformData({ encode, data, fillParent, sort });
286
+
287
+ return [
288
+ deepMix({}, DEFAULT_OPTIONS, {
289
+ type: 'rect',
290
+ data: rectData,
291
+ encode,
292
+ tooltip: {
293
+ title: 'path',
294
+ items: [
295
+ (d: Record<string, any>) => {
296
+ return {
297
+ name: value as string,
298
+ value: d[value],
299
+ };
300
+ },
301
+ ],
302
+ },
303
+ // Add basic interaction.
304
+ interaction: {
305
+ elementHighlight: true,
306
+ },
307
+ ...resOptions,
308
+ }),
309
+ ];
310
+ };
311
+
312
+ Partition.props = {};
@@ -39,7 +39,7 @@ export async function initializeMark(
39
39
  context,
40
40
  );
41
41
 
42
- const { encode, scale, data, tooltip, key: markerKey } = transformedMark;
42
+ const { encode, scale, data, tooltip, key: markKey } = transformedMark;
43
43
 
44
44
  // Skip mark with non-tabular data. Do not skip empty
45
45
  // data, they are useful for facet to display axes.
@@ -107,7 +107,7 @@ export async function initializeMark(
107
107
  scaleKey: independent || isConstant ? Symbol('independent') : key,
108
108
  scale: {
109
109
  type,
110
- markerKey,
110
+ markKey,
111
111
  range: finalRange,
112
112
  ...scaleOptions,
113
113
  quantitative,