@antv/g6 5.0.0-beta.11 → 5.0.0-beta.13

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 (315) 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/constant/shape.d.ts +1 -1
  6. package/esm/index.d.ts +12 -62
  7. package/esm/index.js +4 -5
  8. package/esm/index.js.map +1 -1
  9. package/esm/item/item.js +2 -1
  10. package/esm/item/item.js.map +1 -1
  11. package/esm/runtime/controller/item.js +34 -16
  12. package/esm/runtime/controller/item.js.map +1 -1
  13. package/esm/runtime/controller/layout.js +1 -3
  14. package/esm/runtime/controller/layout.js.map +1 -1
  15. package/esm/runtime/controller/plugin.js +8 -3
  16. package/esm/runtime/controller/plugin.js.map +1 -1
  17. package/esm/runtime/graph.d.ts +1 -1
  18. package/esm/runtime/graph.js +11 -5
  19. package/esm/runtime/graph.js.map +1 -1
  20. package/esm/stdlib/behavior/drag-canvas.d.ts +2 -1
  21. package/esm/stdlib/behavior/drag-canvas.js +12 -5
  22. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  23. package/esm/stdlib/behavior/shortcuts-call.d.ts +2 -2
  24. package/esm/stdlib/behavior/shortcuts-call.js +12 -5
  25. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -1
  26. package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
  27. package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  28. package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -0
  29. package/esm/stdlib/behavior/zoom-canvas.js +8 -2
  30. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  31. package/esm/stdlib/index.d.ts +6 -1
  32. package/esm/stdlib/index.js +8 -3
  33. package/esm/stdlib/index.js.map +1 -1
  34. package/esm/stdlib/item/edge/base.js +5 -1
  35. package/esm/stdlib/item/edge/base.js.map +1 -1
  36. package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  37. package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
  38. package/esm/stdlib/item/edge/cubic.js +1 -1
  39. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  40. package/esm/stdlib/item/edge/loop.js +1 -1
  41. package/esm/stdlib/item/edge/loop.js.map +1 -1
  42. package/esm/stdlib/item/node/base.d.ts +1 -0
  43. package/esm/stdlib/item/node/base.js +5 -2
  44. package/esm/stdlib/item/node/base.js.map +1 -1
  45. package/esm/stdlib/item/node/cube.d.ts +35 -0
  46. package/esm/stdlib/item/node/cube.js +54 -0
  47. package/esm/stdlib/item/node/cube.js.map +1 -0
  48. package/esm/stdlib/item/node/index.d.ts +3 -0
  49. package/esm/stdlib/item/node/index.js +3 -0
  50. package/esm/stdlib/item/node/index.js.map +1 -1
  51. package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  52. package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
  53. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  54. package/esm/stdlib/plugin/grid/index.d.ts +1 -1
  55. package/esm/stdlib/plugin/grid/index.js +3 -4
  56. package/esm/stdlib/plugin/grid/index.js.map +1 -1
  57. package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
  58. package/esm/stdlib/plugin/hull/hullComponent.js +2 -3
  59. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  60. package/esm/stdlib/plugin/hull/util.d.ts +2 -2
  61. package/esm/stdlib/plugin/hull/util.js +6 -2
  62. package/esm/stdlib/plugin/hull/util.js.map +1 -1
  63. package/esm/stdlib/plugin/index.d.ts +1 -0
  64. package/esm/stdlib/plugin/index.js +1 -0
  65. package/esm/stdlib/plugin/index.js.map +1 -1
  66. package/esm/stdlib/plugin/legend/index.d.ts +2 -2
  67. package/esm/stdlib/plugin/legend/index.js +3 -3
  68. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  69. package/esm/stdlib/plugin/menu/index.d.ts +4 -4
  70. package/esm/stdlib/plugin/menu/index.js +3 -3
  71. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  72. package/esm/stdlib/plugin/minimap/index.d.ts +1 -1
  73. package/esm/stdlib/plugin/minimap/index.js +3 -3
  74. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  75. package/esm/stdlib/plugin/timebar/index.js +2 -2
  76. package/esm/stdlib/plugin/timebar/index.js.map +1 -1
  77. package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
  78. package/esm/stdlib/plugin/toolbar/index.js +4 -4
  79. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  80. package/esm/stdlib/plugin/tooltip/index.d.ts +4 -4
  81. package/esm/stdlib/plugin/tooltip/index.js +3 -4
  82. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  83. package/esm/stdlib/plugin/types.d.ts +1 -0
  84. package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
  85. package/esm/stdlib/plugin/watermaker/index.js +243 -0
  86. package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
  87. package/esm/types/index.d.ts +2 -1
  88. package/esm/types/index.js +1 -0
  89. package/esm/types/index.js.map +1 -1
  90. package/esm/types/plugin.d.ts +1 -1
  91. package/esm/util/bbox.js +4 -5
  92. package/esm/util/bbox.js.map +1 -1
  93. package/esm/util/behavior.d.ts +2 -2
  94. package/esm/util/behavior.js +2 -2
  95. package/esm/util/behavior.js.map +1 -1
  96. package/esm/util/data.d.ts +2 -2
  97. package/esm/util/data.js.map +1 -1
  98. package/esm/util/dom.d.ts +15 -0
  99. package/esm/util/dom.js +29 -0
  100. package/esm/util/dom.js.map +1 -0
  101. package/esm/util/extend.d.ts +1 -1
  102. package/esm/util/extend.js +0 -1
  103. package/esm/util/extend.js.map +1 -1
  104. package/esm/util/index.d.ts +7 -52
  105. package/esm/util/index.js +7 -23
  106. package/esm/util/index.js.map +1 -1
  107. package/esm/util/layout.d.ts +1 -1
  108. package/esm/util/layout.js.map +1 -1
  109. package/esm/util/loop.d.ts +1 -1
  110. package/esm/util/math.d.ts +1 -1
  111. package/esm/util/matrix.d.ts +6 -0
  112. package/esm/util/matrix.js +48 -0
  113. package/esm/util/matrix.js.map +1 -0
  114. package/esm/util/path.js +1 -1
  115. package/esm/util/path.js.map +1 -1
  116. package/esm/util/point.d.ts +1 -1
  117. package/esm/util/polyline.d.ts +2 -1
  118. package/esm/util/polyline.js +2 -1
  119. package/esm/util/polyline.js.map +1 -1
  120. package/esm/util/router.d.ts +1 -1
  121. package/esm/util/shape.js +12 -12
  122. package/esm/util/shape.js.map +1 -1
  123. package/esm/util/shape3d.js +15 -11
  124. package/esm/util/shape3d.js.map +1 -1
  125. package/esm/util/text.d.ts +1 -1
  126. package/esm/util/text.js +3 -2
  127. package/esm/util/text.js.map +1 -1
  128. package/lib/api-doc/graph.d.ts +3 -3
  129. package/lib/api-doc/graph.js +27 -7
  130. package/lib/api-doc/graph.js.map +1 -1
  131. package/lib/constant/shape.d.ts +1 -1
  132. package/lib/index.d.ts +12 -62
  133. package/lib/index.js +18 -10
  134. package/lib/index.js.map +1 -1
  135. package/lib/item/item.js +2 -1
  136. package/lib/item/item.js.map +1 -1
  137. package/lib/runtime/controller/item.js +34 -16
  138. package/lib/runtime/controller/item.js.map +1 -1
  139. package/lib/runtime/controller/layout.js +1 -3
  140. package/lib/runtime/controller/layout.js.map +1 -1
  141. package/lib/runtime/controller/plugin.js +8 -3
  142. package/lib/runtime/controller/plugin.js.map +1 -1
  143. package/lib/runtime/graph.d.ts +1 -1
  144. package/lib/runtime/graph.js +12 -5
  145. package/lib/runtime/graph.js.map +1 -1
  146. package/lib/stdlib/behavior/drag-canvas.d.ts +2 -1
  147. package/lib/stdlib/behavior/drag-canvas.js +12 -5
  148. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  149. package/lib/stdlib/behavior/shortcuts-call.d.ts +2 -2
  150. package/lib/stdlib/behavior/shortcuts-call.js +12 -5
  151. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -1
  152. package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
  153. package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  154. package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -0
  155. package/lib/stdlib/behavior/zoom-canvas.js +8 -2
  156. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  157. package/lib/stdlib/index.d.ts +6 -1
  158. package/lib/stdlib/index.js +8 -3
  159. package/lib/stdlib/index.js.map +1 -1
  160. package/lib/stdlib/item/edge/base.js +5 -1
  161. package/lib/stdlib/item/edge/base.js.map +1 -1
  162. package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  163. package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
  164. package/lib/stdlib/item/edge/cubic.js +2 -2
  165. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  166. package/lib/stdlib/item/edge/loop.js +3 -3
  167. package/lib/stdlib/item/edge/loop.js.map +1 -1
  168. package/lib/stdlib/item/node/base.d.ts +1 -0
  169. package/lib/stdlib/item/node/base.js +5 -2
  170. package/lib/stdlib/item/node/base.js.map +1 -1
  171. package/lib/stdlib/item/node/cube.d.ts +35 -0
  172. package/lib/stdlib/item/node/cube.js +58 -0
  173. package/lib/stdlib/item/node/cube.js.map +1 -0
  174. package/lib/stdlib/item/node/index.d.ts +3 -0
  175. package/lib/stdlib/item/node/index.js +3 -0
  176. package/lib/stdlib/item/node/index.js.map +1 -1
  177. package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  178. package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
  179. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  180. package/lib/stdlib/plugin/grid/index.d.ts +1 -1
  181. package/lib/stdlib/plugin/grid/index.js +6 -7
  182. package/lib/stdlib/plugin/grid/index.js.map +1 -1
  183. package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
  184. package/lib/stdlib/plugin/hull/hullComponent.js +2 -3
  185. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  186. package/lib/stdlib/plugin/hull/util.d.ts +2 -2
  187. package/lib/stdlib/plugin/hull/util.js +26 -22
  188. package/lib/stdlib/plugin/hull/util.js.map +1 -1
  189. package/lib/stdlib/plugin/index.d.ts +1 -0
  190. package/lib/stdlib/plugin/index.js +1 -0
  191. package/lib/stdlib/plugin/index.js.map +1 -1
  192. package/lib/stdlib/plugin/legend/index.d.ts +2 -2
  193. package/lib/stdlib/plugin/legend/index.js +3 -3
  194. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  195. package/lib/stdlib/plugin/menu/index.d.ts +4 -4
  196. package/lib/stdlib/plugin/menu/index.js +6 -6
  197. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  198. package/lib/stdlib/plugin/minimap/index.d.ts +1 -1
  199. package/lib/stdlib/plugin/minimap/index.js +6 -6
  200. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  201. package/lib/stdlib/plugin/timebar/index.js +2 -2
  202. package/lib/stdlib/plugin/timebar/index.js.map +1 -1
  203. package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
  204. package/lib/stdlib/plugin/toolbar/index.js +5 -5
  205. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  206. package/lib/stdlib/plugin/tooltip/index.d.ts +4 -4
  207. package/lib/stdlib/plugin/tooltip/index.js +10 -11
  208. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  209. package/lib/stdlib/plugin/types.d.ts +1 -0
  210. package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
  211. package/lib/stdlib/plugin/watermaker/index.js +247 -0
  212. package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
  213. package/lib/types/index.d.ts +2 -1
  214. package/lib/types/index.js +3 -1
  215. package/lib/types/index.js.map +1 -1
  216. package/lib/types/plugin.d.ts +1 -1
  217. package/lib/util/bbox.js +4 -5
  218. package/lib/util/bbox.js.map +1 -1
  219. package/lib/util/behavior.d.ts +2 -2
  220. package/lib/util/behavior.js +2 -2
  221. package/lib/util/behavior.js.map +1 -1
  222. package/lib/util/data.d.ts +2 -2
  223. package/lib/util/data.js.map +1 -1
  224. package/lib/util/dom.d.ts +15 -0
  225. package/lib/util/dom.js +34 -0
  226. package/lib/util/dom.js.map +1 -0
  227. package/lib/util/extend.d.ts +1 -1
  228. package/lib/util/extend.js +0 -1
  229. package/lib/util/extend.js.map +1 -1
  230. package/lib/util/index.d.ts +7 -52
  231. package/lib/util/index.js +23 -23
  232. package/lib/util/index.js.map +1 -1
  233. package/lib/util/layout.d.ts +1 -1
  234. package/lib/util/layout.js.map +1 -1
  235. package/lib/util/loop.d.ts +1 -1
  236. package/lib/util/math.d.ts +1 -1
  237. package/lib/util/matrix.d.ts +6 -0
  238. package/lib/util/matrix.js +52 -0
  239. package/lib/util/matrix.js.map +1 -0
  240. package/lib/util/path.js +2 -2
  241. package/lib/util/path.js.map +1 -1
  242. package/lib/util/point.d.ts +1 -1
  243. package/lib/util/polyline.d.ts +2 -1
  244. package/lib/util/polyline.js +2 -1
  245. package/lib/util/polyline.js.map +1 -1
  246. package/lib/util/router.d.ts +1 -1
  247. package/lib/util/shape.js +12 -12
  248. package/lib/util/shape.js.map +1 -1
  249. package/lib/util/shape3d.js +15 -11
  250. package/lib/util/shape3d.js.map +1 -1
  251. package/lib/util/text.d.ts +1 -1
  252. package/lib/util/text.js +3 -2
  253. package/lib/util/text.js.map +1 -1
  254. package/package.json +34 -41
  255. package/src/api-doc/graph.ts +4 -3
  256. package/src/constant/shape.ts +1 -1
  257. package/src/index.ts +5 -6
  258. package/src/item/item.ts +2 -0
  259. package/src/runtime/controller/item.ts +33 -14
  260. package/src/runtime/controller/layout.ts +1 -5
  261. package/src/runtime/controller/plugin.ts +14 -3
  262. package/src/runtime/graph.ts +12 -6
  263. package/src/stdlib/behavior/drag-canvas.ts +19 -7
  264. package/src/stdlib/behavior/shortcuts-call.ts +13 -4
  265. package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
  266. package/src/stdlib/behavior/zoom-canvas.ts +15 -2
  267. package/src/stdlib/index.ts +10 -1
  268. package/src/stdlib/item/edge/base.ts +5 -2
  269. package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
  270. package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
  271. package/src/stdlib/item/edge/cubic.ts +1 -1
  272. package/src/stdlib/item/edge/loop.ts +1 -1
  273. package/src/stdlib/item/node/base.ts +5 -1
  274. package/src/stdlib/item/node/cube.ts +102 -0
  275. package/src/stdlib/item/node/index.ts +3 -0
  276. package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
  277. package/src/stdlib/plugin/grid/index.ts +6 -6
  278. package/src/stdlib/plugin/hull/convexHull.ts +1 -1
  279. package/src/stdlib/plugin/hull/hullComponent.ts +2 -3
  280. package/src/stdlib/plugin/hull/util.ts +6 -2
  281. package/src/stdlib/plugin/index.ts +1 -0
  282. package/src/stdlib/plugin/legend/index.ts +6 -6
  283. package/src/stdlib/plugin/menu/index.ts +13 -13
  284. package/src/stdlib/plugin/minimap/index.ts +6 -6
  285. package/src/stdlib/plugin/timebar/index.ts +4 -4
  286. package/src/stdlib/plugin/toolbar/index.ts +8 -8
  287. package/src/stdlib/plugin/tooltip/index.ts +10 -10
  288. package/src/stdlib/plugin/types.ts +1 -0
  289. package/src/stdlib/plugin/watermaker/index.ts +302 -0
  290. package/src/types/index.ts +2 -1
  291. package/src/types/plugin.ts +1 -1
  292. package/src/util/bbox.ts +4 -5
  293. package/src/util/behavior.ts +4 -4
  294. package/src/util/data.ts +2 -3
  295. package/src/util/dom.ts +33 -0
  296. package/src/util/extend.ts +2 -3
  297. package/src/util/index.ts +7 -24
  298. package/src/util/layout.ts +3 -2
  299. package/src/util/loop.ts +1 -1
  300. package/src/util/math.ts +1 -1
  301. package/src/util/matrix.ts +66 -0
  302. package/src/util/path.ts +1 -1
  303. package/src/util/point.ts +1 -1
  304. package/src/util/polyline.ts +2 -1
  305. package/src/util/router.ts +1 -1
  306. package/src/util/shape.ts +16 -12
  307. package/src/util/shape3d.ts +19 -10
  308. package/src/util/text.ts +3 -1
  309. package/esm/stdlib/plugin/map/index.d.ts +0 -118
  310. package/esm/stdlib/plugin/map/index.js +0 -683
  311. package/esm/stdlib/plugin/map/index.js.map +0 -1
  312. package/lib/stdlib/plugin/map/index.d.ts +0 -118
  313. package/lib/stdlib/plugin/map/index.js +0 -687
  314. package/lib/stdlib/plugin/map/index.js.map +0 -1
  315. package/src/stdlib/plugin/map/index.ts +0 -808
