@antv/g6 5.0.0-beta.33 → 5.0.0-beta.35

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 (514) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/animations/types.d.ts +3 -4
  3. package/dist/lib/behaviors/base-behavior.d.ts +2 -1
  4. package/dist/lib/behaviors/brush-select.d.ts +33 -16
  5. package/dist/lib/behaviors/click-element.d.ts +28 -5
  6. package/dist/lib/behaviors/collapse-expand.d.ts +3 -2
  7. package/dist/lib/behaviors/create-edge.d.ts +1 -2
  8. package/dist/lib/behaviors/drag-canvas.d.ts +7 -0
  9. package/dist/lib/behaviors/drag-element-force.d.ts +1 -2
  10. package/dist/lib/behaviors/drag-element.d.ts +4 -5
  11. package/dist/lib/behaviors/index.d.ts +2 -0
  12. package/dist/lib/behaviors/lasso-select.d.ts +4 -4
  13. package/dist/lib/behaviors/scroll-canvas.d.ts +64 -0
  14. package/dist/lib/behaviors/types.d.ts +2 -1
  15. package/dist/lib/behaviors/zoom-canvas.d.ts +1 -1
  16. package/dist/lib/constants/events/animation.d.ts +1 -4
  17. package/dist/lib/constants/events/graph.d.ts +5 -1
  18. package/dist/lib/elements/combos/base-combo.d.ts +1 -1
  19. package/dist/lib/elements/edges/base-edge.d.ts +0 -5
  20. package/dist/lib/elements/nodes/base-node.d.ts +3 -10
  21. package/dist/lib/elements/nodes/donut.d.ts +45 -0
  22. package/dist/lib/elements/nodes/html.d.ts +27 -0
  23. package/dist/lib/elements/nodes/index.d.ts +4 -0
  24. package/dist/lib/elements/shapes/badge.d.ts +1 -1
  25. package/dist/lib/{plugins/hull/shape.d.ts → elements/shapes/contour.d.ts} +17 -17
  26. package/dist/lib/elements/shapes/index.d.ts +2 -0
  27. package/dist/lib/exports.d.ts +15 -22
  28. package/dist/lib/plugins/bubble-sets.d.ts +45 -0
  29. package/dist/lib/plugins/camera-setting.d.ts +4 -2
  30. package/dist/lib/plugins/contextmenu.d.ts +1 -0
  31. package/dist/lib/plugins/grid-line.d.ts +51 -8
  32. package/dist/lib/plugins/hull/index.d.ts +44 -13
  33. package/dist/lib/plugins/index.d.ts +4 -0
  34. package/dist/lib/plugins/timebar.d.ts +225 -0
  35. package/dist/lib/plugins/tooltip.d.ts +2 -2
  36. package/dist/lib/registry/index.d.ts +1 -1
  37. package/dist/lib/runtime/data.d.ts +13 -7
  38. package/dist/lib/runtime/element.d.ts +6 -10
  39. package/dist/lib/runtime/graph.d.ts +532 -45
  40. package/dist/lib/runtime/types.d.ts +3 -3
  41. package/dist/lib/runtime/viewport.d.ts +3 -4
  42. package/dist/lib/spec/canvas.d.ts +6 -2
  43. package/dist/lib/spec/data.d.ts +74 -1
  44. package/dist/lib/spec/element/combo.d.ts +17 -6
  45. package/dist/lib/spec/element/edge.d.ts +14 -2
  46. package/dist/lib/spec/element/node.d.ts +19 -3
  47. package/{lib/spec/spec.d.ts → dist/lib/spec/graph.d.ts} +12 -4
  48. package/dist/lib/spec/index.d.ts +1 -1
  49. package/dist/lib/spec/theme.d.ts +1 -4
  50. package/dist/lib/spec/viewport.d.ts +1 -1
  51. package/dist/lib/themes/base.d.ts +1 -0
  52. package/dist/lib/themes/types.d.ts +0 -1
  53. package/dist/lib/transforms/process-parallel-edges.d.ts +2 -3
  54. package/dist/lib/transforms/types.d.ts +1 -1
  55. package/dist/lib/types/callable.d.ts +2 -2
  56. package/dist/lib/types/data.d.ts +3 -3
  57. package/dist/lib/types/id.d.ts +1 -0
  58. package/dist/lib/types/index.d.ts +1 -0
  59. package/dist/lib/types/style.d.ts +1 -3
  60. package/dist/lib/types/viewport.d.ts +4 -4
  61. package/dist/lib/utils/animation.d.ts +6 -6
  62. package/dist/lib/utils/behaviors/brush.d.ts +1 -2
  63. package/dist/lib/utils/behaviors/lasso.d.ts +1 -2
  64. package/dist/lib/utils/behaviors/utils.d.ts +1 -1
  65. package/dist/lib/utils/data.d.ts +2 -2
  66. package/dist/lib/utils/edge.d.ts +1 -2
  67. package/dist/lib/utils/element.d.ts +1 -1
  68. package/dist/lib/utils/event/events.d.ts +1 -1
  69. package/dist/lib/utils/event/index.d.ts +1 -1
  70. package/dist/lib/utils/id.d.ts +2 -3
  71. package/dist/lib/utils/palette.d.ts +2 -3
  72. package/dist/lib/utils/relation.d.ts +3 -4
  73. package/dist/lib/utils/visibility.d.ts +1 -1
  74. package/esm/animations/types.d.ts +3 -4
  75. package/esm/behaviors/base-behavior.d.ts +2 -1
  76. package/esm/behaviors/brush-select.d.ts +33 -16
  77. package/esm/behaviors/brush-select.js +7 -2
  78. package/esm/behaviors/brush-select.js.map +1 -1
  79. package/esm/behaviors/click-element.d.ts +28 -5
  80. package/esm/behaviors/click-element.js +11 -0
  81. package/esm/behaviors/click-element.js.map +1 -1
  82. package/esm/behaviors/collapse-expand.d.ts +3 -2
  83. package/esm/behaviors/collapse-expand.js +2 -2
  84. package/esm/behaviors/collapse-expand.js.map +1 -1
  85. package/esm/behaviors/create-edge.d.ts +1 -2
  86. package/esm/behaviors/create-edge.js.map +1 -1
  87. package/esm/behaviors/drag-canvas.d.ts +7 -0
  88. package/esm/behaviors/drag-canvas.js.map +1 -1
  89. package/esm/behaviors/drag-element-force.d.ts +1 -2
  90. package/esm/behaviors/drag-element-force.js.map +1 -1
  91. package/esm/behaviors/drag-element.d.ts +4 -5
  92. package/esm/behaviors/drag-element.js.map +1 -1
  93. package/esm/behaviors/focus-element.js.map +1 -1
  94. package/esm/behaviors/hover-element.js.map +1 -1
  95. package/esm/behaviors/index.d.ts +2 -0
  96. package/esm/behaviors/index.js +1 -0
  97. package/esm/behaviors/index.js.map +1 -1
  98. package/esm/behaviors/lasso-select.d.ts +4 -4
  99. package/esm/behaviors/lasso-select.js +1 -1
  100. package/esm/behaviors/lasso-select.js.map +1 -1
  101. package/esm/behaviors/scroll-canvas.d.ts +64 -0
  102. package/esm/behaviors/scroll-canvas.js +80 -0
  103. package/esm/behaviors/scroll-canvas.js.map +1 -0
  104. package/esm/behaviors/types.d.ts +2 -1
  105. package/esm/behaviors/zoom-canvas.d.ts +1 -1
  106. package/esm/constants/events/animation.d.ts +1 -4
  107. package/esm/constants/events/animation.js +0 -4
  108. package/esm/constants/events/animation.js.map +1 -1
  109. package/esm/constants/events/graph.d.ts +5 -1
  110. package/esm/constants/events/graph.js +4 -0
  111. package/esm/constants/events/graph.js.map +1 -1
  112. package/esm/elements/combos/base-combo.d.ts +1 -1
  113. package/esm/elements/edges/base-edge.d.ts +0 -5
  114. package/esm/elements/edges/base-edge.js +1 -2
  115. package/esm/elements/edges/base-edge.js.map +1 -1
  116. package/esm/elements/nodes/base-node.d.ts +3 -10
  117. package/esm/elements/nodes/base-node.js +2 -2
  118. package/esm/elements/nodes/base-node.js.map +1 -1
  119. package/esm/elements/nodes/donut.d.ts +45 -0
  120. package/esm/elements/nodes/donut.js +81 -0
  121. package/esm/elements/nodes/donut.js.map +1 -0
  122. package/esm/elements/nodes/html.d.ts +27 -0
  123. package/esm/elements/nodes/html.js +209 -0
  124. package/esm/elements/nodes/html.js.map +1 -0
  125. package/esm/elements/nodes/index.d.ts +4 -0
  126. package/esm/elements/nodes/index.js +2 -0
  127. package/esm/elements/nodes/index.js.map +1 -1
  128. package/esm/elements/shapes/badge.d.ts +1 -1
  129. package/esm/{plugins/hull/shape.d.ts → elements/shapes/contour.d.ts} +17 -17
  130. package/esm/{plugins/hull/shape.js → elements/shapes/contour.js} +12 -11
  131. package/esm/elements/shapes/contour.js.map +1 -0
  132. package/esm/elements/shapes/index.d.ts +2 -0
  133. package/esm/elements/shapes/index.js +1 -0
  134. package/esm/elements/shapes/index.js.map +1 -1
  135. package/esm/exports.d.ts +15 -22
  136. package/esm/exports.js +8 -18
  137. package/esm/exports.js.map +1 -1
  138. package/esm/plugins/bubble-sets.d.ts +45 -0
  139. package/esm/plugins/bubble-sets.js +212 -0
  140. package/esm/plugins/bubble-sets.js.map +1 -0
  141. package/esm/plugins/camera-setting.d.ts +4 -2
  142. package/esm/plugins/camera-setting.js.map +1 -1
  143. package/esm/plugins/contextmenu.d.ts +1 -0
  144. package/esm/plugins/contextmenu.js +1 -0
  145. package/esm/plugins/contextmenu.js.map +1 -1
  146. package/esm/plugins/grid-line.d.ts +51 -8
  147. package/esm/plugins/grid-line.js.map +1 -1
  148. package/esm/plugins/history/utils.js +6 -2
  149. package/esm/plugins/history/utils.js.map +1 -1
  150. package/esm/plugins/hull/index.d.ts +44 -13
  151. package/esm/plugins/hull/index.js +46 -16
  152. package/esm/plugins/hull/index.js.map +1 -1
  153. package/esm/plugins/index.d.ts +4 -0
  154. package/esm/plugins/index.js +2 -0
  155. package/esm/plugins/index.js.map +1 -1
  156. package/esm/plugins/legend.js +4 -2
  157. package/esm/plugins/legend.js.map +1 -1
  158. package/esm/plugins/timebar.d.ts +225 -0
  159. package/esm/plugins/timebar.js +253 -0
  160. package/esm/plugins/timebar.js.map +1 -0
  161. package/esm/plugins/tooltip.d.ts +2 -2
  162. package/esm/registry/build-in.js +15 -10
  163. package/esm/registry/build-in.js.map +1 -1
  164. package/esm/registry/index.d.ts +1 -1
  165. package/esm/registry/index.js +1 -1
  166. package/esm/runtime/canvas.js +7 -4
  167. package/esm/runtime/canvas.js.map +1 -1
  168. package/esm/runtime/data.d.ts +13 -7
  169. package/esm/runtime/data.js +20 -3
  170. package/esm/runtime/data.js.map +1 -1
  171. package/esm/runtime/element.d.ts +6 -10
  172. package/esm/runtime/element.js +65 -46
  173. package/esm/runtime/element.js.map +1 -1
  174. package/esm/runtime/graph.d.ts +532 -45
  175. package/esm/runtime/graph.js +418 -40
  176. package/esm/runtime/graph.js.map +1 -1
  177. package/esm/runtime/layout.js +2 -2
  178. package/esm/runtime/layout.js.map +1 -1
  179. package/esm/runtime/types.d.ts +3 -3
  180. package/esm/runtime/viewport.d.ts +3 -4
  181. package/esm/runtime/viewport.js +2 -2
  182. package/esm/runtime/viewport.js.map +1 -1
  183. package/esm/spec/canvas.d.ts +6 -2
  184. package/esm/spec/data.d.ts +74 -1
  185. package/esm/spec/element/combo.d.ts +17 -6
  186. package/esm/spec/element/edge.d.ts +14 -2
  187. package/esm/spec/element/node.d.ts +19 -3
  188. package/esm/spec/{spec.d.ts → graph.d.ts} +12 -4
  189. package/esm/spec/graph.js +2 -0
  190. package/esm/spec/graph.js.map +1 -0
  191. package/esm/spec/index.d.ts +1 -1
  192. package/esm/spec/theme.d.ts +1 -4
  193. package/esm/spec/viewport.d.ts +1 -1
  194. package/esm/themes/base.d.ts +1 -0
  195. package/esm/themes/base.js +11 -9
  196. package/esm/themes/base.js.map +1 -1
  197. package/esm/themes/types.d.ts +0 -1
  198. package/esm/transforms/process-parallel-edges.d.ts +2 -3
  199. package/esm/transforms/process-parallel-edges.js +2 -4
  200. package/esm/transforms/process-parallel-edges.js.map +1 -1
  201. package/esm/transforms/types.d.ts +1 -1
  202. package/esm/transforms/update-related-edge.js.map +1 -1
  203. package/esm/types/callable.d.ts +2 -2
  204. package/esm/types/data.d.ts +3 -3
  205. package/esm/types/id.d.ts +1 -0
  206. package/esm/types/id.js +2 -0
  207. package/esm/types/id.js.map +1 -0
  208. package/esm/types/index.d.ts +1 -0
  209. package/esm/types/style.d.ts +1 -3
  210. package/esm/types/viewport.d.ts +4 -4
  211. package/esm/utils/animation.d.ts +6 -6
  212. package/esm/utils/animation.js +3 -3
  213. package/esm/utils/animation.js.map +1 -1
  214. package/esm/utils/behaviors/brush.d.ts +1 -2
  215. package/esm/utils/behaviors/brush.js.map +1 -1
  216. package/esm/utils/behaviors/lasso.d.ts +1 -2
  217. package/esm/utils/behaviors/lasso.js.map +1 -1
  218. package/esm/utils/behaviors/utils.d.ts +1 -1
  219. package/esm/utils/change.js +8 -1
  220. package/esm/utils/change.js.map +1 -1
  221. package/esm/utils/data.d.ts +2 -2
  222. package/esm/utils/data.js +2 -2
  223. package/esm/utils/edge.d.ts +1 -2
  224. package/esm/utils/edge.js.map +1 -1
  225. package/esm/utils/element.d.ts +1 -1
  226. package/esm/utils/element.js +2 -2
  227. package/esm/utils/event/events.d.ts +1 -1
  228. package/esm/utils/event/events.js.map +1 -1
  229. package/esm/utils/event/index.d.ts +1 -1
  230. package/esm/utils/event/index.js +1 -1
  231. package/esm/utils/id.d.ts +2 -3
  232. package/esm/utils/id.js.map +1 -1
  233. package/esm/utils/palette.d.ts +2 -3
  234. package/esm/utils/palette.js +1 -1
  235. package/esm/utils/palette.js.map +1 -1
  236. package/esm/utils/relation.d.ts +3 -4
  237. package/esm/utils/relation.js +2 -2
  238. package/esm/utils/relation.js.map +1 -1
  239. package/esm/utils/style.js +3 -3
  240. package/esm/utils/style.js.map +1 -1
  241. package/esm/utils/visibility.d.ts +1 -1
  242. package/esm/utils/visibility.js +1 -1
  243. package/lib/animations/types.d.ts +3 -4
  244. package/lib/behaviors/base-behavior.d.ts +2 -1
  245. package/lib/behaviors/brush-select.d.ts +33 -16
  246. package/lib/behaviors/brush-select.js +7 -2
  247. package/lib/behaviors/brush-select.js.map +1 -1
  248. package/lib/behaviors/click-element.d.ts +28 -5
  249. package/lib/behaviors/click-element.js +11 -0
  250. package/lib/behaviors/click-element.js.map +1 -1
  251. package/lib/behaviors/collapse-expand.d.ts +3 -2
  252. package/lib/behaviors/collapse-expand.js +2 -2
  253. package/lib/behaviors/collapse-expand.js.map +1 -1
  254. package/lib/behaviors/create-edge.d.ts +1 -2
  255. package/lib/behaviors/create-edge.js.map +1 -1
  256. package/lib/behaviors/drag-canvas.d.ts +7 -0
  257. package/lib/behaviors/drag-canvas.js.map +1 -1
  258. package/lib/behaviors/drag-element-force.d.ts +1 -2
  259. package/lib/behaviors/drag-element-force.js.map +1 -1
  260. package/lib/behaviors/drag-element.d.ts +4 -5
  261. package/lib/behaviors/drag-element.js.map +1 -1
  262. package/lib/behaviors/focus-element.js.map +1 -1
  263. package/lib/behaviors/hover-element.js.map +1 -1
  264. package/lib/behaviors/index.d.ts +2 -0
  265. package/lib/behaviors/index.js +3 -1
  266. package/lib/behaviors/index.js.map +1 -1
  267. package/lib/behaviors/lasso-select.d.ts +4 -4
  268. package/lib/behaviors/lasso-select.js +1 -1
  269. package/lib/behaviors/lasso-select.js.map +1 -1
  270. package/lib/behaviors/scroll-canvas.d.ts +64 -0
  271. package/lib/behaviors/scroll-canvas.js +84 -0
  272. package/lib/behaviors/scroll-canvas.js.map +1 -0
  273. package/lib/behaviors/types.d.ts +2 -1
  274. package/lib/behaviors/zoom-canvas.d.ts +1 -1
  275. package/lib/constants/events/animation.d.ts +1 -4
  276. package/lib/constants/events/animation.js +0 -4
  277. package/lib/constants/events/animation.js.map +1 -1
  278. package/lib/constants/events/graph.d.ts +5 -1
  279. package/lib/constants/events/graph.js +4 -0
  280. package/lib/constants/events/graph.js.map +1 -1
  281. package/lib/elements/combos/base-combo.d.ts +1 -1
  282. package/lib/elements/edges/base-edge.d.ts +0 -5
  283. package/lib/elements/edges/base-edge.js +1 -2
  284. package/lib/elements/edges/base-edge.js.map +1 -1
  285. package/lib/elements/nodes/base-node.d.ts +3 -10
  286. package/lib/elements/nodes/base-node.js +2 -2
  287. package/lib/elements/nodes/base-node.js.map +1 -1
  288. package/lib/elements/nodes/donut.d.ts +45 -0
  289. package/lib/elements/nodes/donut.js +85 -0
  290. package/lib/elements/nodes/donut.js.map +1 -0
  291. package/lib/elements/nodes/html.d.ts +27 -0
  292. package/lib/elements/nodes/html.js +213 -0
  293. package/lib/elements/nodes/html.js.map +1 -0
  294. package/lib/elements/nodes/index.d.ts +4 -0
  295. package/lib/elements/nodes/index.js +5 -1
  296. package/lib/elements/nodes/index.js.map +1 -1
  297. package/lib/elements/shapes/badge.d.ts +1 -1
  298. package/lib/{plugins/hull/shape.d.ts → elements/shapes/contour.d.ts} +17 -17
  299. package/lib/{plugins/hull/shape.js → elements/shapes/contour.js} +15 -14
  300. package/lib/elements/shapes/contour.js.map +1 -0
  301. package/lib/elements/shapes/index.d.ts +2 -0
  302. package/lib/elements/shapes/index.js +3 -1
  303. package/lib/elements/shapes/index.js.map +1 -1
  304. package/lib/exports.d.ts +15 -22
  305. package/lib/exports.js +50 -17
  306. package/lib/exports.js.map +1 -1
  307. package/lib/plugins/bubble-sets.d.ts +45 -0
  308. package/lib/plugins/bubble-sets.js +216 -0
  309. package/lib/plugins/bubble-sets.js.map +1 -0
  310. package/lib/plugins/camera-setting.d.ts +4 -2
  311. package/lib/plugins/camera-setting.js.map +1 -1
  312. package/lib/plugins/contextmenu.d.ts +1 -0
  313. package/lib/plugins/contextmenu.js +1 -0
  314. package/lib/plugins/contextmenu.js.map +1 -1
  315. package/lib/plugins/grid-line.d.ts +51 -8
  316. package/lib/plugins/grid-line.js.map +1 -1
  317. package/lib/plugins/history/utils.js +6 -2
  318. package/lib/plugins/history/utils.js.map +1 -1
  319. package/lib/plugins/hull/index.d.ts +44 -13
  320. package/lib/plugins/hull/index.js +46 -16
  321. package/lib/plugins/hull/index.js.map +1 -1
  322. package/lib/plugins/index.d.ts +4 -0
  323. package/lib/plugins/index.js +5 -1
  324. package/lib/plugins/index.js.map +1 -1
  325. package/lib/plugins/legend.js +4 -2
  326. package/lib/plugins/legend.js.map +1 -1
  327. package/lib/plugins/timebar.d.ts +225 -0
  328. package/lib/plugins/timebar.js +257 -0
  329. package/lib/plugins/timebar.js.map +1 -0
  330. package/lib/plugins/tooltip.d.ts +2 -2
  331. package/lib/registry/build-in.js +12 -7
  332. package/lib/registry/build-in.js.map +1 -1
  333. package/lib/registry/index.d.ts +1 -1
  334. package/lib/registry/index.js +1 -1
  335. package/lib/runtime/canvas.js +7 -4
  336. package/lib/runtime/canvas.js.map +1 -1
  337. package/lib/runtime/data.d.ts +13 -7
  338. package/lib/runtime/data.js +20 -3
  339. package/lib/runtime/data.js.map +1 -1
  340. package/lib/runtime/element.d.ts +6 -10
  341. package/lib/runtime/element.js +64 -45
  342. package/lib/runtime/element.js.map +1 -1
  343. package/lib/runtime/graph.d.ts +532 -45
  344. package/lib/runtime/graph.js +417 -39
  345. package/lib/runtime/graph.js.map +1 -1
  346. package/lib/runtime/layout.js +2 -2
  347. package/lib/runtime/layout.js.map +1 -1
  348. package/lib/runtime/types.d.ts +3 -3
  349. package/lib/runtime/viewport.d.ts +3 -4
  350. package/lib/runtime/viewport.js +2 -2
  351. package/lib/runtime/viewport.js.map +1 -1
  352. package/lib/spec/canvas.d.ts +6 -2
  353. package/lib/spec/data.d.ts +74 -1
  354. package/lib/spec/element/combo.d.ts +17 -6
  355. package/lib/spec/element/edge.d.ts +14 -2
  356. package/lib/spec/element/node.d.ts +19 -3
  357. package/{dist/lib/spec/spec.d.ts → lib/spec/graph.d.ts} +12 -4
  358. package/lib/spec/{spec.js → graph.js} +1 -1
  359. package/lib/spec/graph.js.map +1 -0
  360. package/lib/spec/index.d.ts +1 -1
  361. package/lib/spec/theme.d.ts +1 -4
  362. package/lib/spec/viewport.d.ts +1 -1
  363. package/lib/themes/base.d.ts +1 -0
  364. package/lib/themes/base.js +11 -9
  365. package/lib/themes/base.js.map +1 -1
  366. package/lib/themes/types.d.ts +0 -1
  367. package/lib/transforms/process-parallel-edges.d.ts +2 -3
  368. package/lib/transforms/process-parallel-edges.js +2 -4
  369. package/lib/transforms/process-parallel-edges.js.map +1 -1
  370. package/lib/transforms/types.d.ts +1 -1
  371. package/lib/transforms/update-related-edge.js.map +1 -1
  372. package/lib/types/callable.d.ts +2 -2
  373. package/lib/types/data.d.ts +3 -3
  374. package/lib/types/id.d.ts +1 -0
  375. package/lib/{spec/element/base.js → types/id.js} +1 -1
  376. package/lib/types/id.js.map +1 -0
  377. package/lib/types/index.d.ts +1 -0
  378. package/lib/types/style.d.ts +1 -3
  379. package/lib/types/viewport.d.ts +4 -4
  380. package/lib/utils/animation.d.ts +6 -6
  381. package/lib/utils/animation.js +3 -3
  382. package/lib/utils/animation.js.map +1 -1
  383. package/lib/utils/behaviors/brush.d.ts +1 -2
  384. package/lib/utils/behaviors/brush.js.map +1 -1
  385. package/lib/utils/behaviors/lasso.d.ts +1 -2
  386. package/lib/utils/behaviors/lasso.js.map +1 -1
  387. package/lib/utils/behaviors/utils.d.ts +1 -1
  388. package/lib/utils/change.js +8 -1
  389. package/lib/utils/change.js.map +1 -1
  390. package/lib/utils/data.d.ts +2 -2
  391. package/lib/utils/data.js +2 -2
  392. package/lib/utils/edge.d.ts +1 -2
  393. package/lib/utils/edge.js.map +1 -1
  394. package/lib/utils/element.d.ts +1 -1
  395. package/lib/utils/element.js +2 -2
  396. package/lib/utils/event/events.d.ts +1 -1
  397. package/lib/utils/event/events.js.map +1 -1
  398. package/lib/utils/event/index.d.ts +1 -1
  399. package/lib/utils/event/index.js +1 -1
  400. package/lib/utils/id.d.ts +2 -3
  401. package/lib/utils/id.js.map +1 -1
  402. package/lib/utils/palette.d.ts +2 -3
  403. package/lib/utils/palette.js +1 -1
  404. package/lib/utils/palette.js.map +1 -1
  405. package/lib/utils/relation.d.ts +3 -4
  406. package/lib/utils/relation.js +2 -2
  407. package/lib/utils/relation.js.map +1 -1
  408. package/lib/utils/style.js +3 -3
  409. package/lib/utils/style.js.map +1 -1
  410. package/lib/utils/visibility.d.ts +1 -1
  411. package/lib/utils/visibility.js +1 -1
  412. package/package.json +2 -1
  413. package/src/animations/types.ts +3 -4
  414. package/src/behaviors/base-behavior.ts +1 -1
  415. package/src/behaviors/brush-select.ts +34 -16
  416. package/src/behaviors/click-element.ts +29 -7
  417. package/src/behaviors/collapse-expand.ts +5 -4
  418. package/src/behaviors/create-edge.ts +1 -2
  419. package/src/behaviors/drag-canvas.ts +7 -0
  420. package/src/behaviors/drag-element-force.ts +1 -2
  421. package/src/behaviors/drag-element.ts +3 -4
  422. package/src/behaviors/focus-element.ts +1 -2
  423. package/src/behaviors/hover-element.ts +1 -2
  424. package/src/behaviors/index.ts +2 -0
  425. package/src/behaviors/lasso-select.ts +3 -4
  426. package/src/behaviors/scroll-canvas.ts +143 -0
  427. package/src/behaviors/types.ts +2 -1
  428. package/src/behaviors/zoom-canvas.ts +1 -1
  429. package/src/constants/events/animation.ts +0 -4
  430. package/src/constants/events/graph.ts +4 -0
  431. package/src/elements/combos/base-combo.ts +1 -1
  432. package/src/elements/edges/base-edge.ts +1 -7
  433. package/src/elements/nodes/base-node.ts +6 -15
  434. package/src/elements/nodes/donut.ts +137 -0
  435. package/src/elements/nodes/html.ts +230 -0
  436. package/src/elements/nodes/index.ts +4 -0
  437. package/src/{plugins/hull/shape.ts → elements/shapes/contour.ts} +27 -34
  438. package/src/elements/shapes/index.ts +2 -0
  439. package/src/exports.ts +124 -25
  440. package/src/plugins/bubble-sets.ts +268 -0
  441. package/src/plugins/camera-setting.ts +4 -2
  442. package/src/plugins/contextmenu.ts +1 -0
  443. package/src/plugins/grid-line.ts +51 -8
  444. package/src/plugins/history/utils.ts +6 -2
  445. package/src/plugins/hull/index.ts +58 -22
  446. package/src/plugins/index.ts +4 -0
  447. package/src/plugins/legend.ts +6 -4
  448. package/src/plugins/timebar.ts +450 -0
  449. package/src/plugins/tooltip.ts +2 -2
  450. package/src/registry/build-in.ts +27 -8
  451. package/src/registry/index.ts +1 -1
  452. package/src/runtime/canvas.ts +7 -4
  453. package/src/runtime/data.ts +23 -4
  454. package/src/runtime/element.ts +67 -40
  455. package/src/runtime/graph.ts +554 -56
  456. package/src/runtime/layout.ts +4 -4
  457. package/src/runtime/types.ts +3 -3
  458. package/src/runtime/viewport.ts +3 -4
  459. package/src/spec/canvas.ts +6 -2
  460. package/src/spec/data.ts +74 -1
  461. package/src/spec/element/combo.ts +17 -6
  462. package/src/spec/element/edge.ts +14 -2
  463. package/src/spec/element/node.ts +19 -3
  464. package/src/spec/{spec.ts → graph.ts} +12 -4
  465. package/src/spec/index.ts +1 -1
  466. package/src/spec/theme.ts +1 -5
  467. package/src/spec/viewport.ts +1 -1
  468. package/src/themes/base.ts +12 -9
  469. package/src/themes/types.ts +0 -2
  470. package/src/transforms/arrange-draw-order.ts +1 -1
  471. package/src/transforms/process-parallel-edges.ts +5 -7
  472. package/src/transforms/types.ts +1 -1
  473. package/src/transforms/update-related-edge.ts +1 -2
  474. package/src/types/callable.ts +2 -2
  475. package/src/types/data.ts +3 -3
  476. package/src/types/id.ts +1 -0
  477. package/src/types/index.ts +1 -0
  478. package/src/types/style.ts +1 -3
  479. package/src/types/viewport.ts +4 -4
  480. package/src/utils/animation.ts +6 -6
  481. package/src/utils/behaviors/brush.ts +1 -2
  482. package/src/utils/behaviors/lasso.ts +1 -2
  483. package/src/utils/behaviors/utils.ts +1 -1
  484. package/src/utils/change.ts +7 -3
  485. package/src/utils/data.ts +2 -2
  486. package/src/utils/edge.ts +1 -1
  487. package/src/utils/element.ts +2 -2
  488. package/src/utils/event/events.ts +3 -1
  489. package/src/utils/event/index.ts +1 -1
  490. package/src/utils/id.ts +1 -2
  491. package/src/utils/palette.ts +2 -2
  492. package/src/utils/relation.ts +3 -4
  493. package/src/utils/style.ts +3 -3
  494. package/src/utils/visibility.ts +1 -1
  495. package/dist/lib/runtime/index.d.ts +0 -6
  496. package/dist/lib/spec/element/base.d.ts +0 -6
  497. package/esm/plugins/hull/shape.js.map +0 -1
  498. package/esm/runtime/index.d.ts +0 -6
  499. package/esm/runtime/index.js +0 -7
  500. package/esm/runtime/index.js.map +0 -1
  501. package/esm/spec/element/base.d.ts +0 -6
  502. package/esm/spec/element/base.js +0 -2
  503. package/esm/spec/element/base.js.map +0 -1
  504. package/esm/spec/spec.js +0 -2
  505. package/esm/spec/spec.js.map +0 -1
  506. package/lib/plugins/hull/shape.js.map +0 -1
  507. package/lib/runtime/index.d.ts +0 -6
  508. package/lib/runtime/index.js +0 -8
  509. package/lib/runtime/index.js.map +0 -1
  510. package/lib/spec/element/base.d.ts +0 -6
  511. package/lib/spec/element/base.js.map +0 -1
  512. package/lib/spec/spec.js.map +0 -1
  513. package/src/runtime/index.ts +0 -7
  514. package/src/spec/element/base.ts +0 -6
