@antv/g6 5.0.0-beta.3 → 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.
- package/dist/g6.min.js +2 -2
- package/esm/constant/shape.d.ts +2 -0
- package/esm/index.d.ts +4 -1
- package/esm/index.js +1 -1
- package/esm/item/edge.d.ts +1 -0
- package/esm/item/edge.js +3 -1
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +3 -2
- package/esm/item/item.js +12 -6
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +1 -0
- package/esm/item/node.js +11 -4
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/item.js +252 -148
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/graph.d.ts +16 -14
- package/esm/runtime/graph.js +66 -28
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/activate-relations.js +2 -2
- package/esm/stdlib/behavior/activate-relations.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +1 -1
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/drag-canvas.js +50 -27
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.js +8 -8
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.js +10 -10
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.js +47 -24
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/index.d.ts +3 -0
- package/esm/stdlib/index.js +12 -9
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +1 -1
- package/esm/stdlib/item/edge/base.js +13 -4
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +1 -1
- package/esm/stdlib/item/node/base.js +18 -26
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/diamond.js +1 -1
- package/esm/stdlib/item/node/ellipse.js +2 -2
- package/esm/stdlib/item/node/hexagon.js +6 -2
- package/esm/stdlib/item/node/hexagon.js.map +1 -1
- package/esm/stdlib/item/node/image.d.ts +40 -0
- package/esm/stdlib/item/node/image.js +110 -0
- package/esm/stdlib/item/node/image.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +1 -0
- package/esm/stdlib/item/node/index.js +1 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/plugin/history/combo-command.js +2 -2
- package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
- package/esm/stdlib/plugin/history/index.d.ts +10 -10
- package/esm/stdlib/plugin/history/index.js +14 -14
- package/esm/stdlib/plugin/history/index.js.map +1 -1
- package/esm/stdlib/plugin/history/item-data-command.js +4 -4
- package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/index.d.ts +1 -0
- package/esm/stdlib/plugin/index.js +1 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/snapline/index.d.ts +163 -0
- package/esm/stdlib/plugin/snapline/index.js +1052 -0
- package/esm/stdlib/plugin/snapline/index.js.map +1 -0
- package/esm/stdlib/plugin/types.d.ts +1 -0
- package/esm/stdlib/theme/dark.js +42 -2
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +4 -4
- package/esm/types/graph.d.ts +14 -14
- package/esm/types/hook.d.ts +6 -0
- package/esm/types/item.d.ts +6 -0
- package/esm/types/item.js.map +1 -1
- package/esm/types/spec.d.ts +13 -0
- package/esm/util/bbox.d.ts +16 -1
- package/esm/util/bbox.js +29 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/shape.js +2 -2
- package/esm/util/shape.js.map +1 -1
- package/lib/constant/shape.d.ts +2 -0
- package/lib/index.d.ts +4 -1
- package/lib/index.js +1 -1
- package/lib/item/edge.d.ts +1 -0
- package/lib/item/edge.js +3 -1
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +3 -2
- package/lib/item/item.js +12 -6
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +1 -0
- package/lib/item/node.js +11 -4
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/item.js +251 -147
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/graph.d.ts +16 -14
- package/lib/runtime/graph.js +66 -28
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/activate-relations.js +2 -2
- package/lib/stdlib/behavior/activate-relations.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +1 -1
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/drag-canvas.js +50 -27
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.js +8 -8
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.js +10 -10
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.js +47 -24
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/index.d.ts +3 -0
- package/lib/stdlib/index.js +12 -9
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +1 -1
- package/lib/stdlib/item/edge/base.js +13 -4
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +1 -1
- package/lib/stdlib/item/node/base.js +18 -26
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/diamond.js +1 -1
- package/lib/stdlib/item/node/ellipse.js +2 -2
- package/lib/stdlib/item/node/hexagon.js +6 -2
- package/lib/stdlib/item/node/hexagon.js.map +1 -1
- package/lib/stdlib/item/node/image.d.ts +40 -0
- package/lib/stdlib/item/node/image.js +114 -0
- package/lib/stdlib/item/node/image.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +1 -0
- package/lib/stdlib/item/node/index.js +1 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/plugin/history/combo-command.js +2 -2
- package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
- package/lib/stdlib/plugin/history/index.d.ts +10 -10
- package/lib/stdlib/plugin/history/index.js +14 -14
- package/lib/stdlib/plugin/history/index.js.map +1 -1
- package/lib/stdlib/plugin/history/item-data-command.js +4 -4
- package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/index.d.ts +1 -0
- package/lib/stdlib/plugin/index.js +1 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/snapline/index.d.ts +163 -0
- package/lib/stdlib/plugin/snapline/index.js +1056 -0
- package/lib/stdlib/plugin/snapline/index.js.map +1 -0
- package/lib/stdlib/plugin/types.d.ts +1 -0
- package/lib/stdlib/theme/dark.js +42 -2
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +4 -4
- package/lib/types/graph.d.ts +14 -14
- package/lib/types/hook.d.ts +6 -0
- package/lib/types/item.d.ts +6 -0
- package/lib/types/item.js.map +1 -1
- package/lib/types/spec.d.ts +13 -0
- package/lib/util/bbox.d.ts +16 -1
- package/lib/util/bbox.js +32 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/shape.js +2 -2
- package/lib/util/shape.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/item/edge.ts +4 -1
- package/src/item/item.ts +11 -6
- package/src/item/node.ts +18 -10
- package/src/runtime/controller/item.ts +212 -66
- package/src/runtime/graph.ts +91 -29
- package/src/stdlib/behavior/activate-relations.ts +2 -2
- package/src/stdlib/behavior/click-select.ts +1 -1
- package/src/stdlib/behavior/drag-canvas.ts +65 -27
- package/src/stdlib/behavior/drag-combo.ts +8 -8
- package/src/stdlib/behavior/drag-node.ts +10 -10
- package/src/stdlib/behavior/zoom-canvas.ts +60 -24
- package/src/stdlib/index.ts +12 -7
- package/src/stdlib/item/edge/base.ts +13 -5
- package/src/stdlib/item/node/base.ts +24 -29
- package/src/stdlib/item/node/diamond.ts +1 -1
- package/src/stdlib/item/node/ellipse.ts +2 -2
- package/src/stdlib/item/node/hexagon.ts +6 -2
- package/src/stdlib/item/node/image.ts +190 -0
- package/src/stdlib/item/node/index.ts +1 -0
- package/src/stdlib/plugin/history/combo-command.ts +2 -2
- package/src/stdlib/plugin/history/index.ts +14 -14
- package/src/stdlib/plugin/history/item-data-command.ts +4 -4
- package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
- package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/index.ts +1 -0
- package/src/stdlib/plugin/snapline/index.ts +1277 -0
- package/src/stdlib/plugin/types.ts +1 -0
- package/src/stdlib/theme/dark.ts +66 -2
- package/src/stdlib/theme/light.ts +4 -4
- package/src/types/graph.ts +22 -17
- package/src/types/hook.ts +6 -0
- package/src/types/item.ts +10 -0
- package/src/types/spec.ts +13 -0
- package/src/util/bbox.ts +38 -1
- 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(
|
|
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(
|
|
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
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
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 = () =>
|
|
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.
|
|
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 {
|
|
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
|
-
({
|
|
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.
|
|
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
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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
|