@@ -225,9 +225,9 @@ export class ItemController {
225
225
 
226
226
  // 0. clear groups on canvas, and create new groups
227
227
  graph.canvas.removeChildren();
228
- const comboGroup = new Group({ id: 'combo-group' });
229
- const edgeGroup = new Group({ id: 'edge-group' });
230
- const nodeGroup = new Group({ id: 'node-group' });
228
+ const comboGroup = new Group({ id: 'combo-group', style: { zIndex: 0 } });
229
+ const edgeGroup = new Group({ id: 'edge-group', style: { zIndex: 1 } });
230
+ const nodeGroup = new Group({ id: 'node-group', style: { zIndex: 2 } });
231
231
  graph.canvas.appendChild(comboGroup);
232
232
  graph.canvas.appendChild(edgeGroup);
233
233
  graph.canvas.appendChild(nodeGroup);
@@ -237,9 +237,18 @@ export class ItemController {
237
237
 
238
238
  // Also create transient groups on transient canvas.
239
239
  transientCanvas.removeChildren();
240
- this.transientComboGroup = new Group({ id: 'combo-group' });
241
- this.transientEdgeGroup = new Group({ id: 'edge-group' });
242
- this.transientNodeGroup = new Group({ id: 'node-group' });
240
+ this.transientComboGroup = new Group({
241
+ id: 'combo-group',
242
+ style: { zIndex: 0 },
243
+ });
244
+ this.transientEdgeGroup = new Group({
245
+ id: 'edge-group',
246
+ style: { zIndex: 1 },
247
+ });
248
+ this.transientNodeGroup = new Group({
249
+ id: 'node-group',
250
+ style: { zIndex: 2 },
251
+ });
243
252
  transientCanvas.appendChild(this.transientComboGroup);
244
253
  transientCanvas.appendChild(this.transientEdgeGroup);
245
254
  transientCanvas.appendChild(this.transientNodeGroup);
@@ -278,14 +287,16 @@ export class ItemController {
278
287
  theme.node,
279
288
  tileOptimize,
280
289
  );
290
+ let nodesInView;
281
291
  if (renderNodesPromise) {
282
- await renderNodesPromise;
292
+ nodesInView = await renderNodesPromise;
283
293
  }
284
294
  this.renderCombos(combos, theme.combo, graphCore);
285
295
  const renderEdgesPromise = this.renderEdges(
286
296
  edges,
287
297
  theme.edge,
288
298
  tileOptimize,
299
+ nodesInView,
289
300
  );
290
301
  if (renderEdgesPromise) {
291
302
  await renderEdgesPromise;
@@ -1115,18 +1126,18 @@ export class ItemController {
1115
1126
  });
1116
1127
  if (delayFirstDraw) {
1117
1128
  let requestId;
1118
- const items = itemsInView.concat(itemsOutView);
1119
- const sectionNum = Math.ceil(items.length / tileFirstRenderSize);
1129
+ const sectionNum = Math.ceil(itemsOutView.length / tileFirstRenderSize);
1120
1130
  const sections = Array.from({ length: sectionNum }, (v, i) =>
1121
- items.slice(
1131
+ itemsOutView.slice(
1122
1132
  i * tileFirstRenderSize,
1123
1133
  i * tileFirstRenderSize + tileFirstRenderSize,
1124
1134
  ),
1125
1135
  );
1136
+ sections.unshift(itemsInView);
1126
1137
  const update = (resolve) => {
1127
1138
  if (!sections.length) {
1128
1139
  cancelAnimationFrame(requestId);
1129
- return resolve();
1140
+ return resolve(itemsInView);
1130
1141
  }
1131
1142
  sections
1132
1143
  .shift()
@@ -1221,6 +1232,7 @@ export class ItemController {
1221
1232
  tileFirstRender?: boolean | number;
1222
1233
  tileFirstRenderSize?: number;
1223
1234
  },
1235
+ nodesInView?: Node[],
1224
1236
  ): Promise<any> | undefined {
1225
1237
  const { edgeExtensions, edgeGroup, itemMap, edgeDataTypeSet, graph } = this;
1226
1238
  const { dataTypeField = '' } = edgeTheme;
@@ -1230,7 +1242,10 @@ export class ItemController {
1230
1242
  const delayFirstDraw = isNumber(tileFirstRender)
1231
1243
  ? models.length > tileFirstRender
1232
1244
  : tileFirstRender;
1233
- const items = models.map((edge) => {
1245
+ const nodesInViewIds = new Set(nodesInView?.map((node) => node.getID()));
1246
+ const edgesInView = [];
1247
+ const edgesOutView = [];
1248
+ models.forEach((edge) => {
1234
1249
  const { source, target, id } = edge;
1235
1250
  const sourceItem = itemMap.get(source) as Node;
1236
1251
  const targetItem = itemMap.get(target) as Node;
@@ -1276,18 +1291,22 @@ export class ItemController {
1276
1291
  });
1277
1292
 
1278
1293
  itemMap.set(id, edgeItem);
1294
+ if (nodesInViewIds.has(source) || nodesInViewIds.has(target))
1295
+ edgesInView.push(edgeItem);
1296
+ else edgesOutView.push(edgeItem);
1279
1297
  return edgeItem;
1280
1298
  });
1281
1299
 
1282
1300
  if (delayFirstDraw) {
1283
1301
  let requestId;
1284
- const sectionNum = Math.ceil(items.length / tileFirstRenderSize);
1302
+ const sectionNum = Math.ceil(edgesOutView.length / tileFirstRenderSize);
1285
1303
  const sections = Array.from({ length: sectionNum }, (v, i) =>
1286
- items.slice(
1304
+ edgesOutView.slice(
1287
1305
  i * tileFirstRenderSize,
1288
1306
  i * tileFirstRenderSize + tileFirstRenderSize,
1289
1307
  ),
1290
1308
  );
1309
+ sections.unshift(edgesInView);
1291
1310
  const update = (resolve) => {
1292
1311
  if (!sections.length) {
1293
1312
  cancelAnimationFrame(requestId);
@@ -97,8 +97,6 @@ export class LayoutController {
97
97
  });
98
98
  }
99
99
 
100
- this.graph.emit('startlayout');
101
-
102
100
  const [width, height] = this.graph.getSize();
103
101
  const center = [width / 2, height / 2];
104
102
 
@@ -227,8 +225,6 @@ export class LayoutController {
227
225
  }
228
226
  }
229
227
 
230
- this.graph.emit('endlayout');
231
-
232
228
  // Update nodes' positions.
233
229
  this.updateNodesPosition(positions, animate);
234
230
  }
@@ -279,7 +275,7 @@ export class LayoutController {
279
275
  animationEffectTiming,
280
276
  );
281
277
  }
282
- this.graph.emit('endlayout');
278
+ this.graph.emit('afterlayout');
283
279
  this.updateNodesPosition(
284
280
  { nodes: nodePositions, edges: [] },
285
281
  animated || animate,
@@ -116,7 +116,7 @@ export class PluginController {
116
116
  if (action === 'add') {
117
117
  pluginCfgs.forEach((config) => {
118
118
  const { key, plugin } = this.initPlugin(config);
119
- this.addListeners(key, plugin);
119
+ this.addListeners(key, plugin, false);
120
120
  });
121
121
  return;
122
122
  }
@@ -158,7 +158,7 @@ export class PluginController {
158
158
  const { plugin } = item;
159
159
  plugin.updateCfgs(config);
160
160
  this.removeListeners(key);
161
- this.addListeners(key, plugin);
161
+ this.addListeners(key, plugin, false);
162
162
  });
163
163
  return;
164
164
  }
@@ -184,7 +184,11 @@ export class PluginController {
184
184
  return plugin;
185
185
  }
186
186
 
187
- private addListeners = (key: string, plugin: PluginBase) => {
187
+ private addListeners = (
188
+ key: string,
189
+ plugin: PluginBase,
190
+ initWithGraph: boolean = true,
191
+ ) => {
188
192
  const events = plugin.getEvents();
189
193
  this.listenersMap[key] = {};
190
194
  Object.keys(events).forEach((eventName) => {
@@ -196,6 +200,13 @@ export class PluginController {
196
200
  );
197
201
  this.graph.on(eventName, listener);
198
202
  this.listenersMap[key][eventName] = listener;
203
+ // The plugin is not initiated with graph, some events are not listened, trigger them manually
204
+ if (
205
+ !initWithGraph &&
206
+ ['afterrender', 'afterlayout'].includes(eventName)
207
+ ) {
208
+ listener({} as any);
209
+ }
199
210
  });
200
211
  };
201
212
 
@@ -21,7 +21,6 @@ import {
21
21
  isString,
22
22
  map,
23
23
  } from '@antv/util';
24
- import { createDom } from '@antv/dom-util';
25
24
  import { History } from '../stdlib/plugin/history';
26
25
  import { Command } from '../stdlib/plugin/history/command';
27
26
  import type {
@@ -57,6 +56,7 @@ import { FitViewRules, GraphTransformOptions } from '../types/view';
57
56
  import { changeRenderer, createCanvas } from '../util/canvas';
58
57
  import { formatPadding } from '../util/shape';
59
58
  import { getLayoutBounds } from '../util/layout';
59
+ import { createDOM } from '../util/dom';
60
60
  import { Plugin as PluginBase } from '../types/plugin';
61
61
  import { ComboMapper, EdgeMapper, NodeMapper } from '../types/spec';
62
62
  import {
@@ -71,7 +71,7 @@ import {
71
71
  import { PluginController } from './controller/plugin';
72
72
  import Hook from './hooks';
73
73
 
74
- export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
74
+ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
75
75
  extends EventEmitter
76
76
  implements IGraph<B, T>
77
77
  {
@@ -180,7 +180,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
180
180
  this.canvas = canvas;
181
181
  this.backgroundCanvas = backgroundCanvas;
182
182
  this.transientCanvas = transientCanvas;
183
- this.container = container as HTMLDivElement;
183
+ this.container = container as HTMLElement;
184
184
  } else {
185
185
  const containerDOM = isString(container)
186
186
  ? document.getElementById(container as string)
@@ -236,7 +236,8 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
236
236
  .getContextService()
237
237
  .getDomElement() as unknown as HTMLElement;
238
238
  if ($domElement && $domElement.style) {
239
- $domElement.style.position = 'fixed';
239
+ // Make all these 3 canvas doms overlap each other. The container already has `position: relative` style.
240
+ $domElement.style.position = 'absolute';
240
241
  $domElement.style.outline = 'none';
241
242
  $domElement.tabIndex = 1; // Enable keyboard events
242
243
  // Transient canvas should let interactive events go through.
@@ -881,9 +882,14 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
881
882
  );
882
883
  return;
883
884
  }
885
+ const oldSize = [this.specification.width, this.specification.height];
886
+ this.emit('beforesetsize', { oldSize, size: size });
884
887
  this.specification.width = size[0];
885
888
  this.specification.height = size[1];
886
889
  this.canvas.resize(size[0], size[1]);
890
+ this.transientCanvas.resize(size[0], size[1]);
891
+ this.backgroundCanvas.resize(size[0], size[1]);
892
+ this.emit('aftersetsize', { oldSize, size: size });
887
893
  }
888
894
 
889
895
  public getCanvasRange(): Bounds {
@@ -2188,7 +2194,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2188
2194
  const width = this.getSize()[0];
2189
2195
  const height = this.getSize()[1];
2190
2196
 
2191
- const vContainerDOM: HTMLDivElement = createDom(
2197
+ const vContainerDOM: HTMLElement = createDOM(
2192
2198
  '<div id="virtual-image"></div>',
2193
2199
  );
2194
2200
  const vCanvas = createCanvas(
@@ -2296,7 +2302,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2296
2302
  typeof window !== 'undefined' ? window.devicePixelRatio : 1;
2297
2303
  const vWidth = halfX * 2;
2298
2304
  const vHeight = halfY * 2;
2299
- const vContainerDOM: HTMLDivElement = createDom(
2305
+ const vContainerDOM: HTMLElement = createDOM(
2300
2306
  '<div id="virtual-image"></div>',
2301
2307
  );
2302
2308
  const vCanvas = createCanvas(
@@ -1,7 +1,7 @@
1
1
  import { isNumber } from '@antv/util';
2
- import { ID, IG6GraphEvent } from '../../types';
3
2
  import { Behavior } from '../../types/behavior';
4
3
  import { Point } from '../../types/common';
4
+ import { ID, IG6GraphEvent } from '../../types';
5
5
 
6
6
  const VALID_TRIGGERS = ['drag', 'directionKeys'];
7
7
  export interface DragCanvasOptions {
@@ -75,6 +75,7 @@ export class DragCanvas extends Behavior {
75
75
  private hiddenEdgeIds: ID[];
76
76
  private hiddenNodeIds: ID[];
77
77
  private tileRequestId?: number;
78
+ private lastDragTriggerTime?: number;
78
79
 
79
80
  constructor(options: Partial<DragCanvasOptions>) {
80
81
  const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
@@ -236,6 +237,22 @@ export class DragCanvas extends Behavior {
236
237
  const { eventName, direction, secondaryKeyToDisable } = this.options;
237
238
  // disabled key is pressing
238
239
  if (secondaryKeyToDisable && this.disableKeydown) return;
240
+
241
+ // begin dragging
242
+ if (!this.dragging) {
243
+ this.hideShapes();
244
+ this.dragging = true;
245
+ }
246
+
247
+ const now = Date.now();
248
+ const MOUSE_ZOOM_DURATION = 250;
249
+ if (
250
+ this.lastDragTriggerTime &&
251
+ now - this.lastDragTriggerTime < MOUSE_ZOOM_DURATION / 5
252
+ ) {
253
+ return;
254
+ }
255
+
239
256
  const { graph } = this;
240
257
  const { client } = event;
241
258
  const diffX = client.x - this.pointerDownAt.x;
@@ -244,12 +261,6 @@ export class DragCanvas extends Behavior {
244
261
  if (direction === 'y' && !diffY) return;
245
262
  if (direction === 'both' && !diffX && !diffY) return;
246
263
 
247
- // begin dragging
248
- if (!this.dragging) {
249
- this.hideShapes();
250
- this.dragging = true;
251
- }
252
-
253
264
  const { dx, dy } = this.formatDisplacement(diffX, diffY);
254
265
  graph.translate({ dx, dy });
255
266
 
@@ -259,6 +270,7 @@ export class DragCanvas extends Behavior {
259
270
  if (eventName) {
260
271
  this.graph.emit(eventName, { translate: { dx, dy } });
261
272
  }
273
+ this.lastDragTriggerTime = now;
262
274
  }
263
275
 
264
276
  public onPointerUp() {
@@ -78,8 +78,6 @@ export class ShortcutsCall extends Behavior {
78
78
  (codeLowerCase === 'ctrl' && triggerLowerCase === 'control')
79
79
  ) {
80
80
  this.triggerKeydown = true;
81
- } else {
82
- this.triggerKeydown = false;
83
81
  }
84
82
  }
85
83
 
@@ -114,7 +112,18 @@ export class ShortcutsCall extends Behavior {
114
112
  }
115
113
  }
116
114
 
117
- public onKeyUp() {
118
- this.triggerKeydown = false;
115
+ public onKeyUp(e) {
116
+ const code = e.key;
117
+ if (!code) return;
118
+ const { trigger } = this.options;
119
+ const triggerLowerCase = trigger.toLowerCase();
120
+ const codeLowerCase = code.toLowerCase();
121
+ if (
122
+ codeLowerCase === triggerLowerCase ||
123
+ (codeLowerCase === 'control' && triggerLowerCase === 'ctrl') ||
124
+ (codeLowerCase === 'ctrl' && triggerLowerCase === 'control')
125
+ ) {
126
+ this.triggerKeydown = false;
127
+ }
119
128
  }
120
129
  }
@@ -123,7 +123,10 @@ export class ZoomCanvas3D extends Behavior {
123
123
  ((100 * sign * sensitivity) / currentDistance) *
124
124
  Math.sqrt(currentDistance);
125
125
  const toDistance = currentDistance + dolly;
126
- const cameraFrontOfFocalPoint = camera.getDistanceVector()[2] < 0;
126
+ const azimuth = camera.getAzimuth();
127
+ const isFlipped = azimuth < 90 && azimuth > -90 ? 1 : -1;
128
+ const distancePositive = camera.getDistanceVector()[2] < 0 ? 1 : -1;
129
+ const cameraFrontOfFocalPoint = isFlipped * distancePositive > 0;
127
130
 
128
131
  // zoom out constraint
129
132
  if (
@@ -59,7 +59,7 @@ export interface ZoomCanvasOptions {
59
59
  const DEFAULT_OPTIONS: Required<ZoomCanvasOptions> = {
60
60
  enableOptimize: undefined,
61
61
  triggerOnItems: true,
62
- sensitivity: 2,
62
+ sensitivity: 10,
63
63
  trigger: 'wheel',
64
64
  secondaryKey: '',
65
65
  speedUpKey: 'shift',
@@ -77,6 +77,7 @@ export class ZoomCanvas extends Behavior {
77
77
  private hiddenNodeIds: ID[];
78
78
  private zoomTimer: ReturnType<typeof setTimeout>;
79
79
  private tileRequestId?: number;
80
+ private lastWheelTriggerTime?: number;
80
81
 
81
82
  constructor(options: Partial<ZoomCanvasOptions>) {
82
83
  const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
@@ -232,15 +233,27 @@ export class ZoomCanvas extends Behavior {
232
233
  this.hideShapes();
233
234
  this.zooming = true;
234
235
  }
236
+
237
+ const now = Date.now();
238
+ const MOUSE_ZOOM_DURATION = 250;
239
+ if (
240
+ this.lastWheelTriggerTime &&
241
+ now - this.lastWheelTriggerTime < MOUSE_ZOOM_DURATION / 5
242
+ ) {
243
+ return;
244
+ }
245
+
235
246
  let zoomRatio = 1;
236
247
  if (deltaY < 0) zoomRatio = (100 + sensitivity) / 100;
237
248
  if (deltaY > 0) zoomRatio = 100 / (100 + sensitivity);
238
249
  const zoomTo = zoomRatio * graph.getZoom();
239
250
  if (minZoom && zoomTo < minZoom) return;
240
251
  if (maxZoom && zoomTo > maxZoom) return;
241
- // TODO: the zoom center is wrong?
252
+
242
253
  graph.zoom(zoomRatio, { x: client.x, y: client.y });
243
254
 
255
+ this.lastWheelTriggerTime = now;
256
+
244
257
  clearTimeout(this.zoomTimer);
245
258
  this.zoomTimer = setTimeout(() => {
246
259
  this.endZoom();
@@ -32,6 +32,9 @@ const {
32
32
  EllipseNode,
33
33
  ModelRectNode,
34
34
  ImageNode,
35
+ CubeNode,
36
+ BaseNode,
37
+ BaseNode3D,
35
38
  } = Nodes;
36
39
 
37
40
  const {
@@ -76,6 +79,7 @@ const {
76
79
  Toolbar,
77
80
  Timebar,
78
81
  Snapline,
82
+ EdgeFilterLens,
79
83
  } = Plugins;
80
84
 
81
85
  const {
@@ -96,6 +100,7 @@ const {
96
100
  import lassoSelector from './selector/lasso';
97
101
  import rectSelector from './selector/rect';
98
102
  import Hull from './plugin/hull';
103
+ import { WaterMarker } from './plugin/watermaker';
99
104
 
100
105
  const stdLib = {
101
106
  transforms: {
@@ -123,7 +128,6 @@ const stdLib = {
123
128
  'zoom-canvas': ZoomCanvas,
124
129
  'drag-node': DragNode,
125
130
  'drag-combo': DragCombo,
126
- 'create-edge': CreateEdge,
127
131
  'collapse-expand-combo': CollapseExpandCombo,
128
132
  'collapse-expand-tree': CollapseExpandTree,
129
133
  'click-select': ClickSelect,
@@ -246,6 +250,9 @@ const Extensions = {
246
250
  TriangleNode,
247
251
  EllipseNode,
248
252
  ModelRectNode,
253
+ CubeNode,
254
+ BaseNode,
255
+ BaseNode3D,
249
256
  // edges
250
257
  LineEdge,
251
258
  CubicEdge,
@@ -289,6 +296,8 @@ const Extensions = {
289
296
  Timebar,
290
297
  Hull,
291
298
  Snapline,
299
+ EdgeFilterLens,
300
+ WaterMarker,
292
301
  };
293
302
 
294
303
  export default registery;
@@ -289,9 +289,10 @@ export abstract class BaseEdge {
289
289
  const pointOffset = (keyShape as Line | Polyline).getPoint(
290
290
  positionPreset.pointRatio[1],
291
291
  );
292
- const angle = Math.atan(
292
+ let angle = Math.atan(
293
293
  (point.y - pointOffset.y) / (point.x - pointOffset.x),
294
- ); // TODO: NaN
294
+ );
295
+ if (isNaN(angle)) angle = 0;
295
296
 
296
297
  // revert
297
298
  isRevert = pointOffset.x < point.x;
@@ -331,6 +332,7 @@ export abstract class BaseEdge {
331
332
  maxWidth,
332
333
  this.zoomCache.zoom,
333
334
  );
335
+ this.zoomCache.wordWrapWidth = wordWrapWidth;
334
336
  const style = {
335
337
  ...this.defaultStyles.labelShape,
336
338
  textAlign: positionPreset.textAlign,
@@ -339,6 +341,7 @@ export abstract class BaseEdge {
339
341
  ...positionStyle,
340
342
  ...otherStyle,
341
343
  };
344
+ this.boundsCache.labelShapeTransform = style.transform;
342
345
  return this.upsertShape('text', 'labelShape', style, shapeMap, model);
343
346
  }
344
347
 
@@ -1,4 +1,3 @@
1
- import { vec2 } from '@antv/matrix-util';
2
1
  import { Point } from '../../../types/common';
3
2
 
4
3
  import { CubicEdge } from './cubic';
@@ -1,4 +1,3 @@
1
- import { vec2 } from '@antv/matrix-util';
2
1
  import { Point } from '../../../types/common';
3
2
  import { CubicEdge } from './cubic';
4
3
 
@@ -1,5 +1,5 @@
1
1
  import { DisplayObject } from '@antv/g';
2
- import { vec2 } from '@antv/matrix-util';
2
+ import { vec2 } from 'gl-matrix';
3
3
  import { Point } from '../../../types/common';
4
4
  import { EdgeModelData, EdgeShapeMap } from '../../../types/edge';
5
5
  import { State } from '../../../types/item';
@@ -1,4 +1,4 @@
1
- import { vec2 } from '@antv/matrix-util';
1
+ import { vec2 } from 'gl-matrix';
2
2
  import { getBBoxHeight, getBBoxWidth } from '../../../util/bbox';
3
3
  import { distanceVec } from '../../../util/point';
4
4
  import {
@@ -41,6 +41,7 @@ export abstract class BaseNode {
41
41
  themeStyles: NodeShapeStyles | ComboShapeStyles;
42
42
  mergedStyles: NodeShapeStyles | ComboShapeStyles;
43
43
  lodStrategy?: LodStrategyObj;
44
+ enableBalanceShape?: boolean;
44
45
  boundsCache: {
45
46
  keyShapeLocal?: AABB;
46
47
  labelShapeGeometry?: AABB;
@@ -84,9 +85,10 @@ export abstract class BaseNode {
84
85
  };
85
86
 
86
87
  constructor(props) {
87
- const { themeStyles, lodStrategy, zoom } = props;
88
+ const { themeStyles, lodStrategy, enableBalanceShape, zoom } = props;
88
89
  if (themeStyles) this.themeStyles = themeStyles;
89
90
  this.lodStrategy = lodStrategy;
91
+ this.enableBalanceShape = enableBalanceShape;
90
92
  this.boundsCache = {};
91
93
  this.zoomCache.zoom = zoom;
92
94
  this.zoomCache.balanceRatio = 1 / zoom;
@@ -306,6 +308,7 @@ export abstract class BaseNode {
306
308
  keyShapeBox as AABB,
307
309
  maxWidth,
308
310
  this.zoomCache.zoom,
311
+ this.enableBalanceShape,
309
312
  );
310
313
 
311
314
  const positionPreset = {
@@ -873,6 +876,7 @@ export abstract class BaseNode {
873
876
  shapeMap: NodeShapeMap | ComboShapeMap,
874
877
  zoom: number,
875
878
  ) {
879
+ if (!this.enableBalanceShape) return;
876
880
  // balance the size for label, badges
877
881
  const { keyShape, labelShape, labelBackgroundShape } = shapeMap;
878
882
  const balanceRatio = 1 / zoom || 1;
@@ -0,0 +1,102 @@
1
+ import { DisplayObject } from '@antv/g';
2
+ import { NodeDisplayModel } from '../../../types';
3
+ import { State } from '../../../types/item';
4
+ import {
5
+ NodeModelData,
6
+ NodeShapeMap,
7
+ NodeShapeStyles,
8
+ } from '../../../types/node';
9
+ import { BaseNode3D } from './base3d';
10
+
11
+ export class CubeNode extends BaseNode3D {
12
+ override defaultStyles = {
13
+ keyShape: {
14
+ latitudeBands: 32,
15
+ longitudeBands: 32,
16
+ width: 10,
17
+ height: 10,
18
+ depth: 10,
19
+ x: 0,
20
+ y: 0,
21
+ z: 0,
22
+ },
23
+ };
24
+ mergedStyles: NodeShapeStyles;
25
+ constructor(props) {
26
+ super(props);
27
+ }
28
+ public draw(
29
+ model: NodeDisplayModel,
30
+ shapeMap: NodeShapeMap,
31
+ diffData?: { previous: NodeModelData; current: NodeModelData },
32
+ diffState?: { previous: State[]; current: State[] },
33
+ ): NodeShapeMap {
34
+ const { data = {} } = model;
35
+
36
+ let shapes: NodeShapeMap = { keyShape: undefined };
37
+
38
+ // keyShape
39
+ shapes.keyShape = this.drawKeyShape(model, shapeMap, diffData);
40
+
41
+ // haloShape
42
+ if (data.haloShape && this.drawHaloShape) {
43
+ shapes.haloShape = this.drawHaloShape(model, shapeMap, diffData);
44
+ }
45
+
46
+ // labelShape
47
+ if (data.labelShape) {
48
+ shapes.labelShape = this.drawLabelShape(model, shapeMap, diffData);
49
+ }
50
+
51
+ // labelBackgroundShape
52
+ if (data.labelBackgroundShape) {
53
+ shapes.labelBackgroundShape = this.drawLabelBackgroundShape(
54
+ model,
55
+ shapeMap,
56
+ diffData,
57
+ );
58
+ }
59
+
60
+ // iconShape
61
+ if (data.iconShape) {
62
+ shapes.iconShape = this.drawIconShape(model, shapeMap, diffData);
63
+ }
64
+
65
+ // badgeShape
66
+ if (data.badgeShapes) {
67
+ const badgeShapes = this.drawBadgeShapes(
68
+ model,
69
+ shapeMap,
70
+ diffData,
71
+ diffState,
72
+ );
73
+ shapes = {
74
+ ...shapes,
75
+ ...badgeShapes,
76
+ };
77
+ }
78
+
79
+ // otherShapes
80
+ if (data.otherShapes && this.drawOtherShapes) {
81
+ shapes = {
82
+ ...shapes,
83
+ ...this.drawOtherShapes(model, shapeMap, diffData),
84
+ };
85
+ }
86
+ return shapes;
87
+ }
88
+
89
+ public drawKeyShape(
90
+ model: NodeDisplayModel,
91
+ shapeMap: NodeShapeMap,
92
+ diffData?: { previous: NodeModelData; current: NodeModelData },
93
+ diffState?: { previous: State[]; current: State[] },
94
+ ): DisplayObject {
95
+ return this.upsertShape(
96
+ 'cube',
97
+ 'keyShape',
98
+ this.mergedStyles.keyShape,
99
+ shapeMap,
100
+ );
101
+ }
102
+ }
@@ -9,3 +9,6 @@ export * from './donut';
9
9
  export * from './diamond';
10
10
  export * from './modelRect';
11
11
  export * from './image';
12
+ export * from './cube';
13
+ export * from './base';
14
+ export * from './base3d';