@antv/g6 5.0.0-beta.4 → 5.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/index.d.ts +3 -1
  3. package/esm/index.js +1 -1
  4. package/esm/item/edge.d.ts +1 -0
  5. package/esm/item/edge.js +3 -1
  6. package/esm/item/edge.js.map +1 -1
  7. package/esm/item/item.d.ts +3 -2
  8. package/esm/item/item.js +12 -6
  9. package/esm/item/item.js.map +1 -1
  10. package/esm/item/node.d.ts +1 -0
  11. package/esm/item/node.js +3 -1
  12. package/esm/item/node.js.map +1 -1
  13. package/esm/runtime/controller/item.js +252 -148
  14. package/esm/runtime/controller/item.js.map +1 -1
  15. package/esm/runtime/graph.d.ts +16 -14
  16. package/esm/runtime/graph.js +66 -28
  17. package/esm/runtime/graph.js.map +1 -1
  18. package/esm/stdlib/behavior/activate-relations.js +2 -2
  19. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  20. package/esm/stdlib/behavior/click-select.js +1 -1
  21. package/esm/stdlib/behavior/click-select.js.map +1 -1
  22. package/esm/stdlib/behavior/drag-canvas.js +50 -27
  23. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  24. package/esm/stdlib/behavior/drag-combo.js +8 -8
  25. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  26. package/esm/stdlib/behavior/drag-node.js +10 -10
  27. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  28. package/esm/stdlib/behavior/zoom-canvas.js +47 -24
  29. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  30. package/esm/stdlib/index.d.ts +2 -0
  31. package/esm/stdlib/index.js +10 -8
  32. package/esm/stdlib/index.js.map +1 -1
  33. package/esm/stdlib/item/edge/base.d.ts +1 -1
  34. package/esm/stdlib/item/edge/base.js +13 -4
  35. package/esm/stdlib/item/edge/base.js.map +1 -1
  36. package/esm/stdlib/item/node/base.d.ts +1 -1
  37. package/esm/stdlib/item/node/base.js +11 -12
  38. package/esm/stdlib/item/node/base.js.map +1 -1
  39. package/esm/stdlib/item/node/image.d.ts +1 -1
  40. package/esm/stdlib/item/node/image.js +1 -1
  41. package/esm/stdlib/item/node/image.js.map +1 -1
  42. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  43. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  44. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  45. package/esm/stdlib/plugin/history/index.js +14 -14
  46. package/esm/stdlib/plugin/history/index.js.map +1 -1
  47. package/esm/stdlib/plugin/history/item-data-command.js +4 -4
  48. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  49. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  50. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  51. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  52. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  53. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  54. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  55. package/esm/stdlib/plugin/index.d.ts +1 -0
  56. package/esm/stdlib/plugin/index.js +1 -0
  57. package/esm/stdlib/plugin/index.js.map +1 -1
  58. package/esm/stdlib/plugin/snapline/index.d.ts +163 -0
  59. package/esm/stdlib/plugin/snapline/index.js +1052 -0
  60. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  61. package/esm/stdlib/plugin/types.d.ts +1 -0
  62. package/esm/types/graph.d.ts +14 -14
  63. package/esm/types/hook.d.ts +6 -0
  64. package/esm/types/spec.d.ts +13 -0
  65. package/esm/util/bbox.d.ts +16 -1
  66. package/esm/util/bbox.js +29 -0
  67. package/esm/util/bbox.js.map +1 -1
  68. package/esm/util/shape.js +2 -2
  69. package/esm/util/shape.js.map +1 -1
  70. package/lib/index.d.ts +3 -1
  71. package/lib/index.js +1 -1
  72. package/lib/item/edge.d.ts +1 -0
  73. package/lib/item/edge.js +3 -1
  74. package/lib/item/edge.js.map +1 -1
  75. package/lib/item/item.d.ts +3 -2
  76. package/lib/item/item.js +12 -6
  77. package/lib/item/item.js.map +1 -1
  78. package/lib/item/node.d.ts +1 -0
  79. package/lib/item/node.js +3 -1
  80. package/lib/item/node.js.map +1 -1
  81. package/lib/runtime/controller/item.js +251 -147
  82. package/lib/runtime/controller/item.js.map +1 -1
  83. package/lib/runtime/graph.d.ts +16 -14
  84. package/lib/runtime/graph.js +66 -28
  85. package/lib/runtime/graph.js.map +1 -1
  86. package/lib/stdlib/behavior/activate-relations.js +2 -2
  87. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  88. package/lib/stdlib/behavior/click-select.js +1 -1
  89. package/lib/stdlib/behavior/click-select.js.map +1 -1
  90. package/lib/stdlib/behavior/drag-canvas.js +50 -27
  91. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  92. package/lib/stdlib/behavior/drag-combo.js +8 -8
  93. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  94. package/lib/stdlib/behavior/drag-node.js +10 -10
  95. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  96. package/lib/stdlib/behavior/zoom-canvas.js +47 -24
  97. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  98. package/lib/stdlib/index.d.ts +2 -0
  99. package/lib/stdlib/index.js +10 -8
  100. package/lib/stdlib/index.js.map +1 -1
  101. package/lib/stdlib/item/edge/base.d.ts +1 -1
  102. package/lib/stdlib/item/edge/base.js +13 -4
  103. package/lib/stdlib/item/edge/base.js.map +1 -1
  104. package/lib/stdlib/item/node/base.d.ts +1 -1
  105. package/lib/stdlib/item/node/base.js +11 -12
  106. package/lib/stdlib/item/node/base.js.map +1 -1
  107. package/lib/stdlib/item/node/image.d.ts +1 -1
  108. package/lib/stdlib/item/node/image.js +1 -1
  109. package/lib/stdlib/item/node/image.js.map +1 -1
  110. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  111. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  112. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  113. package/lib/stdlib/plugin/history/index.js +14 -14
  114. package/lib/stdlib/plugin/history/index.js.map +1 -1
  115. package/lib/stdlib/plugin/history/item-data-command.js +4 -4
  116. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  117. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  118. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  119. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  120. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  121. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  122. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  123. package/lib/stdlib/plugin/index.d.ts +1 -0
  124. package/lib/stdlib/plugin/index.js +1 -0
  125. package/lib/stdlib/plugin/index.js.map +1 -1
  126. package/lib/stdlib/plugin/snapline/index.d.ts +163 -0
  127. package/lib/stdlib/plugin/snapline/index.js +1056 -0
  128. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  129. package/lib/stdlib/plugin/types.d.ts +1 -0
  130. package/lib/types/graph.d.ts +14 -14
  131. package/lib/types/hook.d.ts +6 -0
  132. package/lib/types/spec.d.ts +13 -0
  133. package/lib/util/bbox.d.ts +16 -1
  134. package/lib/util/bbox.js +32 -1
  135. package/lib/util/bbox.js.map +1 -1
  136. package/lib/util/shape.js +2 -2
  137. package/lib/util/shape.js.map +1 -1
  138. package/package.json +2 -2
  139. package/src/index.ts +1 -1
  140. package/src/item/edge.ts +4 -1
  141. package/src/item/item.ts +11 -6
  142. package/src/item/node.ts +10 -7
  143. package/src/runtime/controller/item.ts +212 -66
  144. package/src/runtime/graph.ts +91 -29
  145. package/src/stdlib/behavior/activate-relations.ts +2 -2
  146. package/src/stdlib/behavior/click-select.ts +1 -1
  147. package/src/stdlib/behavior/drag-canvas.ts +65 -27
  148. package/src/stdlib/behavior/drag-combo.ts +8 -8
  149. package/src/stdlib/behavior/drag-node.ts +10 -10
  150. package/src/stdlib/behavior/zoom-canvas.ts +60 -24
  151. package/src/stdlib/index.ts +10 -7
  152. package/src/stdlib/item/edge/base.ts +13 -5
  153. package/src/stdlib/item/node/base.ts +15 -14
  154. package/src/stdlib/item/node/image.ts +1 -1
  155. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  156. package/src/stdlib/plugin/history/index.ts +14 -14
  157. package/src/stdlib/plugin/history/item-data-command.ts +4 -4
  158. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  159. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  160. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  161. package/src/stdlib/plugin/index.ts +1 -0
  162. package/src/stdlib/plugin/snapline/index.ts +1277 -0
  163. package/src/stdlib/plugin/types.ts +1 -0
  164. package/src/types/graph.ts +22 -17
  165. package/src/types/hook.ts +6 -0
  166. package/src/types/spec.ts +13 -0
  167. package/src/util/bbox.ts +38 -1
  168. package/src/util/shape.ts +2 -2