@@ -1,8 +1,7 @@
1
- import type { ID } from '@antv/graphlib';
2
1
  import { isFunction } from '@antv/util';
3
2
  import { CommonEvent } from '../constants';
4
3
  import type { RuntimeContext } from '../runtime/types';
5
- import type { IPointerEvent } from '../types';
4
+ import type { ID, IPointerEvent } from '../types';
6
5
  import { isElement } from '../utils/element';
7
6
  import type { BaseBehaviorOptions } from './base-behavior';
8
7
  import { BaseBehavior } from './base-behavior';
@@ -12,12 +11,14 @@ export interface CollapseExpandOptions extends BaseBehaviorOptions {
12
11
  * <zh/> 是否启用动画
13
12
  *
14
13
  * <en/> Whether to enable animation
14
+ * @defaultValue true
15
15
  */
16
16
  animation: boolean;
17
17
  /**
18
18
  * <zh/> 是否启用展开/收起功能
19
19
  *
20
20
  * <en/> Whether to enable the expand/collapse function
21
+ * @defaultValue true
21
22
  */
22
23
  enable?: boolean | ((event: IPointerEvent) => boolean);
23
24
  /**
@@ -71,10 +72,10 @@ export class CollapseExpand extends BaseBehavior<CollapseExpandOptions> {
71
72
  const { onCollapse, onExpand, animation } = this.options;
72
73
  const isCollapse = data.style?.collapsed;
73
74
  if (isCollapse) {
74
- await graph.expand(id, animation);
75
+ await graph.expandElement(id, animation);
75
76
  onExpand?.(id);
76
77
  } else {
77
- await graph.collapse(id, animation);
78
+ await graph.collapseElement(id, animation);
78
79
  onCollapse?.(id);
79
80
  }
80
81
  };
@@ -1,10 +1,9 @@
1
- import type { ID } from '@antv/graphlib';
2
1
  import { isFunction, uniqueId } from '@antv/util';
3
2
  import { CommonEvent } from '../constants';
4
3
  import type { RuntimeContext } from '../runtime/types';
5
4
  import type { EdgeData } from '../spec';
6
5
  import type { EdgeStyle } from '../spec/element/edge';
7
- import type { Element, IPointerEvent } from '../types';
6
+ import type { Element, ID, IPointerEvent } from '../types';
8
7
  import type { BaseBehaviorOptions } from './base-behavior';
9
8
  import { BaseBehavior } from './base-behavior';
10
9
 
@@ -9,6 +9,11 @@ import { multiply } from '../utils/vector';
9
9
  import type { BaseBehaviorOptions } from './base-behavior';
10
10
  import { BaseBehavior } from './base-behavior';
11
11
 
12
+ /**
13
+ * <zh/> 拖拽画布交互配置项
14
+ *
15
+ * <en/> Drag canvas behavior options
16
+ */
12
17
  export interface DragCanvasOptions extends BaseBehaviorOptions {
13
18
  /**
14
19
  * <zh/> 是否启用拖拽动画,仅在使用按键移动时有效
@@ -20,6 +25,7 @@ export interface DragCanvasOptions extends BaseBehaviorOptions {
20
25
  * <zh/> 是否启用拖拽画布的功能
21
26
  *
22
27
  * <en/> Whether to enable the function of dragging the canvas
28
+ * @defaultValue true
23
29
  */
24
30
  enable?: boolean | ((event: IPointerEvent | IKeyboardEvent) => boolean);
25
31
  /**
@@ -32,6 +38,7 @@ export interface DragCanvasOptions extends BaseBehaviorOptions {
32
38
  * <zh/> 触发一次按键移动的距离
33
39
  *
34
40
  * <en/> The distance of a single key movement
41
+ * @defaultValue 10
35
42
  */
36
43
  sensitivity?: number;
37
44
  /**
@@ -1,6 +1,5 @@
1
- import type { ID } from '@antv/graphlib';
2
1
  import type { D3Force3DLayout, D3ForceLayout } from '@antv/layout';
3
- import type { Element, IDragEvent, Point } from '../types';
2
+ import type { Element, ID, IDragEvent, Point } from '../types';
4
3
  import { idOf } from '../utils/id';
5
4
  import { add } from '../utils/vector';
6
5
  import type { DragElementOptions } from './drag-element';
@@ -1,10 +1,9 @@
1
1
  import type { BaseStyleProps } from '@antv/g';
2
2
  import { Rect } from '@antv/g';
3
- import type { ID } from '@antv/graphlib';
4
3
  import { isFunction } from '@antv/util';
5
4
  import { COMBO_KEY, CommonEvent } from '../constants';
6
5
  import type { RuntimeContext } from '../runtime/types';
7
- import type { EdgeDirection, Element, IDragEvent, Point, PrefixObject } from '../types';
6
+ import type { EdgeDirection, Element, ID, IDragEvent, Point, PrefixObject } from '../types';
8
7
  import { getBBoxSize, getCombinedBBox } from '../utils/bbox';
9
8
  import { idOf } from '../utils/id';
10
9
  import { subStyleProps } from '../utils/prefix';
@@ -35,7 +34,7 @@ export interface DragElementOptions extends BaseBehaviorOptions, PrefixObject<Ba
35
34
  * - link: Place the drag element as a child element of the target element
36
35
  * - move: Move the element and update the parent element size
37
36
  * - none: Only update the drag target position, no additional operations
38
- * @description
37
+ * @remarks
39
38
  * <zh/> combo 元素可作为元素容器置入 node 或 combo 元素
40
39
  *
41
40
  * <en/> The combo element can be placed as an element container into the node or combo element
@@ -61,7 +60,7 @@ export interface DragElementOptions extends BaseBehaviorOptions, PrefixObject<Ba
61
60
  * - in: hide the edges with the node as the target node
62
61
  * - both: hide all edges related to the node
63
62
  * - all: hide all edges in the graph
64
- * @description
63
+ * @remarks
65
64
  * <zh/> 使用幽灵节点时不会隐藏边
66
65
  *
67
66
  * <en/> Edges will not be hidden when using the drag shadow
@@ -1,8 +1,7 @@
1
- import type { ID } from '@antv/graphlib';
2
1
  import { isFunction } from '@antv/util';
3
2
  import { CommonEvent } from '../constants';
4
3
  import type { RuntimeContext } from '../runtime/types';
5
- import type { Element, IPointerEvent, ViewportAnimationEffectTiming } from '../types';
4
+ import type { Element, ID, IPointerEvent, ViewportAnimationEffectTiming } from '../types';
6
5
  import type { BaseBehaviorOptions } from './base-behavior';
7
6
  import { BaseBehavior } from './base-behavior';
8
7
 
@@ -1,9 +1,8 @@
1
- import type { ID } from '@antv/graphlib';
2
1
  import { isFunction } from '@antv/util';
3
2
  import { CommonEvent } from '../constants';
4
3
  import { ELEMENT_TYPES } from '../constants/element';
5
4
  import type { RuntimeContext } from '../runtime/types';
6
- import type { Element, ElementType, IPointerEvent, State } from '../types';
5
+ import type { Element, ElementType, ID, IPointerEvent, State } from '../types';
7
6
  import { idsOf } from '../utils/id';
8
7
  import { getElementNthDegreeIds } from '../utils/relation';
9
8
  import type { BaseBehaviorOptions } from './base-behavior';
@@ -9,6 +9,7 @@ export { DragElementForce } from './drag-element-force';
9
9
  export { FocusElement } from './focus-element';
10
10
  export { HoverElement } from './hover-element';
11
11
  export { LassoSelect } from './lasso-select';
12
+ export { ScrollCanvas } from './scroll-canvas';
12
13
  export { ZoomCanvas } from './zoom-canvas';
13
14
 
14
15
  export type { BaseBehaviorOptions } from './base-behavior';
@@ -22,4 +23,5 @@ export type { DragElementForceOptions } from './drag-element-force';
22
23
  export type { FocusElementOptions } from './focus-element';
23
24
  export type { HoverElementOptions } from './hover-element';
24
25
  export type { LassoSelectOptions } from './lasso-select';
26
+ export type { ScrollCanvasOptions } from './scroll-canvas';
25
27
  export type { ZoomCanvasOptions } from './zoom-canvas';
@@ -4,16 +4,15 @@ import { getAllElementState } from '../utils/behaviors/utils';
4
4
  import { pointsToPath } from '../utils/path';
5
5
  import { BrushSelect, DEFAULT_STYLE } from './brush-select';
6
6
 
7
- import type { ID } from '@antv/graphlib';
8
7
  import type { RuntimeContext } from '../runtime/types';
9
- import type { IPointerEvent, Points, State } from '../types';
8
+ import type { ID, IPointerEvent, Points, State } from '../types';
10
9
  import type { BrushSelectOptions } from './brush-select';
11
10
 
12
11
  const SHOW_PATH_ID = 'g6-lasso-select-path-id';
13
12
 
14
13
  export type States = Record<ID, State | State[]>;
15
14
 
16
- export type LassoSelectOptions = BrushSelectOptions;
15
+ export interface LassoSelectOptions extends BrushSelectOptions {}
17
16
 
18
17
  export class LassoSelect extends BrushSelect<LassoSelectOptions> {
19
18
  static defaultOptions: Partial<LassoSelectOptions> = {
@@ -43,7 +42,7 @@ export class LassoSelect extends BrushSelect<LassoSelectOptions> {
43
42
  id: SHOW_PATH_ID,
44
43
  style: {
45
44
  ...LassoSelect.defaultOptions.style,
46
- fill: style.color || DEFAULT_STYLE.color,
45
+ fill: style.fill || DEFAULT_STYLE.fill,
47
46
  ...style,
48
47
  pointerEvents: 'none',
49
48
  },
@@ -0,0 +1,143 @@
1
+ import { isFunction, isObject } from '@antv/util';
2
+ import { CanvasEvent } from '../constants';
3
+ import type { RuntimeContext } from '../runtime/types';
4
+ import type { IKeyboardEvent, Point } from '../types';
5
+ import { Shortcut, ShortcutKey } from '../utils/shortcut';
6
+ import type { BaseBehaviorOptions } from './base-behavior';
7
+ import { BaseBehavior } from './base-behavior';
8
+
9
+ export interface ScrollCanvasOptions extends BaseBehaviorOptions {
10
+ /**
11
+ * <zh/> 是否启用滚动画布的功能
12
+ *
13
+ * <en/> Whether to enable the function of scrolling the canvas
14
+ * @defaultValue true
15
+ */
16
+ enable?: boolean | ((event: WheelEvent | IKeyboardEvent) => boolean);
17
+ /**
18
+ * <zh/> 触发滚动的方式,默认使用指针滚动
19
+ *
20
+ * <en/> The way to trigger scrolling, default to scrolling with the pointer pressed
21
+ */
22
+ trigger?: CombinationKey;
23
+ /**
24
+ * <zh/> 允许的滚动方向
25
+ * - 默认情况下没有限制
26
+ * - x : 只允许水平滚动
27
+ * - y : 只允许垂直滚动
28
+ *
29
+ * <en/> The allowed rolling direction
30
+ * - by default, there is no restriction
31
+ * - x: only allow horizontal scrolling
32
+ * - y: only allow vertical scrolling
33
+ */
34
+ direction?: 'x' | 'y';
35
+ /**
36
+ * <zh/> 滚动灵敏度
37
+ *
38
+ * <en/> Scroll sensitivity
39
+ * @defaultValue 1
40
+ */
41
+ sensitivity?: number;
42
+ /**
43
+ * <zh/> 完成滚动时的回调
44
+ *
45
+ * <en/> Callback when scrolling is completed
46
+ */
47
+ onFinish?: () => void;
48
+ }
49
+
50
+ type CombinationKey = {
51
+ up: ShortcutKey;
52
+ down: ShortcutKey;
53
+ left: ShortcutKey;
54
+ right: ShortcutKey;
55
+ };
56
+
57
+ export class ScrollCanvas extends BaseBehavior<ScrollCanvasOptions> {
58
+ static defaultOptions: ScrollCanvasOptions = {
59
+ enable: true,
60
+ sensitivity: 1,
61
+ };
62
+
63
+ private shortcut: Shortcut;
64
+
65
+ constructor(context: RuntimeContext, options: ScrollCanvasOptions) {
66
+ super(context, Object.assign({}, ScrollCanvas.defaultOptions, options));
67
+
68
+ this.shortcut = new Shortcut(context.graph);
69
+
70
+ this.bindEvents();
71
+ }
72
+
73
+ private bindEvents() {
74
+ const { trigger } = this.options;
75
+ this.shortcut.unbindAll();
76
+ const { graph } = this.context;
77
+ if (isObject(trigger)) {
78
+ graph.off(CanvasEvent.WHEEL, this.onWheel);
79
+ const { up = [], down = [], left = [], right = [] } = trigger;
80
+
81
+ this.shortcut.bind(up, (event) => this.scroll([0, -10], event));
82
+ this.shortcut.bind(down, (event) => this.scroll([0, 10], event));
83
+ this.shortcut.bind(left, (event) => this.scroll([-10, 0], event));
84
+ this.shortcut.bind(right, (event) => this.scroll([10, 0], event));
85
+ } else {
86
+ /**
87
+ * 这里必需在原生canvas上绑定wheel事件,参考:
88
+ * https://g.antv.antgroup.com/api/event/faq#%E5%9C%A8-chrome-%E4%B8%AD%E7%A6%81%E6%AD%A2%E9%A1%B5%E9%9D%A2%E9%BB%98%E8%AE%A4%E6%BB%9A%E5%8A%A8%E8%A1%8C%E4%B8%BA
89
+ */
90
+ this.graphDom?.addEventListener(CanvasEvent.WHEEL, this.onWheel, { passive: false });
91
+ }
92
+ }
93
+
94
+ get graphDom() {
95
+ return this.context.graph.getCanvas().getContextService().getDomElement();
96
+ }
97
+
98
+ private onWheel = async (event: WheelEvent) => {
99
+ event.preventDefault();
100
+ const diffX = event.deltaX;
101
+ const diffY = event.deltaY;
102
+
103
+ await this.scroll([-diffX, -diffY], event);
104
+ };
105
+
106
+ private formatDisplacement([dx, dy]: Point) {
107
+ const { direction, sensitivity } = this.options;
108
+
109
+ dx = dx * sensitivity;
110
+ dy = dy * sensitivity;
111
+
112
+ if (direction === 'x') {
113
+ dy = 0;
114
+ } else if (direction === 'y') {
115
+ dx = 0;
116
+ }
117
+
118
+ return [dx, dy] as Point;
119
+ }
120
+
121
+ private async scroll(value: Point, event: WheelEvent | IKeyboardEvent) {
122
+ if (!this.validate(event)) return;
123
+ const { onFinish } = this.options;
124
+ const graph = this.context.graph;
125
+ const formattedValue = this.formatDisplacement(value);
126
+ await graph.translateBy(formattedValue, false);
127
+ onFinish?.();
128
+ }
129
+
130
+ private validate(event: WheelEvent | IKeyboardEvent) {
131
+ if (this.destroyed) return false;
132
+
133
+ const { enable } = this.options;
134
+ if (isFunction(enable)) return enable(event);
135
+ return !!enable;
136
+ }
137
+
138
+ public destroy(): void {
139
+ this.shortcut.destroy();
140
+ this.graphDom?.removeEventListener(CanvasEvent.WHEEL, this.onWheel);
141
+ super.destroy();
142
+ }
143
+ }
@@ -1,8 +1,9 @@
1
1
  import type { BaseBehavior } from './base-behavior';
2
2
  import type { DragCanvasOptions } from './drag-canvas';
3
+ import type { ScrollCanvasOptions } from './scroll-canvas';
3
4
  import type { ZoomCanvasOptions } from './zoom-canvas';
4
5
 
5
6
  export type { States } from './brush-select';
6
7
 
7
- export type BuiltInBehaviorOptions = DragCanvasOptions | ZoomCanvasOptions;
8
+ export type BuiltInBehaviorOptions = DragCanvasOptions | ZoomCanvasOptions | ScrollCanvasOptions;
8
9
  export type Behavior = BaseBehavior<any>;
@@ -26,7 +26,7 @@ export interface ZoomCanvasOptions extends BaseBehaviorOptions {
26
26
  * <zh/> 触发缩放的方式
27
27
  *
28
28
  * <en/> The way to trigger zoom
29
- * @description
29
+ * @remarks
30
30
  * <zh/>
31
31
  * - 数组:组合快捷键,默认使用滚轮缩放,['Control'] 表示按住 Control 键滚动鼠标滚轮时触发缩放
32
32
  * - 对象:缩放快捷键,例如 { zoomIn: ['Control', '+'], zoomOut: ['Control', '-'], reset: ['Control', '0'] }
@@ -1,8 +1,4 @@
1
1
  export enum AnimationType {
2
2
  DRAW = 'draw',
3
3
  TRANSFORM = 'transform',
4
- // LAYOUT = 'layout', // 布局没有统一的动画对象,因此不抛出动画事件 | There is no unified animation object for layout, so no animation event is thrown
5
- ELEMENT_VISIBILITY_CHANGE = 'elementvisibilitychange',
6
- ELEMENT_STATE_CHANGE = 'elementstatechange',
7
- ELEMENT_TRANSLATE = 'elementtranslate',
8
4
  }
@@ -51,4 +51,8 @@ export enum GraphEvent {
51
51
  BATCH_START = 'batchstart',
52
52
  /** <zh/> 批处理结束 | <en/> Batch processing ends */
53
53
  BATCH_END = 'batchend',
54
+ /** <zh/> 销毁开始之前 | <en/> Before destruction */
55
+ BEFORE_DESTROY = 'beforedestroy',
56
+ /** <zh/> 销毁结束之后 | <en/> After destruction */
57
+ AFTER_DESTROY = 'afterdestroy',
54
58
  }
@@ -57,7 +57,7 @@ export type BaseComboStyleProps<T extends Record<string, unknown> = Record<strin
57
57
  * <zh/> Combo 的子元素数据
58
58
  *
59
59
  * <en/> The data of the children of combo
60
- * @description
60
+ * @remarks
61
61
  * <zh/> 如果 combo 是收起状态,children 可能为空,通过 childrenData 能够获取完整的子元素数据
62
62
  *
63
63
  * <en/> If the combo is collapsed, children may be empty, and the complete child element data can be obtained through childrenData
@@ -78,11 +78,6 @@ export type BaseEdgeStyleProps = BaseElementStyleProps &
78
78
  * <en/> Offset of the end arrow
79
79
  */
80
80
  endArrowOffset?: number;
81
- /**
82
- * <zh/> 主色
83
- * <en/> Subject color
84
- */
85
- color?: string;
86
81
  /**
87
82
  * <zh/> 边的起点 shape
88
83
  * <en/> The source shape. Represents the start of the edge
@@ -151,13 +146,12 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
151
146
  }
152
147
 
153
148
  protected getKeyStyle(attributes: ParsedBaseEdgeStyleProps): PathStyleProps {
154
- const { sourceNode, targetNode, color, stroke, ...style } = this.getGraphicStyle(attributes);
149
+ const { sourceNode, targetNode, ...style } = this.getGraphicStyle(attributes);
155
150
 
156
151
  const path = isSameNode(sourceNode, targetNode) ? this.getLoopPath(attributes) : this.getKeyPath(attributes);
157
152
  return {
158
153
  path,
159
154
  ...omitStyleProps(style, ['halo', 'label', 'startArrow', 'endArrow']),
160
- stroke: color || stroke,
161
155
  };
162
156
  }
163
157
 
@@ -1,12 +1,12 @@
1
1
  import type { DisplayObject, DisplayObjectConfig, Group } from '@antv/g';
2
2
  import { Circle as GCircle } from '@antv/g';
3
- import type { ID } from '@antv/graphlib';
4
3
  import { deepMix, isEmpty } from '@antv/util';
5
4
  import type { CategoricalPalette } from '../../palettes/types';
6
5
  import type { NodeData } from '../../spec';
7
6
  import type {
8
7
  BadgePlacement,
9
8
  BaseElementStyleProps,
9
+ ID,
10
10
  Keyframe,
11
11
  LabelPlacement,
12
12
  Node,
@@ -59,18 +59,12 @@ export type BaseNodeStyleProps<T extends Record<string, unknown> = Record<string
59
59
  * <en/> The size of node, which is a shortcut to set the width and height of node
60
60
  */
61
61
  size?: Size;
62
- /**
63
- * <zh/> 主色
64
- *
65
- * <en/> Subject color
66
- */
67
- color?: string;
68
62
  /**
69
63
  * @deprecated
70
64
  * <zh/> 解决类型 style.getPropertyValue 问题,不要使用该属性
71
65
  *
72
66
  * <en/> Solve the problem of style.getPropertyValue, do not use this property
73
- * @description
67
+ * @remarks
74
68
  * <zh/> 移除该属性会导致 Polygon 及其子类与 Node 不兼容
75
69
  *
76
70
  * <en/> Removing this property will cause Polygon and its subclasses to be incompatible with Node
@@ -200,12 +194,9 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
200
194
  }
201
195
 
202
196
  protected getKeyStyle(attributes: Required<S>) {
203
- const { color, fill, ...style } = this.getGraphicStyle(attributes);
197
+ const style = this.getGraphicStyle(attributes);
204
198
 
205
- return Object.assign(
206
- { fill: color || fill },
207
- omitStyleProps(style, ['label', 'halo', 'icon', 'badge', 'port']),
208
- ) as any;
199
+ return Object.assign(omitStyleProps(style, ['label', 'halo', 'icon', 'badge', 'port'])) as any;
209
200
  }
210
201
 
211
202
  protected getLabelStyle(attributes: Required<S>): false | LabelStyleProps {
@@ -310,8 +301,8 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
310
301
  * Get the key shape for the node.
311
302
  * @returns Key shape.
312
303
  */
313
- public getKey(): DisplayObject {
314
- return this.shapeMap.key;
304
+ public getKey<T extends DisplayObject>(): T {
305
+ return this.shapeMap.key as T;
315
306
  }
316
307
 
317
308
  /**
@@ -0,0 +1,137 @@
1
+ import { Path } from '@antv/g';
2
+ import { deepMix, isNumber, isString } from '@antv/util';
3
+ import { getPaletteColors } from '../../utils/palette';
4
+ import { subStyleProps } from '../../utils/prefix';
5
+ import { parseSize } from '../../utils/size';
6
+ import { Circle } from './circle';
7
+
8
+ import type { BaseStyleProps, DisplayObjectConfig, Group } from '@antv/g';
9
+ import type { PrefixObject } from '../../types';
10
+ import type { CircleStyleProps } from './circle';
11
+
12
+ interface Round extends BaseStyleProps {
13
+ /**
14
+ * <zh/> 数值,用于计算比例
15
+ *
16
+ * <en/> Numerical value used to calculate the scale.
17
+ */
18
+ value: number;
19
+ /**
20
+ * <zh/> 颜色
21
+ *
22
+ * <en/> Color.
23
+ */
24
+ color?: string;
25
+ }
26
+
27
+ export interface DonutStyleProps extends CircleStyleProps, PrefixObject<BaseStyleProps, 'donut'> {
28
+ /**
29
+ * <zh/> 内环半径,使用百分比或者像素值
30
+ *
31
+ * <en/> Inner ring radius, using percentage or pixel value.
32
+ */
33
+ innerRadius?: string | number;
34
+ /**
35
+ * <zh/> 圆环数据
36
+ *
37
+ * <en/> Donut data.
38
+ */
39
+ donuts?: number[] | Round[];
40
+ /**
41
+ * <zh/> 颜色或者色板名
42
+ *
43
+ * <en/> Color or palette.
44
+ */
45
+ colors?: string | string[];
46
+ }
47
+
48
+ export class Donut extends Circle {
49
+ static defaultStyleProps: Partial<DonutStyleProps> = {
50
+ innerRadius: '50%',
51
+ donuts: [],
52
+ colors: 'tableau',
53
+ };
54
+
55
+ constructor(options: DisplayObjectConfig<DonutStyleProps>) {
56
+ super(deepMix({}, { style: Donut.defaultStyleProps }, options));
57
+ }
58
+
59
+ protected drawDonutShape(attributes: Required<DonutStyleProps>, container: Group): void {
60
+ const { donuts, innerRadius = 0, size } = attributes;
61
+ if (!donuts?.length) return;
62
+
63
+ const parsedDonuts = donuts.map((round) => (isNumber(round) ? { value: round } : round) as Round);
64
+
65
+ const style = subStyleProps<BaseStyleProps>(this.getGraphicStyle(attributes), 'donut');
66
+
67
+ const colors = getPaletteColors(attributes.colors);
68
+ if (!colors) return;
69
+
70
+ const sum = parsedDonuts.reduce((acc, cur) => acc + (cur.value ?? 0), 0);
71
+
72
+ let start = 0;
73
+ parsedDonuts.forEach((round, index) => {
74
+ const { value = 0, color = colors[index % colors.length], ...roundStyle } = round;
75
+ const outerR = parseSize(size)[0] / 2;
76
+ const innerR = isString(innerRadius) ? (outerR * parseInt(innerRadius)) / 100 : innerRadius;
77
+ const angle = (sum === 0 ? 1 / parsedDonuts.length : value / sum) * 360;
78
+
79
+ this.upsert(
80
+ `round${index}`,
81
+ Path,
82
+ {
83
+ ...style,
84
+ path: arc(outerR, innerR, start, start + angle),
85
+ fill: color,
86
+ ...roundStyle,
87
+ },
88
+ container,
89
+ );
90
+
91
+ start += angle;
92
+ });
93
+ }
94
+
95
+ public render(attributes: Required<DonutStyleProps>, container: Group = this) {
96
+ super.render(attributes, container);
97
+ this.drawDonutShape(attributes, container);
98
+ }
99
+ }
100
+
101
+ const point = (x: number, y: number, r: number, angel: number) => [x + Math.sin(angel) * r, y - Math.cos(angel) * r];
102
+
103
+ const full = (x: number, y: number, R: number, r: number) => {
104
+ if (r <= 0 || R <= r) {
105
+ return [['M', x - R, y], ['A', R, R, 0, 1, 1, x + R, y], ['A', R, R, 0, 1, 1, x - R, y], ['Z']];
106
+ }
107
+ return [
108
+ ['M', x - R, y],
109
+ ['A', R, R, 0, 1, 1, x + R, y],
110
+ ['A', R, R, 0, 1, 1, x - R, y],
111
+ ['Z'],
112
+ ['M', x + r, y],
113
+ ['A', r, r, 0, 1, 0, x - r, y],
114
+ ['A', r, r, 0, 1, 0, x + r, y],
115
+ ['Z'],
116
+ ];
117
+ };
118
+
119
+ const part = (x: number, y: number, R: number, r: number, start: number, end: number) => {
120
+ const [s, e] = [(start / 360) * 2 * Math.PI, (end / 360) * 2 * Math.PI];
121
+ const P = [point(x, y, r, s), point(x, y, R, s), point(x, y, R, e), point(x, y, r, e)];
122
+ const flag = e - s > Math.PI ? 1 : 0;
123
+ return [
124
+ ['M', P[0][0], P[0][1]],
125
+ ['L', P[1][0], P[1][1]],
126
+ ['A', R, R, 0, flag, 1, P[2][0], P[2][1]],
127
+ ['L', P[3][0], P[3][1]],
128
+ ['A', r, r, 0, flag, 0, P[0][0], P[0][1]],
129
+ ['Z'],
130
+ ];
131
+ };
132
+
133
+ const arc = (R = 0, r = 0, start: number, end: number) => {
134
+ const [x, y] = [0, 0];
135
+ if (Math.abs(start - end) % 360 < 0.000001) return full(x, y, R, r);
136
+ return part(x, y, R, r, start, end);
137
+ };