@antv/g6 5.0.0-beta.2 → 5.0.0-beta.21

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/g6.min.js +2 -2
  2. package/esm/api-doc/graph.d.ts +3 -3
  3. package/esm/api-doc/graph.js +3 -3
  4. package/esm/api-doc/graph.js.map +1 -1
  5. package/esm/api-doc/types.d.ts +1 -0
  6. package/esm/api-doc/types.js +1 -2
  7. package/esm/api-doc/types.js.map +1 -1
  8. package/esm/constant/shape.d.ts +3 -1
  9. package/esm/index.d.ts +33 -65
  10. package/esm/index.js +4 -5
  11. package/esm/index.js.map +1 -1
  12. package/esm/item/combo.d.ts +1 -1
  13. package/esm/item/combo.js +18 -14
  14. package/esm/item/combo.js.map +1 -1
  15. package/esm/item/edge.d.ts +19 -2
  16. package/esm/item/edge.js +100 -44
  17. package/esm/item/edge.js.map +1 -1
  18. package/esm/item/item.d.ts +3 -2
  19. package/esm/item/item.js +27 -13
  20. package/esm/item/item.js.map +1 -1
  21. package/esm/item/node.d.ts +2 -8
  22. package/esm/item/node.js +31 -19
  23. package/esm/item/node.js.map +1 -1
  24. package/esm/runtime/controller/data.d.ts +30 -16
  25. package/esm/runtime/controller/data.js +290 -422
  26. package/esm/runtime/controller/data.js.map +1 -1
  27. package/esm/runtime/controller/interaction.js +9 -4
  28. package/esm/runtime/controller/interaction.js.map +1 -1
  29. package/esm/runtime/controller/item.d.ts +1 -0
  30. package/esm/runtime/controller/item.js +285 -150
  31. package/esm/runtime/controller/item.js.map +1 -1
  32. package/esm/runtime/controller/layout.js +1 -3
  33. package/esm/runtime/controller/layout.js.map +1 -1
  34. package/esm/runtime/controller/plugin.js +9 -5
  35. package/esm/runtime/controller/plugin.js.map +1 -1
  36. package/esm/runtime/graph.d.ts +104 -24
  37. package/esm/runtime/graph.js +472 -94
  38. package/esm/runtime/graph.js.map +1 -1
  39. package/esm/stdlib/behavior/activate-relations.js +2 -2
  40. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  41. package/esm/stdlib/behavior/brush-select.d.ts +7 -1
  42. package/esm/stdlib/behavior/brush-select.js +10 -12
  43. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  44. package/esm/stdlib/behavior/click-select.js +1 -1
  45. package/esm/stdlib/behavior/click-select.js.map +1 -1
  46. package/esm/stdlib/behavior/create-edge.d.ts +57 -0
  47. package/esm/stdlib/behavior/create-edge.js +215 -0
  48. package/esm/stdlib/behavior/create-edge.js.map +1 -0
  49. package/esm/stdlib/behavior/drag-canvas.d.ts +3 -1
  50. package/esm/stdlib/behavior/drag-canvas.js +78 -33
  51. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  52. package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
  53. package/esm/stdlib/behavior/drag-combo.js +43 -32
  54. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  55. package/esm/stdlib/behavior/drag-node.d.ts +3 -3
  56. package/esm/stdlib/behavior/drag-node.js +80 -63
  57. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  58. package/esm/stdlib/behavior/index.d.ts +3 -0
  59. package/esm/stdlib/behavior/index.js +3 -0
  60. package/esm/stdlib/behavior/index.js.map +1 -1
  61. package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
  62. package/esm/stdlib/behavior/lasso-select.js +3 -4
  63. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  64. package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
  65. package/esm/stdlib/behavior/scroll-canvas.js +266 -0
  66. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
  67. package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
  68. package/esm/stdlib/behavior/shortcuts-call.js +87 -0
  69. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
  70. package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
  71. package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  72. package/esm/stdlib/behavior/zoom-canvas.d.ts +3 -1
  73. package/esm/stdlib/behavior/zoom-canvas.js +70 -26
  74. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  75. package/esm/stdlib/data/index.d.ts +1 -0
  76. package/esm/stdlib/data/index.js +1 -0
  77. package/esm/stdlib/data/index.js.map +1 -1
  78. package/esm/stdlib/data/mapNodeSize.d.ts +4 -5
  79. package/esm/stdlib/data/mapNodeSize.js +12 -2
  80. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  81. package/esm/stdlib/data/processParallelEdges.d.ts +21 -0
  82. package/esm/stdlib/data/processParallelEdges.js +127 -0
  83. package/esm/stdlib/data/processParallelEdges.js.map +1 -0
  84. package/esm/stdlib/data/transformV4Data.d.ts +3 -4
  85. package/esm/stdlib/data/transformV4Data.js +10 -2
  86. package/esm/stdlib/data/transformV4Data.js.map +1 -1
  87. package/esm/stdlib/data/validateData.d.ts +4 -5
  88. package/esm/stdlib/data/validateData.js +22 -13
  89. package/esm/stdlib/data/validateData.js.map +1 -1
  90. package/esm/stdlib/index.d.ts +27 -8
  91. package/esm/stdlib/index.js +24 -11
  92. package/esm/stdlib/index.js.map +1 -1
  93. package/esm/stdlib/item/edge/base.d.ts +3 -5
  94. package/esm/stdlib/item/edge/base.js +32 -31
  95. package/esm/stdlib/item/edge/base.js.map +1 -1
  96. package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  97. package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
  98. package/esm/stdlib/item/edge/cubic.js +1 -1
  99. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  100. package/esm/stdlib/item/edge/loop.js +1 -1
  101. package/esm/stdlib/item/edge/loop.js.map +1 -1
  102. package/esm/stdlib/item/node/base.d.ts +3 -6
  103. package/esm/stdlib/item/node/base.js +30 -60
  104. package/esm/stdlib/item/node/base.js.map +1 -1
  105. package/esm/stdlib/item/node/base3d.d.ts +1 -0
  106. package/esm/stdlib/item/node/base3d.js +1 -0
  107. package/esm/stdlib/item/node/base3d.js.map +1 -1
  108. package/esm/stdlib/item/node/cube.d.ts +35 -0
  109. package/esm/stdlib/item/node/cube.js +54 -0
  110. package/esm/stdlib/item/node/cube.js.map +1 -0
  111. package/esm/stdlib/item/node/diamond.js +1 -1
  112. package/esm/stdlib/item/node/ellipse.js +2 -2
  113. package/esm/stdlib/item/node/hexagon.js +6 -2
  114. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  115. package/esm/stdlib/item/node/image.d.ts +40 -0
  116. package/esm/stdlib/item/node/image.js +110 -0
  117. package/esm/stdlib/item/node/image.js.map +1 -0
  118. package/esm/stdlib/item/node/index.d.ts +4 -0
  119. package/esm/stdlib/item/node/index.js +4 -0
  120. package/esm/stdlib/item/node/index.js.map +1 -1
  121. package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  122. package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
  123. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  124. package/esm/stdlib/plugin/grid/index.d.ts +1 -1
  125. package/esm/stdlib/plugin/grid/index.js +3 -4
  126. package/esm/stdlib/plugin/grid/index.js.map +1 -1
  127. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  128. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  129. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  130. package/esm/stdlib/plugin/history/index.js +14 -14
  131. package/esm/stdlib/plugin/history/index.js.map +1 -1
  132. package/esm/stdlib/plugin/history/item-data-command.js +25 -16
  133. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  134. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  135. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  136. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  137. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  138. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  139. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  140. package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
  141. package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  142. package/esm/stdlib/plugin/hull/hullComponent.js +5 -9
  143. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  144. package/esm/stdlib/plugin/hull/util.d.ts +2 -2
  145. package/esm/stdlib/plugin/hull/util.js +6 -2
  146. package/esm/stdlib/plugin/hull/util.js.map +1 -1
  147. package/esm/stdlib/plugin/index.d.ts +2 -0
  148. package/esm/stdlib/plugin/index.js +2 -0
  149. package/esm/stdlib/plugin/index.js.map +1 -1
  150. package/esm/stdlib/plugin/legend/index.d.ts +2 -2
  151. package/esm/stdlib/plugin/legend/index.js +3 -3
  152. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  153. package/esm/stdlib/plugin/menu/index.d.ts +4 -4
  154. package/esm/stdlib/plugin/menu/index.js +3 -3
  155. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  156. package/esm/stdlib/plugin/minimap/index.d.ts +6 -2
  157. package/esm/stdlib/plugin/minimap/index.js +119 -12
  158. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  159. package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
  160. package/esm/stdlib/plugin/snapline/index.js +1063 -0
  161. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  162. package/esm/stdlib/plugin/timebar/index.js +2 -2
  163. package/esm/stdlib/plugin/timebar/index.js.map +1 -1
  164. package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
  165. package/esm/stdlib/plugin/toolbar/index.js +4 -4
  166. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  167. package/esm/stdlib/plugin/tooltip/index.d.ts +4 -4
  168. package/esm/stdlib/plugin/tooltip/index.js +3 -4
  169. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  170. package/esm/stdlib/plugin/types.d.ts +2 -0
  171. package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
  172. package/esm/stdlib/plugin/watermaker/index.js +243 -0
  173. package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
  174. package/esm/stdlib/theme/dark.js +42 -2
  175. package/esm/stdlib/theme/dark.js.map +1 -1
  176. package/esm/stdlib/theme/light.js +4 -4
  177. package/esm/types/data.d.ts +5 -0
  178. package/esm/types/event.d.ts +1 -0
  179. package/esm/types/graph.d.ts +48 -22
  180. package/esm/types/hook.d.ts +22 -2
  181. package/esm/types/index.d.ts +2 -1
  182. package/esm/types/index.js +1 -0
  183. package/esm/types/index.js.map +1 -1
  184. package/esm/types/item.d.ts +7 -1
  185. package/esm/types/item.js.map +1 -1
  186. package/esm/types/plugin.d.ts +1 -1
  187. package/esm/types/spec.d.ts +20 -3
  188. package/esm/types/view.d.ts +5 -0
  189. package/esm/util/array.d.ts +1 -0
  190. package/esm/util/array.js +3 -0
  191. package/esm/util/array.js.map +1 -1
  192. package/esm/util/bbox.d.ts +16 -1
  193. package/esm/util/bbox.js +33 -5
  194. package/esm/util/bbox.js.map +1 -1
  195. package/esm/util/behavior.d.ts +2 -2
  196. package/esm/util/behavior.js +2 -2
  197. package/esm/util/behavior.js.map +1 -1
  198. package/esm/util/data.d.ts +5 -2
  199. package/esm/util/data.js +15 -0
  200. package/esm/util/data.js.map +1 -1
  201. package/esm/util/dom.d.ts +15 -0
  202. package/esm/util/dom.js +29 -0
  203. package/esm/util/dom.js.map +1 -0
  204. package/esm/util/event.d.ts +3 -1
  205. package/esm/util/event.js +8 -1
  206. package/esm/util/event.js.map +1 -1
  207. package/esm/util/extend.d.ts +1 -1
  208. package/esm/util/extend.js +0 -1
  209. package/esm/util/extend.js.map +1 -1
  210. package/esm/util/index.d.ts +7 -52
  211. package/esm/util/index.js +7 -23
  212. package/esm/util/index.js.map +1 -1
  213. package/esm/util/item.d.ts +16 -1
  214. package/esm/util/item.js +31 -8
  215. package/esm/util/item.js.map +1 -1
  216. package/esm/util/layout.d.ts +12 -1
  217. package/esm/util/layout.js +45 -0
  218. package/esm/util/layout.js.map +1 -1
  219. package/esm/util/loop.d.ts +2 -1
  220. package/esm/util/loop.js +14 -0
  221. package/esm/util/loop.js.map +1 -1
  222. package/esm/util/math.d.ts +1 -1
  223. package/esm/util/matrix.d.ts +6 -0
  224. package/esm/util/matrix.js +48 -0
  225. package/esm/util/matrix.js.map +1 -0
  226. package/esm/util/path.js +1 -1
  227. package/esm/util/path.js.map +1 -1
  228. package/esm/util/point.d.ts +1 -1
  229. package/esm/util/point.js +9 -2
  230. package/esm/util/point.js.map +1 -1
  231. package/esm/util/polyline.d.ts +2 -1
  232. package/esm/util/polyline.js +2 -1
  233. package/esm/util/polyline.js.map +1 -1
  234. package/esm/util/router.d.ts +1 -1
  235. package/esm/util/shape.d.ts +3 -3
  236. package/esm/util/shape.js +17 -26
  237. package/esm/util/shape.js.map +1 -1
  238. package/esm/util/shape3d.d.ts +1 -1
  239. package/esm/util/shape3d.js +16 -17
  240. package/esm/util/shape3d.js.map +1 -1
  241. package/esm/util/text.d.ts +1 -1
  242. package/esm/util/text.js +3 -2
  243. package/esm/util/text.js.map +1 -1
  244. package/esm/util/warn.d.ts +14 -0
  245. package/esm/util/warn.js +4 -0
  246. package/esm/util/warn.js.map +1 -0
  247. package/lib/api-doc/graph.d.ts +3 -3
  248. package/lib/api-doc/graph.js +27 -7
  249. package/lib/api-doc/graph.js.map +1 -1
  250. package/lib/api-doc/types.d.ts +1 -0
  251. package/lib/api-doc/types.js +2 -2
  252. package/lib/api-doc/types.js.map +1 -1
  253. package/lib/constant/shape.d.ts +3 -1
  254. package/lib/index.d.ts +33 -65
  255. package/lib/index.js +18 -10
  256. package/lib/index.js.map +1 -1
  257. package/lib/item/combo.d.ts +1 -1
  258. package/lib/item/combo.js +18 -14
  259. package/lib/item/combo.js.map +1 -1
  260. package/lib/item/edge.d.ts +19 -2
  261. package/lib/item/edge.js +99 -43
  262. package/lib/item/edge.js.map +1 -1
  263. package/lib/item/item.d.ts +3 -2
  264. package/lib/item/item.js +27 -13
  265. package/lib/item/item.js.map +1 -1
  266. package/lib/item/node.d.ts +2 -8
  267. package/lib/item/node.js +31 -19
  268. package/lib/item/node.js.map +1 -1
  269. package/lib/runtime/controller/data.d.ts +30 -16
  270. package/lib/runtime/controller/data.js +288 -420
  271. package/lib/runtime/controller/data.js.map +1 -1
  272. package/lib/runtime/controller/interaction.js +9 -4
  273. package/lib/runtime/controller/interaction.js.map +1 -1
  274. package/lib/runtime/controller/item.d.ts +1 -0
  275. package/lib/runtime/controller/item.js +284 -149
  276. package/lib/runtime/controller/item.js.map +1 -1
  277. package/lib/runtime/controller/layout.js +1 -3
  278. package/lib/runtime/controller/layout.js.map +1 -1
  279. package/lib/runtime/controller/plugin.js +9 -5
  280. package/lib/runtime/controller/plugin.js.map +1 -1
  281. package/lib/runtime/graph.d.ts +104 -24
  282. package/lib/runtime/graph.js +473 -94
  283. package/lib/runtime/graph.js.map +1 -1
  284. package/lib/stdlib/behavior/activate-relations.js +2 -2
  285. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  286. package/lib/stdlib/behavior/brush-select.d.ts +7 -1
  287. package/lib/stdlib/behavior/brush-select.js +13 -12
  288. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  289. package/lib/stdlib/behavior/click-select.js +1 -1
  290. package/lib/stdlib/behavior/click-select.js.map +1 -1
  291. package/lib/stdlib/behavior/create-edge.d.ts +57 -0
  292. package/lib/stdlib/behavior/create-edge.js +219 -0
  293. package/lib/stdlib/behavior/create-edge.js.map +1 -0
  294. package/lib/stdlib/behavior/drag-canvas.d.ts +3 -1
  295. package/lib/stdlib/behavior/drag-canvas.js +78 -33
  296. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  297. package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
  298. package/lib/stdlib/behavior/drag-combo.js +43 -32
  299. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  300. package/lib/stdlib/behavior/drag-node.d.ts +3 -3
  301. package/lib/stdlib/behavior/drag-node.js +80 -63
  302. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  303. package/lib/stdlib/behavior/index.d.ts +3 -0
  304. package/lib/stdlib/behavior/index.js +3 -0
  305. package/lib/stdlib/behavior/index.js.map +1 -1
  306. package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
  307. package/lib/stdlib/behavior/lasso-select.js +6 -4
  308. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  309. package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
  310. package/lib/stdlib/behavior/scroll-canvas.js +270 -0
  311. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
  312. package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
  313. package/lib/stdlib/behavior/shortcuts-call.js +91 -0
  314. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
  315. package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
  316. package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  317. package/lib/stdlib/behavior/zoom-canvas.d.ts +3 -1
  318. package/lib/stdlib/behavior/zoom-canvas.js +70 -26
  319. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  320. package/lib/stdlib/data/index.d.ts +1 -0
  321. package/lib/stdlib/data/index.js +1 -0
  322. package/lib/stdlib/data/index.js.map +1 -1
  323. package/lib/stdlib/data/mapNodeSize.d.ts +4 -5
  324. package/lib/stdlib/data/mapNodeSize.js +13 -3
  325. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  326. package/lib/stdlib/data/processParallelEdges.d.ts +21 -0
  327. package/lib/stdlib/data/processParallelEdges.js +131 -0
  328. package/lib/stdlib/data/processParallelEdges.js.map +1 -0
  329. package/lib/stdlib/data/transformV4Data.d.ts +3 -4
  330. package/lib/stdlib/data/transformV4Data.js +11 -3
  331. package/lib/stdlib/data/transformV4Data.js.map +1 -1
  332. package/lib/stdlib/data/validateData.d.ts +4 -5
  333. package/lib/stdlib/data/validateData.js +23 -14
  334. package/lib/stdlib/data/validateData.js.map +1 -1
  335. package/lib/stdlib/index.d.ts +27 -8
  336. package/lib/stdlib/index.js +24 -11
  337. package/lib/stdlib/index.js.map +1 -1
  338. package/lib/stdlib/item/edge/base.d.ts +3 -5
  339. package/lib/stdlib/item/edge/base.js +30 -29
  340. package/lib/stdlib/item/edge/base.js.map +1 -1
  341. package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  342. package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
  343. package/lib/stdlib/item/edge/cubic.js +2 -2
  344. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  345. package/lib/stdlib/item/edge/loop.js +3 -3
  346. package/lib/stdlib/item/edge/loop.js.map +1 -1
  347. package/lib/stdlib/item/node/base.d.ts +3 -6
  348. package/lib/stdlib/item/node/base.js +29 -59
  349. package/lib/stdlib/item/node/base.js.map +1 -1
  350. package/lib/stdlib/item/node/base3d.d.ts +1 -0
  351. package/lib/stdlib/item/node/base3d.js +1 -0
  352. package/lib/stdlib/item/node/base3d.js.map +1 -1
  353. package/lib/stdlib/item/node/cube.d.ts +35 -0
  354. package/lib/stdlib/item/node/cube.js +58 -0
  355. package/lib/stdlib/item/node/cube.js.map +1 -0
  356. package/lib/stdlib/item/node/diamond.js +1 -1
  357. package/lib/stdlib/item/node/ellipse.js +2 -2
  358. package/lib/stdlib/item/node/hexagon.js +6 -2
  359. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  360. package/lib/stdlib/item/node/image.d.ts +40 -0
  361. package/lib/stdlib/item/node/image.js +114 -0
  362. package/lib/stdlib/item/node/image.js.map +1 -0
  363. package/lib/stdlib/item/node/index.d.ts +4 -0
  364. package/lib/stdlib/item/node/index.js +4 -0
  365. package/lib/stdlib/item/node/index.js.map +1 -1
  366. package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  367. package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
  368. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  369. package/lib/stdlib/plugin/grid/index.d.ts +1 -1
  370. package/lib/stdlib/plugin/grid/index.js +6 -7
  371. package/lib/stdlib/plugin/grid/index.js.map +1 -1
  372. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  373. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  374. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  375. package/lib/stdlib/plugin/history/index.js +14 -14
  376. package/lib/stdlib/plugin/history/index.js.map +1 -1
  377. package/lib/stdlib/plugin/history/item-data-command.js +25 -16
  378. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  379. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  380. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  381. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  382. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  383. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  384. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  385. package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
  386. package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  387. package/lib/stdlib/plugin/hull/hullComponent.js +5 -9
  388. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  389. package/lib/stdlib/plugin/hull/util.d.ts +2 -2
  390. package/lib/stdlib/plugin/hull/util.js +26 -22
  391. package/lib/stdlib/plugin/hull/util.js.map +1 -1
  392. package/lib/stdlib/plugin/index.d.ts +2 -0
  393. package/lib/stdlib/plugin/index.js +2 -0
  394. package/lib/stdlib/plugin/index.js.map +1 -1
  395. package/lib/stdlib/plugin/legend/index.d.ts +2 -2
  396. package/lib/stdlib/plugin/legend/index.js +3 -3
  397. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  398. package/lib/stdlib/plugin/menu/index.d.ts +4 -4
  399. package/lib/stdlib/plugin/menu/index.js +6 -6
  400. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  401. package/lib/stdlib/plugin/minimap/index.d.ts +6 -2
  402. package/lib/stdlib/plugin/minimap/index.js +121 -14
  403. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  404. package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
  405. package/lib/stdlib/plugin/snapline/index.js +1067 -0
  406. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  407. package/lib/stdlib/plugin/timebar/index.js +2 -2
  408. package/lib/stdlib/plugin/timebar/index.js.map +1 -1
  409. package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
  410. package/lib/stdlib/plugin/toolbar/index.js +5 -5
  411. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  412. package/lib/stdlib/plugin/tooltip/index.d.ts +4 -4
  413. package/lib/stdlib/plugin/tooltip/index.js +10 -11
  414. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  415. package/lib/stdlib/plugin/types.d.ts +2 -0
  416. package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
  417. package/lib/stdlib/plugin/watermaker/index.js +247 -0
  418. package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
  419. package/lib/stdlib/theme/dark.js +42 -2
  420. package/lib/stdlib/theme/dark.js.map +1 -1
  421. package/lib/stdlib/theme/light.js +4 -4
  422. package/lib/types/data.d.ts +5 -0
  423. package/lib/types/event.d.ts +1 -0
  424. package/lib/types/graph.d.ts +48 -22
  425. package/lib/types/hook.d.ts +22 -2
  426. package/lib/types/index.d.ts +2 -1
  427. package/lib/types/index.js +3 -1
  428. package/lib/types/index.js.map +1 -1
  429. package/lib/types/item.d.ts +7 -1
  430. package/lib/types/item.js.map +1 -1
  431. package/lib/types/plugin.d.ts +1 -1
  432. package/lib/types/spec.d.ts +20 -3
  433. package/lib/types/view.d.ts +5 -0
  434. package/lib/util/array.d.ts +1 -0
  435. package/lib/util/array.js +5 -1
  436. package/lib/util/array.js.map +1 -1
  437. package/lib/util/bbox.d.ts +16 -1
  438. package/lib/util/bbox.js +36 -6
  439. package/lib/util/bbox.js.map +1 -1
  440. package/lib/util/behavior.d.ts +2 -2
  441. package/lib/util/behavior.js +2 -2
  442. package/lib/util/behavior.js.map +1 -1
  443. package/lib/util/data.d.ts +5 -2
  444. package/lib/util/data.js +16 -1
  445. package/lib/util/data.js.map +1 -1
  446. package/lib/util/dom.d.ts +15 -0
  447. package/lib/util/dom.js +34 -0
  448. package/lib/util/dom.js.map +1 -0
  449. package/lib/util/event.d.ts +3 -1
  450. package/lib/util/event.js +8 -1
  451. package/lib/util/event.js.map +1 -1
  452. package/lib/util/extend.d.ts +1 -1
  453. package/lib/util/extend.js +0 -1
  454. package/lib/util/extend.js.map +1 -1
  455. package/lib/util/index.d.ts +7 -52
  456. package/lib/util/index.js +23 -23
  457. package/lib/util/index.js.map +1 -1
  458. package/lib/util/item.d.ts +16 -1
  459. package/lib/util/item.js +33 -9
  460. package/lib/util/item.js.map +1 -1
  461. package/lib/util/layout.d.ts +12 -1
  462. package/lib/util/layout.js +47 -1
  463. package/lib/util/layout.js.map +1 -1
  464. package/lib/util/loop.d.ts +2 -1
  465. package/lib/util/loop.js +15 -1
  466. package/lib/util/loop.js.map +1 -1
  467. package/lib/util/math.d.ts +1 -1
  468. package/lib/util/matrix.d.ts +6 -0
  469. package/lib/util/matrix.js +52 -0
  470. package/lib/util/matrix.js.map +1 -0
  471. package/lib/util/path.js +2 -2
  472. package/lib/util/path.js.map +1 -1
  473. package/lib/util/point.d.ts +1 -1
  474. package/lib/util/point.js +9 -2
  475. package/lib/util/point.js.map +1 -1
  476. package/lib/util/polyline.d.ts +2 -1
  477. package/lib/util/polyline.js +2 -1
  478. package/lib/util/polyline.js.map +1 -1
  479. package/lib/util/router.d.ts +1 -1
  480. package/lib/util/shape.d.ts +3 -3
  481. package/lib/util/shape.js +17 -26
  482. package/lib/util/shape.js.map +1 -1
  483. package/lib/util/shape3d.d.ts +1 -1
  484. package/lib/util/shape3d.js +15 -16
  485. package/lib/util/shape3d.js.map +1 -1
  486. package/lib/util/text.d.ts +1 -1
  487. package/lib/util/text.js +3 -2
  488. package/lib/util/text.js.map +1 -1
  489. package/lib/util/warn.d.ts +14 -0
  490. package/lib/util/warn.js +8 -0
  491. package/lib/util/warn.js.map +1 -0
  492. package/package.json +42 -51
  493. package/src/api-doc/graph.ts +4 -3
  494. package/src/api-doc/types.ts +1 -0
  495. package/src/constant/shape.ts +1 -1
  496. package/src/index.ts +5 -6
  497. package/src/item/combo.ts +16 -15
  498. package/src/item/edge.ts +135 -57
  499. package/src/item/item.ts +32 -19
  500. package/src/item/node.ts +36 -50
  501. package/src/runtime/controller/data.ts +371 -490
  502. package/src/runtime/controller/interaction.ts +10 -4
  503. package/src/runtime/controller/item.ts +261 -78
  504. package/src/runtime/controller/layout.ts +1 -5
  505. package/src/runtime/controller/plugin.ts +15 -4
  506. package/src/runtime/graph.ts +605 -103
  507. package/src/stdlib/behavior/activate-relations.ts +2 -2
  508. package/src/stdlib/behavior/brush-select.ts +14 -13
  509. package/src/stdlib/behavior/click-select.ts +1 -1
  510. package/src/stdlib/behavior/create-edge.ts +305 -0
  511. package/src/stdlib/behavior/drag-canvas.ts +107 -35
  512. package/src/stdlib/behavior/drag-combo.ts +10 -10
  513. package/src/stdlib/behavior/drag-node.ts +27 -18
  514. package/src/stdlib/behavior/index.ts +3 -0
  515. package/src/stdlib/behavior/lasso-select.ts +7 -5
  516. package/src/stdlib/behavior/scroll-canvas.ts +348 -0
  517. package/src/stdlib/behavior/shortcuts-call.ts +129 -0
  518. package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
  519. package/src/stdlib/behavior/zoom-canvas.ts +98 -27
  520. package/src/stdlib/data/index.ts +1 -0
  521. package/src/stdlib/data/mapNodeSize.ts +22 -3
  522. package/src/stdlib/data/processParallelEdges.ts +203 -0
  523. package/src/stdlib/data/transformV4Data.ts +16 -3
  524. package/src/stdlib/data/validateData.ts +32 -18
  525. package/src/stdlib/index.ts +31 -8
  526. package/src/stdlib/item/edge/base.ts +32 -41
  527. package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
  528. package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
  529. package/src/stdlib/item/edge/cubic.ts +1 -1
  530. package/src/stdlib/item/edge/loop.ts +1 -1
  531. package/src/stdlib/item/node/base.ts +38 -65
  532. package/src/stdlib/item/node/base3d.ts +1 -0
  533. package/src/stdlib/item/node/cube.ts +102 -0
  534. package/src/stdlib/item/node/diamond.ts +1 -1
  535. package/src/stdlib/item/node/ellipse.ts +2 -2
  536. package/src/stdlib/item/node/hexagon.ts +6 -2
  537. package/src/stdlib/item/node/image.ts +190 -0
  538. package/src/stdlib/item/node/index.ts +4 -0
  539. package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
  540. package/src/stdlib/plugin/grid/index.ts +6 -6
  541. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  542. package/src/stdlib/plugin/history/index.ts +14 -14
  543. package/src/stdlib/plugin/history/item-data-command.ts +35 -17
  544. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  545. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  546. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  547. package/src/stdlib/plugin/hull/convexHull.ts +1 -1
  548. package/src/stdlib/plugin/hull/hullComponent.ts +10 -8
  549. package/src/stdlib/plugin/hull/util.ts +6 -2
  550. package/src/stdlib/plugin/index.ts +2 -0
  551. package/src/stdlib/plugin/legend/index.ts +6 -6
  552. package/src/stdlib/plugin/menu/index.ts +13 -13
  553. package/src/stdlib/plugin/minimap/index.ts +126 -16
  554. package/src/stdlib/plugin/snapline/index.ts +1297 -0
  555. package/src/stdlib/plugin/timebar/index.ts +4 -4
  556. package/src/stdlib/plugin/toolbar/index.ts +8 -8
  557. package/src/stdlib/plugin/tooltip/index.ts +10 -10
  558. package/src/stdlib/plugin/types.ts +2 -0
  559. package/src/stdlib/plugin/watermaker/index.ts +302 -0
  560. package/src/stdlib/theme/dark.ts +66 -2
  561. package/src/stdlib/theme/light.ts +4 -4
  562. package/src/types/data.ts +6 -0
  563. package/src/types/event.ts +1 -0
  564. package/src/types/graph.ts +62 -25
  565. package/src/types/hook.ts +22 -2
  566. package/src/types/index.ts +2 -1
  567. package/src/types/item.ts +12 -1
  568. package/src/types/plugin.ts +1 -1
  569. package/src/types/spec.ts +23 -3
  570. package/src/types/view.ts +8 -3
  571. package/src/util/array.ts +12 -0
  572. package/src/util/bbox.ts +42 -6
  573. package/src/util/behavior.ts +4 -4
  574. package/src/util/data.ts +26 -4
  575. package/src/util/dom.ts +33 -0
  576. package/src/util/event.ts +14 -1
  577. package/src/util/extend.ts +2 -3
  578. package/src/util/index.ts +7 -24
  579. package/src/util/item.ts +65 -28
  580. package/src/util/layout.ts +48 -2
  581. package/src/util/loop.ts +16 -1
  582. package/src/util/math.ts +1 -1
  583. package/src/util/matrix.ts +66 -0
  584. package/src/util/path.ts +1 -1
  585. package/src/util/point.ts +9 -4
  586. package/src/util/polyline.ts +2 -1
  587. package/src/util/router.ts +1 -1
  588. package/src/util/shape.ts +23 -26
  589. package/src/util/shape3d.ts +20 -20
  590. package/src/util/text.ts +3 -1
  591. package/src/util/warn.ts +20 -0