@@ -4,6 +4,7 @@ import {
4
4
  debounce,
5
5
  each,
6
6
  isArray,
7
+ isNumber,
7
8
  isObject,
8
9
  map,
9
10
  throttle,
@@ -64,6 +65,8 @@ import { getGroupedChanges } from '../../util/event';
64
65
  import { BaseNode } from '../../stdlib/item/node/base';
65
66
  import { BaseEdge } from '../../stdlib/item/edge/base';
66
67
  import { EdgeCollisionChecker, QuadTree } from '../../util/polyline';
68
+ import { isBBoxInBBox, isPointInBBox } from '../../util/bbox';
69
+ import { convertToNumber } from '../../util/type';
67
70
 
68
71
  /**
69
72
  * Manages and stores the node / edge / combo items.
@@ -207,12 +210,16 @@ export class ItemController {
207
210
  * Listener of runtime's render hook.
208
211
  * @param param contains inner data stored in graphCore structure
209
212
  */
210
- private onRender(param: {
213
+ private async onRender(param: {
211
214
  graphCore: GraphCore;
212
215
  theme: ThemeSpecification;
213
216
  transientCanvas: Canvas;
217
+ tileOptimize?: {
218
+ tileFirstRender?: boolean | number;
219
+ tileFirstRenderSize?: number;
220
+ };
214
221
  }) {
215
- const { graphCore, theme = {}, transientCanvas } = param;
222
+ const { graphCore, theme = {}, transientCanvas, tileOptimize = {} } = param;
216
223
  const { graph } = this;
217
224
 
218
225
  // 0. clear groups on canvas, and create new groups
@@ -265,9 +272,23 @@ export class ItemController {
265
272
  edges: graphCore.getAllEdges(),
266
273
  });
267
274
 
268
- this.renderNodes(nodes, theme.node);
275
+ const renderNodesPromise = this.renderNodes(
276
+ nodes,
277
+ theme.node,
278
+ tileOptimize,
279
+ );
280
+ if (renderNodesPromise) {
281
+ await renderNodesPromise;
282
+ }
269
283
  this.renderCombos(combos, theme.combo, graphCore);
270
- this.renderEdges(edges, theme.edge);
284
+ const renderEdgesPromise = this.renderEdges(
285
+ edges,
286
+ theme.edge,
287
+ tileOptimize,
288
+ );
289
+ if (renderEdgesPromise) {
290
+ await renderEdgesPromise;
291
+ }
271
292
  this.sortByComboTree(graphCore);
272
293
  // collapse the combos which has 'collapsed' in initial data
273
294
  if (graphCore.hasTreeStructure('combo')) {
@@ -406,6 +427,10 @@ export class ItemController {
406
427
  });
407
428
  };
408
429
  const debounceUpdateRelates = debounce(updateRelates, 16, false);
430
+ const throttleUpdateRelates = throttle(updateRelates, 16, {
431
+ leading: true,
432
+ trailing: true,
433
+ });
409
434
 
410
435
  Object.values(nodeComboUpdate).forEach((updateObj: any) => {
411
436
  const { isReplace, previous, current, id } = updateObj;
@@ -415,14 +440,12 @@ export class ItemController {
415
440
  if (!item || item.destroyed) return;
416
441
  const type = item.getType();
417
442
  const innerModel = graphCore.getNode(id);
418
- if (
419
- onlyMove &&
420
- type === 'node' &&
421
- isNaN(current.x) &&
422
- isNaN(current.y)
423
- ) {
424
- callback(innerModel, true);
425
- return;
443
+ if (type === 'node' && onlyMove) {
444
+ const { x, y, fx, fy } = current;
445
+ if (isNaN(x) && isNaN(y) && isNaN(fx) && isNaN(fy)) {
446
+ callback(innerModel, true);
447
+ return;
448
+ }
426
449
  }
427
450
 
428
451
  const nodeRelatedIdsToUpdate: Set<ID> = new Set<ID>();
@@ -503,7 +526,7 @@ export class ItemController {
503
526
  nodeRelatedIdsToUpdate.add(edge.id);
504
527
  });
505
528
 
506
- item.onframe = () => updateRelates(nodeRelatedIdsToUpdate);
529
+ item.onframe = () => throttleUpdateRelates(nodeRelatedIdsToUpdate);
507
530
  let statesCache;
508
531
  if (
509
532
  innerModel.data._isCombo &&
@@ -541,7 +564,7 @@ export class ItemController {
541
564
 
542
565
  const parentItem = this.itemMap.get(current.parentId);
543
566
  if (current.parentId && parentItem?.model.data.collapsed) {
544
- this.graph.executeWithoutStacking(() => {
567
+ this.graph.executeWithNoStack(() => {
545
568
  this.graph.hideItem(innerModel.id, false);
546
569
  });
547
570
  }
@@ -669,8 +692,15 @@ export class ItemController {
669
692
  value: boolean;
670
693
  graphCore: GraphCore;
671
694
  animate?: boolean;
695
+ keepKeyShape?: boolean;
672
696
  }) {
673
- const { ids, value, graphCore, animate = true } = param;
697
+ const {
698
+ ids,
699
+ value,
700
+ graphCore,
701
+ animate = true,
702
+ keepKeyShape = false,
703
+ } = param;
674
704
  ids.forEach((id) => {
675
705
  const item = this.itemMap.get(id);
676
706
  if (!item) {
@@ -700,7 +730,7 @@ export class ItemController {
700
730
  });
701
731
  }
702
732
  } else {
703
- item.hide(animate);
733
+ item.hide(animate, keepKeyShape);
704
734
  if (type !== 'edge') {
705
735
  const relatedEdges = graphCore.getRelatedEdges(id);
706
736
  relatedEdges.forEach(({ id: edgeId }) => {
@@ -747,11 +777,42 @@ export class ItemController {
747
777
  }
748
778
 
749
779
  private onViewportChange = debounce(
750
- ({ transform, effectTiming }: ViewportChangeHookParams) => {
780
+ ({
781
+ transform,
782
+ effectTiming,
783
+ tileLodSize = 1000,
784
+ }: ViewportChangeHookParams) => {
751
785
  const { zoom } = transform;
752
786
  if (zoom) {
753
787
  const zoomRatio = this.graph.getZoom();
754
- this.itemMap.forEach((item) => item.updateZoom(zoomRatio));
788
+ const range = this.graph.getCanvasRange();
789
+ const nodeItems = Array.from(this.itemMap, ([key, value]) => value);
790
+ const itemsInViewport = [];
791
+ const itemsOutViewport = [];
792
+ nodeItems.forEach((item) => {
793
+ const { keyShape } = item.shapeMap;
794
+ if (!keyShape) return;
795
+ const renderBounds = keyShape.getRenderBounds();
796
+ if (isBBoxInBBox(renderBounds, range, 0.4))
797
+ itemsInViewport.push(item);
798
+ else itemsOutViewport.push(item);
799
+ });
800
+ const sortedItems = itemsInViewport.concat(itemsOutViewport);
801
+ const sections = Math.ceil(nodeItems.length / tileLodSize);
802
+ const itemSections = Array.from({ length: sections }, (v, i) =>
803
+ sortedItems.slice(i * tileLodSize, i * tileLodSize + tileLodSize),
804
+ );
805
+ let requestId;
806
+ const update = () => {
807
+ if (!itemSections.length) {
808
+ cancelAnimationFrame(requestId);
809
+ return;
810
+ }
811
+ itemSections.shift().forEach((item) => item.updateZoom(zoomRatio));
812
+ requestId = requestAnimationFrame(update);
813
+ };
814
+ requestId = requestAnimationFrame(update);
815
+ // this.itemMap.forEach((item) => item.updateZoom(zoomRatio));
755
816
  this.zoom = zoomRatio;
756
817
  }
757
818
  },
@@ -972,13 +1033,24 @@ export class ItemController {
972
1033
  * Create nodes with inner data to canvas.
973
1034
  * @param models nodes' inner datas
974
1035
  */
975
- private renderNodes(
1036
+ private async renderNodes(
976
1037
  models: NodeModel[],
977
1038
  nodeTheme: NodeThemeSpecifications = {},
978
- ) {
1039
+ tileOptimize?: {
1040
+ tileFirstRender?: boolean | number;
1041
+ tileFirstRenderSize?: number;
1042
+ },
1043
+ ): Promise<any> | undefined {
979
1044
  const { nodeExtensions, nodeGroup, nodeDataTypeSet, graph } = this;
980
1045
  const { dataTypeField = '' } = nodeTheme;
1046
+ const { tileFirstRender, tileFirstRenderSize = 1000 } = tileOptimize || {};
981
1047
  const zoom = graph.getZoom();
1048
+ const delayFirstDraw = isNumber(tileFirstRender)
1049
+ ? models.length > tileFirstRender
1050
+ : tileFirstRender;
1051
+ const itemsInView = [];
1052
+ const itemsOutView = [];
1053
+ const viewRange = this.graph.getCanvasRange();
982
1054
  models.forEach((node) => {
983
1055
  // get the base styles from theme
984
1056
  let dataType;
@@ -990,30 +1062,73 @@ export class ItemController {
990
1062
  nodeTheme,
991
1063
  );
992
1064
 
993
- this.itemMap.set(
994
- node.id,
995
- new Node({
996
- model: node,
997
- renderExtensions: nodeExtensions,
998
- containerGroup: nodeGroup,
999
- mapper: this.nodeMapper,
1000
- stateMapper: this.nodeStateMapper,
1001
- zoom,
1002
- theme: itemTheme as {
1003
- styles: NodeStyleSet;
1004
- lodStrategy: LodStrategyObj;
1005
- },
1006
- device:
1007
- graph.rendererType === 'webgl-3d'
1008
- ? // TODO: G type
1009
- (graph.canvas.context as any).deviceRendererPlugin.getDevice()
1010
- : undefined,
1011
- }),
1012
- );
1065
+ const nodeItem = new Node({
1066
+ delayFirstDraw,
1067
+ model: node,
1068
+ renderExtensions: nodeExtensions,
1069
+ containerGroup: nodeGroup,
1070
+ mapper: this.nodeMapper,
1071
+ stateMapper: this.nodeStateMapper,
1072
+ zoom,
1073
+ theme: itemTheme as {
1074
+ styles: NodeStyleSet;
1075
+ lodStrategy: LodStrategyObj;
1076
+ },
1077
+ device:
1078
+ graph.rendererType === 'webgl-3d'
1079
+ ? // TODO: G type
1080
+ (graph.canvas.context as any).deviceRendererPlugin.getDevice()
1081
+ : undefined,
1082
+ });
1083
+
1084
+ this.itemMap.set(node.id, nodeItem);
1085
+ const { x, y } = nodeItem.model.data;
1086
+ if (
1087
+ delayFirstDraw &&
1088
+ isPointInBBox(
1089
+ { x: convertToNumber(x), y: convertToNumber(y) },
1090
+ viewRange,
1091
+ )
1092
+ ) {
1093
+ itemsInView.push(nodeItem);
1094
+ } else {
1095
+ itemsOutView.push(nodeItem);
1096
+ }
1013
1097
  });
1098
+ if (delayFirstDraw) {
1099
+ let requestId;
1100
+ const items = itemsInView.concat(itemsOutView);
1101
+ const sectionNum = Math.ceil(items.length / tileFirstRenderSize);
1102
+ const sections = Array.from({ length: sectionNum }, (v, i) =>
1103
+ items.slice(
1104
+ i * tileFirstRenderSize,
1105
+ i * tileFirstRenderSize + tileFirstRenderSize,
1106
+ ),
1107
+ );
1108
+ const update = (resolve) => {
1109
+ if (!sections.length) {
1110
+ cancelAnimationFrame(requestId);
1111
+ return resolve();
1112
+ }
1113
+ sections
1114
+ .shift()
1115
+ .forEach((item) =>
1116
+ item.draw(
1117
+ item.displayModel as NodeDisplayModel | ComboDisplayModel,
1118
+ undefined,
1119
+ undefined,
1120
+ !item.displayModel.data.disableAnimate,
1121
+ ),
1122
+ );
1123
+ requestId = requestAnimationFrame(() => update(resolve));
1124
+ };
1125
+ return new Promise((resolve) => {
1126
+ requestId = requestAnimationFrame(() => update(resolve));
1127
+ });
1128
+ }
1014
1129
  }
1015
1130
 
1016
- private renderCombos(
1131
+ private async renderCombos(
1017
1132
  models: ComboModel[],
1018
1133
  comboTheme: ComboThemeSpecifications = {},
1019
1134
  graphCore: GraphCore,
@@ -1084,12 +1199,20 @@ export class ItemController {
1084
1199
  private renderEdges(
1085
1200
  models: EdgeModel[],
1086
1201
  edgeTheme: EdgeThemeSpecifications = {},
1087
- ) {
1202
+ tileOptimize?: {
1203
+ tileFirstRender?: boolean | number;
1204
+ tileFirstRenderSize?: number;
1205
+ },
1206
+ ): Promise<any> | undefined {
1088
1207
  const { edgeExtensions, edgeGroup, itemMap, edgeDataTypeSet, graph } = this;
1089
1208
  const { dataTypeField = '' } = edgeTheme;
1209
+ const { tileFirstRender, tileFirstRenderSize = 1000 } = tileOptimize || {};
1090
1210
  const zoom = graph.getZoom();
1091
1211
  const nodeMap = filterItemMapByType(itemMap, 'node') as Map<ID, Node>;
1092
- models.forEach((edge) => {
1212
+ const delayFirstDraw = isNumber(tileFirstRender)
1213
+ ? models.length > tileFirstRender
1214
+ : tileFirstRender;
1215
+ const items = models.map((edge) => {
1093
1216
  const { source, target, id } = edge;
1094
1217
  const sourceItem = itemMap.get(source) as Node;
1095
1218
  const targetItem = itemMap.get(target) as Node;
@@ -1115,27 +1238,50 @@ export class ItemController {
1115
1238
  edgeTheme,
1116
1239
  );
1117
1240
 
1118
- itemMap.set(
1119
- id,
1120
- new Edge({
1121
- model: edge,
1122
- renderExtensions: edgeExtensions,
1123
- containerGroup: edgeGroup,
1124
- mapper: this.edgeMapper as DisplayMapper,
1125
- stateMapper: this.edgeStateMapper as {
1126
- [stateName: string]: DisplayMapper;
1127
- },
1128
- sourceItem,
1129
- targetItem,
1130
- nodeMap,
1131
- zoom,
1132
- theme: itemTheme as {
1133
- styles: EdgeStyleSet;
1134
- lodStrategy: LodStrategyObj;
1135
- },
1136
- }),
1137
- );
1241
+ const edgeItem = new Edge({
1242
+ delayFirstDraw,
1243
+ model: edge,
1244
+ renderExtensions: edgeExtensions,
1245
+ containerGroup: edgeGroup,
1246
+ mapper: this.edgeMapper as DisplayMapper,
1247
+ stateMapper: this.edgeStateMapper as {
1248
+ [stateName: string]: DisplayMapper;
1249
+ },
1250
+ sourceItem,
1251
+ targetItem,
1252
+ nodeMap,
1253
+ zoom,
1254
+ theme: itemTheme as {
1255
+ styles: EdgeStyleSet;
1256
+ lodStrategy: LodStrategyObj;
1257
+ },
1258
+ });
1259
+
1260
+ itemMap.set(id, edgeItem);
1261
+ return edgeItem;
1138
1262
  });
1263
+
1264
+ if (delayFirstDraw) {
1265
+ let requestId;
1266
+ const sectionNum = Math.ceil(items.length / tileFirstRenderSize);
1267
+ const sections = Array.from({ length: sectionNum }, (v, i) =>
1268
+ items.slice(
1269
+ i * tileFirstRenderSize,
1270
+ i * tileFirstRenderSize + tileFirstRenderSize,
1271
+ ),
1272
+ );
1273
+ const update = (resolve) => {
1274
+ if (!sections.length) {
1275
+ cancelAnimationFrame(requestId);
1276
+ return resolve();
1277
+ }
1278
+ sections.shift().forEach((item) => item.draw(item.displayModel));
1279
+ requestId = requestAnimationFrame(() => update(resolve));
1280
+ };
1281
+ return new Promise((resolve) => {
1282
+ requestId = requestAnimationFrame(() => update(resolve));
1283
+ });
1284
+ }
1139
1285
  }
1140
1286
 
1141
1287
  /**
@@ -1288,7 +1434,7 @@ export class ItemController {
1288
1434
  // find the succeeds in collapsed
1289
1435
  graphComboTreeDfs(this.graph, [comboModel], (child) => {
1290
1436
  if (child.id !== comboModel.id) {
1291
- this.graph.executeWithoutStacking(() => {
1437
+ this.graph.executeWithNoStack(() => {
1292
1438
  this.graph.hideItem(child.id, false);
1293
1439
  });
1294
1440
  }
@@ -1308,7 +1454,7 @@ export class ItemController {
1308
1454
  pairs.push({ source, target });
1309
1455
  });
1310
1456
  // each item in groupedEdges is a virtual edge
1311
- this.graph.executeWithoutStacking(() => {
1457
+ this.graph.executeWithNoStack(() => {
1312
1458
  this.graph.addData('edge', groupVirtualEdges(pairs));
1313
1459
  });
1314
1460
  }
@@ -1391,7 +1537,7 @@ export class ItemController {
1391
1537
  );
1392
1538
 
1393
1539
  // remove related virtual edges
1394
- this.graph.executeWithoutStacking(() => {
1540
+ this.graph.executeWithNoStack(() => {
1395
1541
  this.graph.removeData('edge', uniq(relatedVirtualEdgeIds));
1396
1542
  this.graph.showItem(edgesToShow.concat(nodesToShow));
1397
1543
  // add virtual edges by grouping visible ancestor edges