@@ -1,4 +1,3 @@
1
- import { createDom } from '@antv/dom-util';
2
1
  import { Canvas } from '@antv/g';
3
2
  import type { TimebarStyleProps } from '@antv/gui';
4
3
  import { Timebar as GUITimebar } from '@antv/gui';
@@ -10,6 +9,7 @@ import type { ITEM_TYPE } from '../../../types/item';
10
9
  import { Plugin as Base, IPluginBaseConfig } from '../../../types/plugin';
11
10
  import { createCanvas } from '../../../util/canvas';
12
11
  import { formatPadding } from '../../../util/shape';
12
+ import { createDOM } from '../../../util/dom';
13
13
 
14
14
  // -- start -- Adapt to GUI -- start --
15
15
  type SubStyleProps<T, Prefix extends string> = {
@@ -123,7 +123,7 @@ const tryToGet = <T = any>(
123
123
  };
124
124
 
125
125
  export class Timebar extends Base {
126
- private wrapper: HTMLDivElement;
126
+ private wrapper: HTMLElement;
127
127
  private canvas: Canvas;
128
128
  private timebar: GUITimebar;
129
129
  private graphDataCache: GraphData;
@@ -235,9 +235,9 @@ export class Timebar extends Base {
235
235
  const { className } = options;
236
236
  const { width, height } = this.containerShape;
237
237
 
238
- const wrapper = (HTMLDivElement = createDom(
238
+ const wrapper = createDOM(
239
239
  `<div class="${className}" style="width: ${width}px;height: ${height}"></div>`,
240
- ));
240
+ );
241
241
  this.container.appendChild(wrapper);
242
242
  return wrapper;
243
243
  }
@@ -1,13 +1,13 @@
1
- import { createDom, modifyCSS } from '@antv/dom-util';
2
1
  import insertCss from 'insert-css';
3
2
  import { IGraph } from '../../../types';
4
3
  import { Plugin as Base, IPluginBaseConfig } from '../../../types/plugin';
4
+ import { createDOM, modifyCSS } from '../../../util/dom';
5
5
 
6
6
  /**
7
7
  * The `ToolbarConfig` interface contains the following properties:
8
8
 
9
9
  - `handleClick`: An optional function for handling clicks on the toolbar. It takes two arguments: `code` (of type string) and `graph` (of type IGraph), and has no return value.
10
- - `getContent`: A required function for getting the content of the toolbar. It takes an optional argument of type `IGraph`, and returns a value of type HTMLDivElement or string.
10
+ - `getContent`: A required function for getting the content of the toolbar. It takes an optional argument of type `IGraph`, and returns a value of type HTMLElement or string.
11
11
  - `zoomSensitivity`: An optional number representing the zoom sensitivity of the toolbar. The default value is 10.
12
12
  - `minZoom`: An optional number representing the minimum zoom ratio of the toolbar. The default value is 0.00001.
13
13
  - `maxZoom`: An optional number representing the maximum zoom ratio of the toolbar. The default value is 1000.
@@ -17,7 +17,7 @@ export interface ToolbarConfig extends IPluginBaseConfig {
17
17
  /** Function for handling clicks on toolbar */
18
18
  handleClick?: (code: string, graph: IGraph) => void;
19
19
  /** Function for getting content of toolbar */
20
- getContent: (graph?: IGraph) => HTMLDivElement | string;
20
+ getContent: (graph?: IGraph) => HTMLElement | string;
21
21
  /** Zoom sensitivity of toolbar */
22
22
  zoomSensitivity: number;
23
23
  /** Minimum zoom ratio of toolbar */
@@ -51,12 +51,12 @@ const getEventPath = (evt: MouseEvent) => {
51
51
  };
52
52
 
53
53
  export class Toolbar extends Base {
54
- public ToolbarDOM: HTMLDivElement;
54
+ public ToolbarDOM: HTMLElement;
55
55
  public ContainerDOM: HTMLElement;
56
56
  constructor(config: Partial<ToolbarConfig>) {
57
57
  super(config);
58
- this.ToolbarDOM = createDom('<div></div>');
59
- this.ContainerDOM = createDom('<div></div>');
58
+ this.ToolbarDOM = createDOM('<div></div>');
59
+ this.ContainerDOM = createDOM('<div></div>');
60
60
  }
61
61
  public getDefaultCfgs(): ToolbarConfig {
62
62
  return {
@@ -95,7 +95,7 @@ export class Toolbar extends Base {
95
95
  public getContainer() {
96
96
  const { container } = this.options;
97
97
  if (typeof container === 'string') {
98
- this.ContainerDOM = document.getElementById(container) as HTMLDivElement;
98
+ this.ContainerDOM = document.getElementById(container) as HTMLElement;
99
99
  } else {
100
100
  this.ContainerDOM = this.graph.container;
101
101
  }
@@ -109,7 +109,7 @@ export class Toolbar extends Base {
109
109
  const { getContent, className, handleClick, position } = this.options;
110
110
  const ToolBarContent = getContent(graph);
111
111
  if (typeof ToolBarContent === 'string') {
112
- this.ToolbarDOM = createDom(ToolBarContent);
112
+ this.ToolbarDOM = createDOM(ToolBarContent);
113
113
  } else {
114
114
  this.ToolbarDOM = ToolBarContent;
115
115
  }
@@ -1,11 +1,11 @@
1
1
  // TODO: update type define.
2
- import { createDom, modifyCSS } from '@antv/dom-util';
3
2
  import { AABB } from '@antv/g';
4
3
  import { isArray, isString, uniqueId } from '@antv/util';
5
4
  import insertCss from 'insert-css';
6
5
  import { IGraph } from '../../../types';
7
6
  import { IG6GraphEvent } from '../../../types/event';
8
7
  import { Plugin as Base, IPluginBaseConfig } from '../../../types/plugin';
8
+ import { createDOM, modifyCSS } from '../../../util/dom';
9
9
 
10
10
  typeof document !== 'undefined' &&
11
11
  insertCss(`
@@ -56,21 +56,21 @@ type Placement =
56
56
  /**
57
57
  * The `TooltipConfig` interface contains the following properties:
58
58
 
59
- - `getContent`: An optional function for getting the content of the tooltip. It takes an optional argument of type `IG6GraphEvent`, and returns a value of type HTMLDivElement, string, or Promise (resolving to HTMLDivElement or string).
59
+ - `getContent`: An optional function for getting the content of the tooltip. It takes an optional argument of type `IG6GraphEvent`, and returns a value of type HTMLElement, string, or Promise (resolving to HTMLElement or string).
60
60
  - `offsetX`: An optional number representing the offset of the tooltip in the X direction.
61
61
  - `offsetY`: An optional number representing the offset of the tooltip in the Y direction.
62
62
  - `shouldBegin`: An optional function for determining whether the tooltip should be displayed. It takes an optional argument of type `IG6GraphEvent`, and returns a boolean value.
63
63
  - `itemTypes`: An optional array of strings representing the types of items for which the tooltip is allowed to be displayed. The possible values are 'node', 'edge', 'combo', and 'canvas'.
64
64
  - `trigger`: An optional string, either 'pointerenter' or 'click', representing the event type that triggers the display of the tooltip.
65
65
  - `fixToNode`: An optional array of two numbers, a string representing a placement, or undefined, representing how to fix the tooltip to a node.
66
- - `loadingContent`: An optional HTMLDivElement or string representing the loading DOM.
66
+ - `loadingContent`: An optional HTMLElement or string representing the loading DOM.
67
67
 
68
68
  */
69
69
  export interface TooltipConfig extends IPluginBaseConfig {
70
70
  /** Function for getting tooltip content */
71
71
  getContent?: (
72
72
  evt?: IG6GraphEvent,
73
- ) => HTMLDivElement | string | Promise<HTMLDivElement | string>;
73
+ ) => HTMLElement | string | Promise<HTMLElement | string>;
74
74
  /** Offset of tooltip in X direction */
75
75
  offsetX?: number;
76
76
  /** Offset of tooltip in Y direction */
@@ -84,7 +84,7 @@ export interface TooltipConfig extends IPluginBaseConfig {
84
84
  /** How to fix tooltip to node */
85
85
  fixToNode?: [number, number] | Placement | undefined;
86
86
  /** Loading DOM */
87
- loadingContent?: HTMLDivElement | string;
87
+ loadingContent?: HTMLElement | string;
88
88
  }
89
89
  export class Tooltip extends Base {
90
90
  private tooltip;
@@ -153,7 +153,7 @@ export class Tooltip extends Base {
153
153
  public init(graph: IGraph) {
154
154
  super.init(graph);
155
155
  const className = this.options.className;
156
- const tooltip = createDom(
156
+ const tooltip = createDOM(
157
157
  `<div class='${className || 'g6-component-tooltip'}'></div>`,
158
158
  );
159
159
  modifyCSS(tooltip, {
@@ -173,12 +173,12 @@ export class Tooltip extends Base {
173
173
  });
174
174
  }
175
175
  //`container` string type in v5
176
- let container: HTMLDivElement | null | string = this.options.container;
176
+ let container: HTMLElement | null | string = this.options.container;
177
177
  if (!container) {
178
- container = this.graph.container as HTMLDivElement;
178
+ container = this.graph.container as HTMLElement;
179
179
  }
180
180
  if (isString(container)) {
181
- container = document.getElementById(container) as HTMLDivElement;
181
+ container = document.getElementById(container) as HTMLElement;
182
182
  }
183
183
  container.appendChild(tooltip);
184
184
  this.tooltip = tooltip;
@@ -264,7 +264,7 @@ export class Tooltip extends Base {
264
264
  });
265
265
  if (isString(tooltip)) {
266
266
  tooltipDom.innerHTML = tooltip;
267
- } else if (tooltip instanceof HTMLDivElement) {
267
+ } else if (tooltip instanceof HTMLElement) {
268
268
  this.clearContainer();
269
269
  this.container.appendChild(tooltip);
270
270
  } else {
@@ -7,3 +7,5 @@ export type { MiniMapConfig } from './minimap';
7
7
  export type { ToolbarConfig } from './toolbar';
8
8
  export type { TooltipConfig } from './tooltip';
9
9
  export type { TimebarConfig } from './timebar';
10
+ export type { SnapLineConfig } from './snapline';
11
+ export type { EdgeFilterLens } from './edgeFilterLens';
@@ -0,0 +1,302 @@
1
+ import { uniqueId, isString } from '@antv/util';
2
+ import { Canvas, Group, Image, Text, TextStyleProps } from '@antv/g';
3
+ import { Plugin as Base, IPluginBaseConfig } from '../../../types/plugin';
4
+ import { createCanvas } from '../../../util/canvas';
5
+ import { IGraph } from '../../../types';
6
+
7
+ /** Define configuration types for image and text watermarks */
8
+ type ImageWaterMarkerConfig = {
9
+ /** URL of the image used as the watermark. */
10
+ imgURL: string;
11
+ /** Width of the image watermark in pixels. */
12
+ width: number;
13
+ /** Height of the image watermark in pixels. */
14
+ height: number;
15
+ /** Rotation angle of the image watermark in degrees (0 to 360). */
16
+ rotate: number;
17
+ };
18
+ interface TextWaterMarkerConfig extends TextStyleProps {
19
+ /** Text or an array of texts to be used as the watermark content. */
20
+ texts: string | string[];
21
+ /** Rotation angle of the text watermark in degrees (0 to 360). */
22
+ rotate: number;
23
+ }
24
+
25
+ /** Define configuration types for watermarks */
26
+ export interface WaterMarkerConfig extends IPluginBaseConfig {
27
+ /** The watermarker canvas. undefined by default means create a new canvas to draw the markers. */
28
+ canvas?: Canvas;
29
+ /** (Optional) The width of the watermark canvas in pixels. undefined by default, means equal to graph's width. */
30
+ width?: number;
31
+ /** (Optional) The height of the watermark canvas in pixels. undefined by default, means equal to graph's height. */
32
+ height?: number;
33
+ /** (Optional) The mode of the watermark, either 'image' or 'text'. */
34
+ mode?: 'image' | 'text';
35
+ /** (Optional) The position of the watermark, default: under the main canvas*/
36
+ position?: 'top' | 'middle' | 'bottom';
37
+ /** (Optional) Configuration for an image watermark (See ImageWaterMarkerConfig). */
38
+ image?: Partial<ImageWaterMarkerConfig>;
39
+ /** (Optional) Configuration for a text watermark (See TextWaterMarkerConfig). */
40
+ text?: Partial<TextWaterMarkerConfig>;
41
+ /** The first marker's position. [0, 0] by default. */
42
+ begin?: [number, number];
43
+ /** The gap of x and y between neighbor markers. [100, 100] by default. */
44
+ seperation?: [number, number];
45
+ }
46
+
47
+ export class WaterMarker extends Base {
48
+ private container: HTMLElement;
49
+ private canvas: Canvas;
50
+ private canvasSize: [number, number];
51
+ private followGraphSize: boolean;
52
+
53
+ constructor(options?: WaterMarkerConfig) {
54
+ super(options);
55
+ }
56
+
57
+ public getDefaultCfgs(): WaterMarkerConfig {
58
+ return {
59
+ key: `watermarker-${uniqueId()}`,
60
+ container: null,
61
+ canvas: undefined,
62
+ mode: 'image',
63
+ width: undefined,
64
+ height: undefined,
65
+ position: 'bottom',
66
+ begin: [0, 0],
67
+ seperation: [100, 100],
68
+ image: {
69
+ imgURL:
70
+ 'https://gw.alipayobjects.com/os/s/prod/antv/assets/image/logo-with-text-73b8a.svg',
71
+ width: 94,
72
+ height: 28,
73
+ rotate: 0,
74
+ },
75
+ text: {
76
+ texts: 'AntV',
77
+ rotate: 20,
78
+ fontSize: 14,
79
+ fontFamily: 'Microsoft YaHei',
80
+ fill: 'rgba(0, 0, 0, 0.1)',
81
+ textBaseline: 'top',
82
+ },
83
+ };
84
+ }
85
+
86
+ /**
87
+ * Initialize the WaterMarker plugin.
88
+ */
89
+ public init(graph: IGraph) {
90
+ super.init(graph);
91
+ const promise = this.initCanvas();
92
+ promise.then(() => {
93
+ this.updateWaterMarker();
94
+ });
95
+ }
96
+
97
+ public getEvents() {
98
+ return {
99
+ aftersetsize: this.onGraphSetSize,
100
+ };
101
+ }
102
+
103
+ /**
104
+ * Initialize the canvas for watermark rendering.
105
+ */
106
+ public initCanvas() {
107
+ const { graph, options } = this;
108
+ const { width, height, position, canvas } = options;
109
+ let parentNode = options.container;
110
+ let container: HTMLElement;
111
+
112
+ const graphSize = graph.getSize();
113
+ if (canvas) {
114
+ this.canvas = canvas;
115
+ this.canvasSize = [graphSize[0], graphSize[1]];
116
+ this.followGraphSize = true;
117
+ this.container = graph.container as HTMLDivElement;
118
+ return canvas.ready;
119
+ }
120
+
121
+ if (isString(parentNode)) {
122
+ parentNode = document.getElementById(parentNode) as HTMLElement;
123
+ }
124
+ if (parentNode) {
125
+ container = parentNode;
126
+ } else {
127
+ container = graph.container as HTMLElement;
128
+ }
129
+ if (!container.style.position) {
130
+ container.style.position = 'relative';
131
+ }
132
+
133
+ this.canvasSize = [
134
+ width === undefined ? graphSize[0] : width,
135
+ height === undefined ? graphSize[1] : height,
136
+ ];
137
+ this.followGraphSize = width === undefined || height === undefined;
138
+
139
+ this.canvas = createCanvas(
140
+ 'canvas',
141
+ container,
142
+ this.canvasSize[0],
143
+ this.canvasSize[1],
144
+ );
145
+ const $domElement = this.canvas
146
+ .getContextService()
147
+ .getDomElement() as unknown as HTMLElement;
148
+ $domElement.style.position = 'fixed';
149
+ $domElement.style.outline = 'none';
150
+ $domElement.style.pointerEvents = 'none';
151
+ $domElement.style.userSelect = 'none';
152
+ this.container = container;
153
+
154
+ const canvasEl = this.canvas.getContextService().getDomElement() as any;
155
+ this.container.removeChild(canvasEl);
156
+ const graphCanvasDOM = graph.canvas
157
+ .getContextService()
158
+ .getDomElement() as any;
159
+ const graphTransientCanvasDOM = graph.transientCanvas
160
+ .getContextService()
161
+ .getDomElement() as any;
162
+ switch (position) {
163
+ case 'top':
164
+ this.container.appendChild(canvasEl);
165
+ break;
166
+ case 'middle':
167
+ this.container.insertBefore(canvasEl, graphTransientCanvasDOM);
168
+ break;
169
+ case 'bottom':
170
+ default:
171
+ this.container.insertBefore(canvasEl, graphCanvasDOM);
172
+ }
173
+
174
+ return this.canvas.ready;
175
+ }
176
+
177
+ private onGraphSetSize(e) {
178
+ const { size } = e;
179
+ if (!this.followGraphSize) return;
180
+ this.canvas.resize(size[0], size[1]);
181
+ this.updateWaterMarker();
182
+ }
183
+
184
+ /**
185
+ * Update the watermark based on the chosen mode (image or text).
186
+ */
187
+ public updateWaterMarker() {
188
+ switch (this.options.mode) {
189
+ case 'text':
190
+ this.setTextWaterMarker();
191
+ break;
192
+ case 'image':
193
+ default:
194
+ this.setImageWaterMarker();
195
+ break;
196
+ }
197
+ }
198
+
199
+ /**
200
+ * Render an image watermark on the canvas.
201
+ */
202
+ public setImageWaterMarker() {
203
+ const { canvas, options, canvasSize } = this;
204
+ const { image, begin, seperation } = options;
205
+ const { imgURL, rotate = 0, ...imageStyles } = image;
206
+
207
+ const currentPosition = [...begin];
208
+ let imageBounds;
209
+ const getRowGroup = () => {
210
+ const rowGroup = new Group();
211
+ while (currentPosition[0] < canvasSize[0]) {
212
+ const imageShape = new Image({
213
+ style: {
214
+ ...imageStyles,
215
+ img: imgURL,
216
+ x: currentPosition[0],
217
+ y: currentPosition[1],
218
+ },
219
+ });
220
+ if (rotate) {
221
+ imageShape.style.transformOrigin = 'center';
222
+ imageShape.style.transform = `rotate(${rotate}deg)`;
223
+ }
224
+ if (!imageBounds) {
225
+ imageBounds = imageShape.getLocalBounds();
226
+ }
227
+ rowGroup.appendChild(imageShape);
228
+ currentPosition[0] += imageBounds.halfExtents[0] * 2 + seperation[0];
229
+ }
230
+ return rowGroup;
231
+ };
232
+ while (currentPosition[1] < canvasSize[1]) {
233
+ canvas.appendChild(getRowGroup());
234
+ currentPosition[0] = begin[0];
235
+ currentPosition[1] += imageBounds.halfExtents[1] * 2 + seperation[1];
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Render a text watermark on the canvas.
241
+ */
242
+ public async setTextWaterMarker() {
243
+ const { canvas, options, canvasSize } = this;
244
+ const { text, seperation, begin } = options;
245
+ const { texts, rotate, ...textStyles } = text;
246
+
247
+ const currentPosition = [...begin];
248
+ const displayTexts = isString(texts) ? [texts] : texts;
249
+ const textContent = displayTexts.join('\n');
250
+ let textBounds;
251
+ const getRowGroup = () => {
252
+ const rowGroup = new Group();
253
+ while (currentPosition[0] < canvasSize[0]) {
254
+ const textShape = new Text({
255
+ style: {
256
+ ...textStyles,
257
+ text: textContent,
258
+ x: currentPosition[0],
259
+ y: currentPosition[1],
260
+ },
261
+ });
262
+ if (rotate) {
263
+ textShape.style.transform = `rotate(${rotate}deg)`;
264
+ }
265
+ if (!textBounds) {
266
+ textBounds = textShape.getLocalBounds();
267
+ }
268
+ rowGroup.appendChild(textShape);
269
+ currentPosition[0] += textBounds.halfExtents[0] * 2 + seperation[0];
270
+ }
271
+ return rowGroup;
272
+ };
273
+ while (currentPosition[1] < canvasSize[1]) {
274
+ canvas.appendChild(getRowGroup());
275
+ currentPosition[0] = begin[0];
276
+ currentPosition[1] += textBounds.halfExtents[1] * 2 + seperation[1];
277
+ }
278
+ }
279
+
280
+ /**
281
+ * Destroy the WaterMarker and remove it from the container.
282
+ */
283
+ public destroy() {
284
+ const { canvas, options } = this;
285
+
286
+ const parentNode = options.container;
287
+ let container: HTMLElement;
288
+
289
+ if (!parentNode) {
290
+ container = this.graph.container as HTMLElement;
291
+ }
292
+ if (isString(container)) {
293
+ container = document.getElementById(container) as HTMLElement;
294
+ }
295
+
296
+ if (container !== this.graph.container) {
297
+ container.remove();
298
+ }
299
+
300
+ canvas.destroy();
301
+ }
302
+ }
@@ -7,6 +7,7 @@ const textColor = 'rgba(255,255,255,0.85)';
7
7
  const nodeColor = 'rgb(34,126,255)';
8
8
  const edgeColor = 'rgb(153, 173, 209)';
9
9
  const comboFill = 'rgb(253, 253, 253)';
10
+ const comboStroke = 'rgba(153,173,209,1)';
10
11
  const disabledFill = '#D0E4FF';
11
12
 
12
13
  const edgeMainStroke = '#637088';
@@ -105,7 +106,7 @@ export const DarkTheme = {
105
106
  },
106
107
  haloShape: {
107
108
  opacity: 0.45,
108
- lineWidth: 20,
109
+ lineWidth: 12,
109
110
  zIndex: -1,
110
111
  pointerEvents: 'none',
111
112
  visible: true,
@@ -118,7 +119,7 @@ export const DarkTheme = {
118
119
  },
119
120
  haloShape: {
120
121
  opacity: 0.25,
121
- lineWidth: 20,
122
+ lineWidth: 12,
122
123
  zIndex: -1,
123
124
  pointerEvents: 'none',
124
125
  visible: true,
@@ -301,6 +302,23 @@ export const DarkTheme = {
301
302
  height: 10,
302
303
  padding: [25, 20, 15, 20],
303
304
  },
305
+ labelShape: {
306
+ ...DEFAULT_TEXT_STYLE,
307
+ fill: textColor,
308
+ opacity: 0.85,
309
+ position: 'bottom',
310
+ zIndex: 2,
311
+ lod: 0,
312
+ maxLines: 1,
313
+ },
314
+ labelBackgroundShape: {
315
+ padding: [2, 4, 2, 4],
316
+ lineWidth: 0,
317
+ fill: '#000',
318
+ opacity: 0.75,
319
+ zIndex: 1,
320
+ lod: 0,
321
+ },
304
322
  },
305
323
  selected: {
306
324
  keyShape: {
@@ -311,12 +329,30 @@ export const DarkTheme = {
311
329
  labelShape: {
312
330
  fontWeight: 700,
313
331
  },
332
+ haloShape: {
333
+ opacity: 0.25,
334
+ lineWidth: 12,
335
+ pointerEvents: 'none',
336
+ zIndex: -1,
337
+ visible: true,
338
+ stroke: comboStroke,
339
+ droppable: false,
340
+ },
314
341
  },
315
342
  active: {
316
343
  keyShape: {
317
344
  stroke: nodeStroke,
318
345
  lineWidth: 1,
319
346
  },
347
+ haloShape: {
348
+ opacity: 0.25,
349
+ lineWidth: 12,
350
+ pointerEvents: 'none',
351
+ zIndex: -1,
352
+ visible: true,
353
+ stroke: comboStroke,
354
+ droppable: false,
355
+ },
320
356
  },
321
357
  highlight: {
322
358
  keyShape: {
@@ -334,6 +370,9 @@ export const DarkTheme = {
334
370
  fill: comboFill,
335
371
  lineWidth: 1,
336
372
  },
373
+ labelShape: {
374
+ opacity: 0.65,
375
+ },
337
376
  },
338
377
  disable: {
339
378
  keyShape: {
@@ -344,6 +383,31 @@ export const DarkTheme = {
344
383
  fill: disabledFill,
345
384
  opacity: 0.25,
346
385
  },
386
+ labelShape: {
387
+ opacity: 0.25,
388
+ },
389
+ },
390
+ collapsed: {
391
+ keyShape: {
392
+ ...DEFAULT_SHAPE_STYLE,
393
+ fill: comboFill,
394
+ lineWidth: 1,
395
+ stroke: comboStroke,
396
+ // the collapsed size
397
+ r: 16,
398
+ width: 48,
399
+ height: 24,
400
+ padding: [25, 20, 15, 20],
401
+ },
402
+ iconShape: {
403
+ ...DEFAULT_TEXT_STYLE,
404
+ fill: comboStroke,
405
+ fontSize: 12,
406
+ zIndex: 1,
407
+ lod: -1,
408
+ contentType: 'childCount',
409
+ visible: true,
410
+ },
347
411
  },
348
412
  },
349
413
  ],
@@ -108,7 +108,7 @@ export const LightTheme = {
108
108
  },
109
109
  haloShape: {
110
110
  opacity: 0.25,
111
- lineWidth: 20,
111
+ lineWidth: 12,
112
112
  pointerEvents: 'none',
113
113
  zIndex: -1,
114
114
  visible: true,
@@ -121,7 +121,7 @@ export const LightTheme = {
121
121
  },
122
122
  haloShape: {
123
123
  opacity: 0.25,
124
- lineWidth: 20,
124
+ lineWidth: 12,
125
125
  pointerEvents: 'none',
126
126
  zIndex: -1,
127
127
  visible: true,
@@ -328,7 +328,7 @@ export const LightTheme = {
328
328
  },
329
329
  haloShape: {
330
330
  opacity: 0.25,
331
- lineWidth: 20,
331
+ lineWidth: 12,
332
332
  pointerEvents: 'none',
333
333
  zIndex: -1,
334
334
  visible: true,
@@ -343,7 +343,7 @@ export const LightTheme = {
343
343
  },
344
344
  haloShape: {
345
345
  opacity: 0.25,
346
- lineWidth: 20,
346
+ lineWidth: 12,
347
347
  pointerEvents: 'none',
348
348
  zIndex: -1,
349
349
  visible: true,
package/src/types/data.ts CHANGED
@@ -14,6 +14,12 @@ export interface GraphData {
14
14
  combos?: ComboUserModel[];
15
15
  }
16
16
 
17
+ export interface GraphDataChanges {
18
+ dataAdded: GraphData;
19
+ dataUpdated: GraphData;
20
+ dataRemoved: GraphData;
21
+ }
22
+
17
23
  export type TreeData =
18
24
  | ITreeData<NodeUserModelData>
19
25
  | ITreeData<NodeUserModelData>[];
@@ -42,6 +42,7 @@ export interface IG6GraphEvent
42
42
  currentTarget: IGraph;
43
43
  itemType: 'node' | 'edge' | 'combo' | 'canvas';
44
44
  itemId: ID;
45
+ key?: string;
45
46
  /** Original event emitted by G */
46
47
  gEvent: Event;
47
48
  }