@antv/g6 5.0.0-beta.26 → 5.0.0-beta.27
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 +1 -1
- package/esm/index.d.ts +3 -1
- package/esm/index.js +1 -1
- package/esm/item/combo.d.ts +6 -4
- package/esm/item/combo.js +10 -3
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +12 -4
- package/esm/item/edge.js +100 -17
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +18 -8
- package/esm/item/item.js +103 -59
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +10 -4
- package/esm/item/node.js +92 -8
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +5 -1
- package/esm/runtime/controller/data.js +38 -1
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/index.d.ts +1 -1
- package/esm/runtime/controller/index.js +1 -1
- package/esm/runtime/controller/index.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +22 -11
- package/esm/runtime/controller/item.js +241 -96
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.d.ts +3 -0
- package/esm/runtime/controller/layout.js +178 -98
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.d.ts +3 -0
- package/esm/runtime/controller/plugin.js +66 -24
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/controller/viewport.js +9 -2
- package/esm/runtime/controller/viewport.js.map +1 -1
- package/esm/runtime/graph.d.ts +57 -26
- package/esm/runtime/graph.js +263 -139
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +9 -3
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/drag-canvas.js +6 -3
- 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.d.ts +4 -0
- package/esm/stdlib/behavior/drag-node.js +121 -27
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.js +3 -3
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.js +3 -3
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/mapNodeSize.js +2 -2
- package/esm/stdlib/data/mapNodeSize.js.map +1 -1
- package/esm/stdlib/data/validateData.js +2 -2
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +2 -0
- package/esm/stdlib/index.js +3 -1
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +2 -11
- package/esm/stdlib/item/edge/base.js +12 -105
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +2 -20
- package/esm/stdlib/item/node/base.js +10 -150
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/esm/stdlib/plugin/fisheye/index.js +3 -2
- package/esm/stdlib/plugin/fisheye/index.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/hull/index.d.ts +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/lodController/index.d.ts +73 -0
- package/esm/stdlib/plugin/lodController/index.js +556 -0
- package/esm/stdlib/plugin/lodController/index.js.map +1 -0
- package/esm/stdlib/plugin/minimap/index.js +12 -14
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/esm/stdlib/plugin/toolbar/index.js +27 -29
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/theme/dark.js +32 -35
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +27 -30
- package/esm/stdlib/theme/light.js.map +1 -1
- package/esm/stdlib/themeSolver/spec.js +2 -2
- package/esm/stdlib/themeSolver/spec.js.map +1 -1
- package/esm/types/animate.d.ts +1 -1
- package/esm/types/combo.d.ts +2 -2
- package/esm/types/edge.d.ts +2 -2
- package/esm/types/graph.d.ts +62 -43
- package/esm/types/hook.d.ts +5 -0
- package/esm/types/item.d.ts +9 -15
- package/esm/types/layout.d.ts +7 -2
- package/esm/types/layout.js.map +1 -1
- package/esm/types/node.d.ts +3 -2
- package/esm/types/plugin.d.ts +1 -0
- package/esm/types/plugin.js +1 -0
- package/esm/types/plugin.js.map +1 -1
- package/esm/types/spec.d.ts +1 -0
- package/esm/types/theme.d.ts +7 -7
- package/esm/util/animate.d.ts +7 -2
- package/esm/util/animate.js +37 -23
- package/esm/util/animate.js.map +1 -1
- package/esm/util/bbox.d.ts +7 -1
- package/esm/util/bbox.js +16 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/data.d.ts +7 -1
- package/esm/util/data.js +17 -5
- package/esm/util/data.js.map +1 -1
- package/esm/util/dom.js +5 -5
- package/esm/util/dom.js.map +1 -1
- package/esm/util/item.d.ts +1 -1
- package/esm/util/item.js +8 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/mapper.js +1 -1
- package/esm/util/mapper.js.map +1 -1
- package/esm/util/path.d.ts +6 -1
- package/esm/util/path.js +72 -1
- package/esm/util/path.js.map +1 -1
- package/esm/util/polyline.d.ts +10 -0
- package/esm/util/polyline.js +22 -17
- package/esm/util/polyline.js.map +1 -1
- package/esm/util/router.d.ts +1 -1
- package/esm/util/router.js +19 -18
- package/esm/util/router.js.map +1 -1
- package/esm/util/shape.d.ts +1 -1
- package/esm/util/shape.js +28 -13
- package/esm/util/shape.js.map +1 -1
- package/esm/util/zoom.d.ts +5 -8
- package/esm/util/zoom.js +15 -20
- package/esm/util/zoom.js.map +1 -1
- package/lib/constant/shape.d.ts +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -1
- package/lib/item/combo.d.ts +6 -4
- package/lib/item/combo.js +10 -3
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +12 -4
- package/lib/item/edge.js +99 -16
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +18 -8
- package/lib/item/item.js +101 -57
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +10 -4
- package/lib/item/node.js +92 -8
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +5 -1
- package/lib/runtime/controller/data.js +38 -1
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/index.d.ts +1 -1
- package/lib/runtime/controller/index.js +1 -1
- package/lib/runtime/controller/index.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +22 -11
- package/lib/runtime/controller/item.js +238 -93
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.d.ts +3 -0
- package/lib/runtime/controller/layout.js +178 -98
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.d.ts +3 -0
- package/lib/runtime/controller/plugin.js +66 -24
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/controller/viewport.js +9 -2
- package/lib/runtime/controller/viewport.js.map +1 -1
- package/lib/runtime/graph.d.ts +57 -26
- package/lib/runtime/graph.js +263 -139
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +9 -3
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/drag-canvas.js +6 -3
- 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.d.ts +4 -0
- package/lib/stdlib/behavior/drag-node.js +121 -27
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.js +3 -3
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.js +3 -3
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/mapNodeSize.js +2 -2
- package/lib/stdlib/data/mapNodeSize.js.map +1 -1
- package/lib/stdlib/data/validateData.js +2 -2
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +2 -0
- package/lib/stdlib/index.js +3 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +2 -11
- package/lib/stdlib/item/edge/base.js +12 -105
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +2 -20
- package/lib/stdlib/item/node/base.js +10 -150
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/lib/stdlib/plugin/fisheye/index.js +2 -1
- package/lib/stdlib/plugin/fisheye/index.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/hull/index.d.ts +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/lodController/index.d.ts +73 -0
- package/lib/stdlib/plugin/lodController/index.js +560 -0
- package/lib/stdlib/plugin/lodController/index.js.map +1 -0
- package/lib/stdlib/plugin/minimap/index.js +12 -14
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/lib/stdlib/plugin/toolbar/index.js +27 -29
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/theme/dark.js +32 -35
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +27 -30
- package/lib/stdlib/theme/light.js.map +1 -1
- package/lib/stdlib/themeSolver/spec.js +2 -2
- package/lib/stdlib/themeSolver/spec.js.map +1 -1
- package/lib/types/animate.d.ts +1 -1
- package/lib/types/combo.d.ts +2 -2
- package/lib/types/edge.d.ts +2 -2
- package/lib/types/graph.d.ts +62 -43
- package/lib/types/hook.d.ts +5 -0
- package/lib/types/item.d.ts +9 -15
- package/lib/types/layout.d.ts +7 -2
- package/lib/types/layout.js.map +1 -1
- package/lib/types/node.d.ts +3 -2
- package/lib/types/plugin.d.ts +1 -0
- package/lib/types/plugin.js +1 -0
- package/lib/types/plugin.js.map +1 -1
- package/lib/types/spec.d.ts +1 -0
- package/lib/types/theme.d.ts +7 -7
- package/lib/util/animate.d.ts +7 -2
- package/lib/util/animate.js +37 -23
- package/lib/util/animate.js.map +1 -1
- package/lib/util/bbox.d.ts +7 -1
- package/lib/util/bbox.js +18 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/data.d.ts +7 -1
- package/lib/util/data.js +19 -6
- package/lib/util/data.js.map +1 -1
- package/lib/util/dom.js +5 -5
- package/lib/util/dom.js.map +1 -1
- package/lib/util/item.d.ts +1 -1
- package/lib/util/item.js +8 -8
- package/lib/util/item.js.map +1 -1
- package/lib/util/mapper.js +1 -1
- package/lib/util/mapper.js.map +1 -1
- package/lib/util/path.d.ts +6 -1
- package/lib/util/path.js +72 -1
- package/lib/util/path.js.map +1 -1
- package/lib/util/polyline.d.ts +10 -0
- package/lib/util/polyline.js +25 -18
- package/lib/util/polyline.js.map +1 -1
- package/lib/util/router.d.ts +1 -1
- package/lib/util/router.js +19 -18
- package/lib/util/router.js.map +1 -1
- package/lib/util/shape.d.ts +1 -1
- package/lib/util/shape.js +27 -12
- package/lib/util/shape.js.map +1 -1
- package/lib/util/zoom.d.ts +5 -8
- package/lib/util/zoom.js +17 -22
- package/lib/util/zoom.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/item/combo.ts +13 -5
- package/src/item/edge.ts +126 -17
- package/src/item/item.ts +119 -57
- package/src/item/node.ts +108 -11
- package/src/runtime/controller/data.ts +64 -3
- package/src/runtime/controller/index.ts +1 -1
- package/src/runtime/controller/item.ts +321 -135
- package/src/runtime/controller/layout.ts +254 -113
- package/src/runtime/controller/plugin.ts +86 -33
- package/src/runtime/controller/viewport.ts +8 -2
- package/src/runtime/graph.ts +383 -158
- package/src/stdlib/behavior/click-select.ts +8 -3
- package/src/stdlib/behavior/drag-canvas.ts +6 -3
- package/src/stdlib/behavior/drag-combo.ts +8 -8
- package/src/stdlib/behavior/drag-node.ts +165 -50
- package/src/stdlib/behavior/scroll-canvas.ts +3 -3
- package/src/stdlib/behavior/zoom-canvas.ts +3 -3
- package/src/stdlib/data/mapNodeSize.ts +2 -2
- package/src/stdlib/data/validateData.ts +2 -2
- package/src/stdlib/index.ts +3 -0
- package/src/stdlib/item/edge/base.ts +15 -139
- package/src/stdlib/item/node/base.ts +20 -215
- package/src/stdlib/plugin/edgeFilterLens/index.ts +2 -2
- package/src/stdlib/plugin/fisheye/index.ts +3 -2
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/index.ts +1 -0
- package/src/stdlib/plugin/lodController/index.ts +602 -0
- package/src/stdlib/plugin/minimap/index.ts +12 -14
- package/src/stdlib/plugin/toolbar/index.ts +29 -31
- package/src/stdlib/theme/dark.ts +32 -34
- package/src/stdlib/theme/light.ts +27 -29
- package/src/stdlib/themeSolver/spec.ts +2 -2
- package/src/types/animate.ts +1 -1
- package/src/types/combo.ts +2 -2
- package/src/types/edge.ts +2 -2
- package/src/types/graph.ts +65 -53
- package/src/types/hook.ts +5 -0
- package/src/types/item.ts +8 -14
- package/src/types/layout.ts +20 -15
- package/src/types/node.ts +3 -2
- package/src/types/plugin.ts +2 -0
- package/src/types/spec.ts +1 -0
- package/src/types/theme.ts +7 -7
- package/src/util/animate.ts +104 -78
- package/src/util/bbox.ts +26 -1
- package/src/util/data.ts +15 -6
- package/src/util/dom.ts +6 -6
- package/src/util/item.ts +15 -1
- package/src/util/mapper.ts +1 -1
- package/src/util/path.ts +72 -2
- package/src/util/polyline.ts +30 -23
- package/src/util/router.ts +21 -19
- package/src/util/shape.ts +27 -12
- package/src/util/zoom.ts +19 -25
- package/esm/runtime/controller/extension.d.ts +0 -9
- package/esm/runtime/controller/extension.js +0 -11
- package/esm/runtime/controller/extension.js.map +0 -1
- package/lib/runtime/controller/extension.d.ts +0 -9
- package/lib/runtime/controller/extension.js +0 -15
- package/lib/runtime/controller/extension.js.map +0 -1
- package/src/runtime/controller/extension.ts +0 -14
package/src/runtime/graph.ts
CHANGED
|
@@ -59,26 +59,29 @@ import { changeRenderer, createCanvas } from '../util/canvas';
|
|
|
59
59
|
import { createDOM } from '../util/dom';
|
|
60
60
|
import { getLayoutBounds } from '../util/layout';
|
|
61
61
|
import { formatPadding } from '../util/shape';
|
|
62
|
+
import Node from '../item/node';
|
|
63
|
+
import { cloneJSON, isEmptyGraph } from '../util/data';
|
|
64
|
+
import { getCombinedCanvasesBounds } from '../util/bbox';
|
|
62
65
|
import {
|
|
63
66
|
DataController,
|
|
64
|
-
ExtensionController,
|
|
65
67
|
InteractionController,
|
|
66
68
|
ItemController,
|
|
67
69
|
LayoutController,
|
|
68
70
|
ThemeController,
|
|
69
71
|
ViewportController,
|
|
72
|
+
PluginController,
|
|
70
73
|
} from './controller';
|
|
71
|
-
import { PluginController } from './controller/plugin';
|
|
72
74
|
import Hook from './hooks';
|
|
73
|
-
import { isEmptyGraph } from '../util/data';
|
|
74
75
|
|
|
75
76
|
export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
76
77
|
extends EventEmitter
|
|
77
78
|
implements IGraph<B, T>
|
|
78
79
|
{
|
|
79
80
|
public hooks: Hooks;
|
|
80
|
-
// for nodes and edges, which will be separate into groups
|
|
81
|
+
// for nodes and edges excluding their labels, which will be separate into groups
|
|
81
82
|
public canvas: Canvas;
|
|
83
|
+
// for nodes' and edges' labels
|
|
84
|
+
public labelCanvas: Canvas;
|
|
82
85
|
// the container dom for the graph canvas
|
|
83
86
|
public container: HTMLElement;
|
|
84
87
|
// the tag to indicate whether the graph instance is destroyed
|
|
@@ -87,6 +90,8 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
87
90
|
public rendererType: RendererName;
|
|
88
91
|
// for transient shapes for interactions, e.g. transient node and related edges while draging, delegates
|
|
89
92
|
public transientCanvas: Canvas;
|
|
93
|
+
// for transient items' label shapes
|
|
94
|
+
public transientLabelCanvas: Canvas;
|
|
90
95
|
// for background shapes, e.g. grid, pipe indices
|
|
91
96
|
public backgroundCanvas: Canvas;
|
|
92
97
|
// the tag indicates all the three canvases are all ready
|
|
@@ -98,7 +103,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
98
103
|
private layoutController: LayoutController;
|
|
99
104
|
private viewportController: ViewportController;
|
|
100
105
|
private itemController: ItemController;
|
|
101
|
-
private extensionController: ExtensionController;
|
|
102
106
|
private themeController: ThemeController;
|
|
103
107
|
private pluginController: PluginController;
|
|
104
108
|
|
|
@@ -127,7 +131,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
127
131
|
canvases: {
|
|
128
132
|
background: this.backgroundCanvas,
|
|
129
133
|
main: this.canvas,
|
|
134
|
+
label: this.labelCanvas,
|
|
130
135
|
transient: this.transientCanvas,
|
|
136
|
+
transientLabel: this.transientLabelCanvas,
|
|
131
137
|
},
|
|
132
138
|
});
|
|
133
139
|
|
|
@@ -146,9 +152,8 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
146
152
|
this.interactionController = new InteractionController(this);
|
|
147
153
|
this.layoutController = new LayoutController(this);
|
|
148
154
|
this.themeController = new ThemeController(this);
|
|
149
|
-
this.itemController = new ItemController(this);
|
|
150
155
|
this.viewportController = new ViewportController(this);
|
|
151
|
-
this.
|
|
156
|
+
this.itemController = new ItemController(this);
|
|
152
157
|
this.pluginController = new PluginController(this);
|
|
153
158
|
}
|
|
154
159
|
|
|
@@ -159,6 +164,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
159
164
|
canvas,
|
|
160
165
|
backgroundCanvas,
|
|
161
166
|
transientCanvas,
|
|
167
|
+
transientLabelCanvas,
|
|
162
168
|
width,
|
|
163
169
|
height,
|
|
164
170
|
} = this.specification;
|
|
@@ -181,6 +187,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
181
187
|
this.canvas = canvas;
|
|
182
188
|
this.backgroundCanvas = backgroundCanvas;
|
|
183
189
|
this.transientCanvas = transientCanvas;
|
|
190
|
+
this.transientLabelCanvas = transientLabelCanvas;
|
|
184
191
|
this.container = container as HTMLElement;
|
|
185
192
|
} else {
|
|
186
193
|
const containerDOM = isString(container)
|
|
@@ -217,6 +224,13 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
217
224
|
size[1],
|
|
218
225
|
pixelRatio,
|
|
219
226
|
);
|
|
227
|
+
this.labelCanvas = createCanvas(
|
|
228
|
+
'canvas',
|
|
229
|
+
containerDOM,
|
|
230
|
+
size[0],
|
|
231
|
+
size[1],
|
|
232
|
+
pixelRatio,
|
|
233
|
+
);
|
|
220
234
|
this.transientCanvas = createCanvas(
|
|
221
235
|
this.rendererType,
|
|
222
236
|
containerDOM,
|
|
@@ -224,30 +238,45 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
224
238
|
size[1],
|
|
225
239
|
pixelRatio,
|
|
226
240
|
);
|
|
241
|
+
this.transientLabelCanvas = createCanvas(
|
|
242
|
+
'canvas',
|
|
243
|
+
containerDOM,
|
|
244
|
+
size[0],
|
|
245
|
+
size[1],
|
|
246
|
+
pixelRatio,
|
|
247
|
+
);
|
|
227
248
|
}
|
|
228
249
|
|
|
229
250
|
Promise.all(
|
|
230
|
-
[
|
|
231
|
-
|
|
232
|
-
|
|
251
|
+
[
|
|
252
|
+
this.backgroundCanvas,
|
|
253
|
+
this.canvas,
|
|
254
|
+
this.labelCanvas,
|
|
255
|
+
this.transientCanvas,
|
|
256
|
+
this.transientLabelCanvas,
|
|
257
|
+
].map((canvas) => canvas.ready),
|
|
233
258
|
).then(() => {
|
|
234
|
-
[
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
259
|
+
[
|
|
260
|
+
this.backgroundCanvas,
|
|
261
|
+
this.canvas,
|
|
262
|
+
this.labelCanvas,
|
|
263
|
+
this.transientCanvas,
|
|
264
|
+
this.transientLabelCanvas,
|
|
265
|
+
].forEach((canvas, i) => {
|
|
266
|
+
const $domElement = canvas
|
|
267
|
+
.getContextService()
|
|
268
|
+
.getDomElement() as unknown as HTMLElement;
|
|
269
|
+
if ($domElement && $domElement.style) {
|
|
270
|
+
// Make all these 3 canvas doms overlap each other. The container already has `position: relative` style.
|
|
271
|
+
$domElement.style.position = 'absolute';
|
|
272
|
+
$domElement.style.outline = 'none';
|
|
273
|
+
$domElement.tabIndex = 1; // Enable keyboard events
|
|
274
|
+
// Transient canvas should let interactive events go through.
|
|
275
|
+
if (i !== 1) {
|
|
276
|
+
$domElement.style.pointerEvents = 'none';
|
|
248
277
|
}
|
|
249
|
-
}
|
|
250
|
-
);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
251
280
|
|
|
252
281
|
this.canvasReady = true;
|
|
253
282
|
});
|
|
@@ -287,8 +316,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
287
316
|
init: new Hook<{
|
|
288
317
|
canvases: {
|
|
289
318
|
background: Canvas;
|
|
319
|
+
label: Canvas;
|
|
290
320
|
main: Canvas;
|
|
291
321
|
transient: Canvas;
|
|
322
|
+
transientLabel: Canvas;
|
|
292
323
|
};
|
|
293
324
|
}>({ name: 'init' }),
|
|
294
325
|
datachange: new Hook<{ data: GraphData; type: DataChangeType }>({
|
|
@@ -306,6 +337,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
306
337
|
graphCore: GraphCore;
|
|
307
338
|
theme: ThemeSpecification;
|
|
308
339
|
transientCanvas: Canvas;
|
|
340
|
+
transientLabelCanvas: Canvas;
|
|
309
341
|
}>({
|
|
310
342
|
name: 'render',
|
|
311
343
|
}),
|
|
@@ -473,6 +505,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
473
505
|
graphCore: this.dataController.graphCore,
|
|
474
506
|
theme: this.themeController.specification,
|
|
475
507
|
transientCanvas: this.transientCanvas,
|
|
508
|
+
transientLabelCanvas: this.transientLabelCanvas,
|
|
476
509
|
tileOptimize: {
|
|
477
510
|
tileFirstRender,
|
|
478
511
|
tileFirstRenderSize,
|
|
@@ -518,9 +551,13 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
518
551
|
await emitRender();
|
|
519
552
|
} else {
|
|
520
553
|
await Promise.all(
|
|
521
|
-
[
|
|
522
|
-
|
|
523
|
-
|
|
554
|
+
[
|
|
555
|
+
this.backgroundCanvas,
|
|
556
|
+
this.canvas,
|
|
557
|
+
this.labelCanvas,
|
|
558
|
+
this.transientCanvas,
|
|
559
|
+
this.transientLabelCanvas,
|
|
560
|
+
].map((canvas) => canvas.ready),
|
|
524
561
|
);
|
|
525
562
|
await emitRender();
|
|
526
563
|
}
|
|
@@ -530,12 +567,14 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
530
567
|
* Change graph data.
|
|
531
568
|
* @param data new data
|
|
532
569
|
* @param type the way to change data, 'replace' means discard the old data and use the new one; 'mergeReplace' means merge the common part, remove (old - new), add (new - old)
|
|
570
|
+
* @param relayout whether relayout the nodes after data changing
|
|
533
571
|
* @returns
|
|
534
572
|
* @group Data
|
|
535
573
|
*/
|
|
536
574
|
public async changeData(
|
|
537
575
|
data: DataConfig,
|
|
538
576
|
type: 'replace' | 'mergeReplace' = 'mergeReplace',
|
|
577
|
+
relayout: boolean = true,
|
|
539
578
|
) {
|
|
540
579
|
const { tileFirstRender, tileFirstRenderSize } =
|
|
541
580
|
this.specification.optimize || {};
|
|
@@ -544,6 +583,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
544
583
|
graphCore: this.dataController.graphCore,
|
|
545
584
|
theme: this.themeController.specification,
|
|
546
585
|
transientCanvas: this.transientCanvas,
|
|
586
|
+
transientLabelCanvas: this.transientLabelCanvas,
|
|
547
587
|
tileOptimize: {
|
|
548
588
|
tileFirstRender,
|
|
549
589
|
tileFirstRenderSize,
|
|
@@ -551,7 +591,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
551
591
|
});
|
|
552
592
|
this.emit('afterrender');
|
|
553
593
|
|
|
554
|
-
|
|
594
|
+
if (relayout) {
|
|
595
|
+
await this.layout();
|
|
596
|
+
}
|
|
555
597
|
}
|
|
556
598
|
|
|
557
599
|
/**
|
|
@@ -775,10 +817,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
775
817
|
halfExtents,
|
|
776
818
|
} = boundsType === 'render'
|
|
777
819
|
? // Get the bounds of the whole graph content.
|
|
778
|
-
this.canvas.
|
|
779
|
-
: // Get the
|
|
820
|
+
getCombinedCanvasesBounds([this.canvas, this.labelCanvas])
|
|
821
|
+
: // Get the b ounds of the nodes positions while the graph content is not ready.
|
|
780
822
|
getLayoutBounds(this);
|
|
781
|
-
|
|
782
823
|
const origin = this.canvas.canvas2Viewport({
|
|
783
824
|
x: graphCenterX,
|
|
784
825
|
y: graphCenterY,
|
|
@@ -849,7 +890,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
849
890
|
} =
|
|
850
891
|
boundsType === 'render'
|
|
851
892
|
? // Get the bounds of the whole graph content.
|
|
852
|
-
this.canvas.
|
|
893
|
+
getCombinedCanvasesBounds([this.canvas, this.labelCanvas])
|
|
853
894
|
: // Get the bounds of the nodes positions while the graph content is not ready.
|
|
854
895
|
getLayoutBounds(this);
|
|
855
896
|
await this.translateTo(
|
|
@@ -922,9 +963,15 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
922
963
|
this.emit('beforesetsize', { oldSize, size: size });
|
|
923
964
|
this.specification.width = size[0];
|
|
924
965
|
this.specification.height = size[1];
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
966
|
+
[
|
|
967
|
+
this.canvas,
|
|
968
|
+
this.labelCanvas,
|
|
969
|
+
this.transientCanvas,
|
|
970
|
+
this.transientLabelCanvas,
|
|
971
|
+
this.backgroundCanvas,
|
|
972
|
+
].forEach((canvas) => {
|
|
973
|
+
canvas.resize(size[0], size[1]);
|
|
974
|
+
});
|
|
928
975
|
this.emit('aftersetsize', { oldSize, size: size });
|
|
929
976
|
}
|
|
930
977
|
|
|
@@ -1062,6 +1109,26 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1062
1109
|
): EdgeModel[] {
|
|
1063
1110
|
return this.dataController.findRelatedEdges(nodeId, direction);
|
|
1064
1111
|
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Get nearby edges from a start node using quadtree collision detection.
|
|
1114
|
+
* @param nodeId id of the start node
|
|
1115
|
+
* @returns nearby edges' data array
|
|
1116
|
+
*/
|
|
1117
|
+
public getNearEdgesData(
|
|
1118
|
+
nodeId: ID,
|
|
1119
|
+
shouldBegin?: (edge: EdgeDisplayModel) => boolean,
|
|
1120
|
+
): EdgeModel[] {
|
|
1121
|
+
const transientItem = this.itemController.getTransientItem(
|
|
1122
|
+
nodeId,
|
|
1123
|
+
) as unknown as Node;
|
|
1124
|
+
const itemMap = this.itemController.getItemMap();
|
|
1125
|
+
return this.dataController.findNearEdges(
|
|
1126
|
+
nodeId,
|
|
1127
|
+
itemMap,
|
|
1128
|
+
transientItem,
|
|
1129
|
+
shouldBegin,
|
|
1130
|
+
);
|
|
1131
|
+
}
|
|
1065
1132
|
/**
|
|
1066
1133
|
* Get one-hop node ids from a start node.
|
|
1067
1134
|
* @param nodeId id of the start node
|
|
@@ -1106,16 +1173,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1106
1173
|
return this.itemController.findDisplayModel(id);
|
|
1107
1174
|
}
|
|
1108
1175
|
|
|
1109
|
-
/**
|
|
1110
|
-
* Retrieve the nearby edges for a given node using quadtree collision detection.
|
|
1111
|
-
* @param nodeId node id
|
|
1112
|
-
* @group Data
|
|
1113
|
-
*/
|
|
1114
|
-
public getNearEdgesForNode(nodeId: ID): EdgeModel[] {
|
|
1115
|
-
const { graphCore } = this.dataController;
|
|
1116
|
-
return this.itemController.findNearEdgesByNode(nodeId, graphCore);
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
1176
|
/**
|
|
1120
1177
|
* Find items which has the state.
|
|
1121
1178
|
* @param itemType item type
|
|
@@ -1166,13 +1223,14 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1166
1223
|
|
|
1167
1224
|
const { graphCore } = this.dataController;
|
|
1168
1225
|
const { specification } = this.themeController;
|
|
1226
|
+
const modelArr = isArray(models) ? models : [models];
|
|
1169
1227
|
graphCore.once('changed', (event) => {
|
|
1170
1228
|
if (!event.changes.length) return;
|
|
1171
1229
|
const changes = event.changes;
|
|
1172
1230
|
const timingParameters = {
|
|
1173
1231
|
type: itemType,
|
|
1174
1232
|
action: 'add',
|
|
1175
|
-
models,
|
|
1233
|
+
models: modelArr,
|
|
1176
1234
|
apiName: 'addData',
|
|
1177
1235
|
changes,
|
|
1178
1236
|
};
|
|
@@ -1186,7 +1244,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1186
1244
|
this.emit('afteritemchange', timingParameters);
|
|
1187
1245
|
});
|
|
1188
1246
|
|
|
1189
|
-
const modelArr = isArray(models) ? models : [models];
|
|
1190
1247
|
const data = { nodes: [], edges: [], combos: [] };
|
|
1191
1248
|
data[`${itemType}s`] = modelArr;
|
|
1192
1249
|
this.hooks.datachange.emit({
|
|
@@ -1201,7 +1258,8 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1201
1258
|
}
|
|
1202
1259
|
/**
|
|
1203
1260
|
* Remove one or more node/edge/combo data from the graph.
|
|
1204
|
-
* @param
|
|
1261
|
+
* @param itemType the type the item(s) to be removed.
|
|
1262
|
+
* @param id the id or the ids' array of the items to be removed.
|
|
1205
1263
|
* @returns whether success
|
|
1206
1264
|
* @group Data
|
|
1207
1265
|
*/
|
|
@@ -1303,8 +1361,8 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1303
1361
|
}
|
|
1304
1362
|
/**
|
|
1305
1363
|
* Update one or more node/edge/combo data on the graph.
|
|
1306
|
-
* @param {ITEM_TYPE} itemType
|
|
1307
|
-
* @param models
|
|
1364
|
+
* @param {ITEM_TYPE} itemType the type the item(s) to be udated.
|
|
1365
|
+
* @param models update configs.
|
|
1308
1366
|
* @group Data
|
|
1309
1367
|
*/
|
|
1310
1368
|
public updateData(
|
|
@@ -1332,11 +1390,11 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1332
1390
|
const { graphCore } = this.dataController;
|
|
1333
1391
|
const { specification } = this.themeController;
|
|
1334
1392
|
graphCore.once('changed', (event) => {
|
|
1335
|
-
const changes = this.extendChanges(
|
|
1393
|
+
const changes = this.extendChanges(cloneJSON(event.changes));
|
|
1336
1394
|
const timingParameters = {
|
|
1337
1395
|
type: itemType,
|
|
1338
1396
|
action: 'update',
|
|
1339
|
-
models,
|
|
1397
|
+
models: modelArr,
|
|
1340
1398
|
apiName: 'updateData',
|
|
1341
1399
|
changes,
|
|
1342
1400
|
};
|
|
@@ -1364,7 +1422,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1364
1422
|
/**
|
|
1365
1423
|
* Update one or more nodes' positions,
|
|
1366
1424
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1367
|
-
* @param models new configurations with x and y for every node, which has id field to indicate the specific item
|
|
1425
|
+
* @param models new configurations with x and y for every node, which has id field to indicate the specific item.
|
|
1426
|
+
* @param upsertAncestors whether update the ancestors in combo tree.
|
|
1427
|
+
* @param disableAnimate whether disable the animation for this call.
|
|
1428
|
+
* @param callback callback function after update nodes done.
|
|
1368
1429
|
* @group Data
|
|
1369
1430
|
*/
|
|
1370
1431
|
public updateNodePosition(
|
|
@@ -1379,7 +1440,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1379
1440
|
model: NodeModel | EdgeModel | ComboModel,
|
|
1380
1441
|
canceled?: boolean,
|
|
1381
1442
|
) => void,
|
|
1382
|
-
stack?: boolean,
|
|
1383
1443
|
) {
|
|
1384
1444
|
return this.updatePosition(
|
|
1385
1445
|
'node',
|
|
@@ -1387,7 +1447,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1387
1447
|
upsertAncestors,
|
|
1388
1448
|
disableAnimate,
|
|
1389
1449
|
callback,
|
|
1390
|
-
stack,
|
|
1391
1450
|
);
|
|
1392
1451
|
}
|
|
1393
1452
|
|
|
@@ -1395,7 +1454,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1395
1454
|
* Update one or more combos' positions,
|
|
1396
1455
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1397
1456
|
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1398
|
-
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1457
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
|
|
1458
|
+
* @param upsertAncestors whether update the ancestors in combo tree.
|
|
1459
|
+
* @param disableAnimate whether disable the animation for this call.
|
|
1460
|
+
* @param callback callback function after update combos done.
|
|
1399
1461
|
* @group Data
|
|
1400
1462
|
*/
|
|
1401
1463
|
public updateComboPosition(
|
|
@@ -1407,7 +1469,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1407
1469
|
upsertAncestors?: boolean,
|
|
1408
1470
|
disableAnimate = false,
|
|
1409
1471
|
callback?: (model: NodeModel | EdgeModel | ComboModel) => void,
|
|
1410
|
-
stack?: boolean,
|
|
1411
1472
|
) {
|
|
1412
1473
|
return this.updatePosition(
|
|
1413
1474
|
'combo',
|
|
@@ -1415,7 +1476,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1415
1476
|
upsertAncestors,
|
|
1416
1477
|
disableAnimate,
|
|
1417
1478
|
callback,
|
|
1418
|
-
stack,
|
|
1419
1479
|
);
|
|
1420
1480
|
}
|
|
1421
1481
|
|
|
@@ -1446,7 +1506,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1446
1506
|
model: NodeModel | EdgeModel | ComboModel,
|
|
1447
1507
|
canceled?: boolean,
|
|
1448
1508
|
) => void,
|
|
1449
|
-
stack?: boolean,
|
|
1450
1509
|
) {
|
|
1451
1510
|
const modelArr = isArray(models) ? models : [models];
|
|
1452
1511
|
const { graphCore } = this.dataController;
|
|
@@ -1460,7 +1519,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1460
1519
|
type,
|
|
1461
1520
|
action: 'updatePosition',
|
|
1462
1521
|
upsertAncestors,
|
|
1463
|
-
models,
|
|
1522
|
+
models: modelArr,
|
|
1464
1523
|
apiName: 'updatePosition',
|
|
1465
1524
|
changes,
|
|
1466
1525
|
};
|
|
@@ -1513,21 +1572,46 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1513
1572
|
* @returns
|
|
1514
1573
|
* @group Item
|
|
1515
1574
|
*/
|
|
1516
|
-
public showItem(
|
|
1575
|
+
public showItem(
|
|
1576
|
+
ids: ID | ID[],
|
|
1577
|
+
options?: {
|
|
1578
|
+
disableAnimate?: boolean;
|
|
1579
|
+
shapeIds?: string | string[];
|
|
1580
|
+
},
|
|
1581
|
+
) {
|
|
1582
|
+
const { disableAnimate = false, shapeIds } = options || {};
|
|
1517
1583
|
const idArr = isArray(ids) ? ids : [ids];
|
|
1518
1584
|
if (isEmpty(idArr)) return;
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1585
|
+
|
|
1586
|
+
let changes;
|
|
1587
|
+
if (shapeIds?.length) {
|
|
1588
|
+
const shapeIdsArr = isArray(shapeIds) ? shapeIds : [shapeIds];
|
|
1589
|
+
changes = {
|
|
1590
|
+
newValue: [{ ids: idArr, visible: true, shapeIds: shapeIdsArr }],
|
|
1591
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1592
|
+
};
|
|
1593
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1594
|
+
ids: idArr as ID[],
|
|
1595
|
+
value: true,
|
|
1596
|
+
graphCore: this.dataController.graphCore,
|
|
1597
|
+
animate: !disableAnimate,
|
|
1598
|
+
shapeIds: shapeIdsArr,
|
|
1599
|
+
});
|
|
1600
|
+
} else {
|
|
1601
|
+
changes = {
|
|
1602
|
+
newValue: [{ ids: idArr, visible: true }],
|
|
1603
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1604
|
+
};
|
|
1605
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1606
|
+
ids: idArr as ID[],
|
|
1607
|
+
value: true,
|
|
1608
|
+
graphCore: this.dataController.graphCore,
|
|
1609
|
+
animate: !disableAnimate,
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1529
1613
|
this.emit('afteritemvisibilitychange', {
|
|
1530
|
-
ids,
|
|
1614
|
+
ids: idArr as ID[],
|
|
1531
1615
|
value: true,
|
|
1532
1616
|
animate: !disableAnimate,
|
|
1533
1617
|
action: 'updateVisibility',
|
|
@@ -1537,30 +1621,62 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1537
1621
|
}
|
|
1538
1622
|
/**
|
|
1539
1623
|
* Hide the item(s).
|
|
1540
|
-
* @param
|
|
1624
|
+
* @param id the id for the item to be hidden.
|
|
1625
|
+
* @param disableAnimate whether disable the hidden animations.
|
|
1626
|
+
* @param keepKeyShape whether keep the keyShape.
|
|
1627
|
+
* @param keepRelated whether keep the related nodes for edge.
|
|
1541
1628
|
* @returns
|
|
1542
1629
|
* @group Item
|
|
1543
1630
|
*/
|
|
1544
1631
|
public hideItem(
|
|
1545
1632
|
ids: ID | ID[],
|
|
1546
|
-
|
|
1547
|
-
|
|
1633
|
+
options?: {
|
|
1634
|
+
disableAnimate?: boolean;
|
|
1635
|
+
keepKeyShape?: boolean;
|
|
1636
|
+
keepRelated?: boolean;
|
|
1637
|
+
shapeIds?: string[];
|
|
1638
|
+
},
|
|
1548
1639
|
) {
|
|
1549
|
-
const
|
|
1640
|
+
const {
|
|
1641
|
+
disableAnimate = false,
|
|
1642
|
+
keepKeyShape = false,
|
|
1643
|
+
keepRelated = false,
|
|
1644
|
+
shapeIds,
|
|
1645
|
+
} = options || {};
|
|
1646
|
+
const idArr: ID[] = isArray(ids) ? ids : [ids];
|
|
1550
1647
|
if (isEmpty(idArr)) return;
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1648
|
+
|
|
1649
|
+
let changes;
|
|
1650
|
+
if (shapeIds?.length) {
|
|
1651
|
+
const shapeIdsArr = isArray(shapeIds) ? shapeIds : [shapeIds];
|
|
1652
|
+
changes = {
|
|
1653
|
+
newValue: [{ ids: idArr, visible: false, shapeIds: shapeIdsArr }],
|
|
1654
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1655
|
+
};
|
|
1656
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1657
|
+
ids: idArr,
|
|
1658
|
+
value: false,
|
|
1659
|
+
graphCore: this.dataController.graphCore,
|
|
1660
|
+
animate: !disableAnimate,
|
|
1661
|
+
shapeIds: shapeIdsArr,
|
|
1662
|
+
});
|
|
1663
|
+
} else {
|
|
1664
|
+
changes = {
|
|
1665
|
+
newValue: [{ ids: idArr, visible: false }],
|
|
1666
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1667
|
+
};
|
|
1668
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1669
|
+
ids: idArr,
|
|
1670
|
+
value: false,
|
|
1671
|
+
graphCore: this.dataController.graphCore,
|
|
1672
|
+
animate: !disableAnimate,
|
|
1673
|
+
keepKeyShape,
|
|
1674
|
+
keepRelated,
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1562
1678
|
this.emit('afteritemvisibilitychange', {
|
|
1563
|
-
ids,
|
|
1679
|
+
ids: idArr,
|
|
1564
1680
|
value: false,
|
|
1565
1681
|
animate: !disableAnimate,
|
|
1566
1682
|
action: 'updateVisibility',
|
|
@@ -1737,12 +1853,22 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1737
1853
|
return this.itemController.getItemVisible(id);
|
|
1738
1854
|
}
|
|
1739
1855
|
|
|
1856
|
+
/**
|
|
1857
|
+
* Get the visible shape ids in a node / edge / combo.
|
|
1858
|
+
* @param id the id for the node / edge / combo
|
|
1859
|
+
* @returns ids of the visible shapes
|
|
1860
|
+
*/
|
|
1861
|
+
public getItemVisibleShapeIds(id: ID) {
|
|
1862
|
+
return this.itemController.getItemVisibleShapeIds(id);
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1740
1865
|
// ===== combo operations =====
|
|
1741
1866
|
|
|
1742
1867
|
/**
|
|
1743
1868
|
* Add a new combo to the graph, and update the structure of the existed child in childrenIds to be the children of the new combo.
|
|
1744
1869
|
* Different from addData with combo type, this API update the succeeds' combo tree strucutres in the same time.
|
|
1745
|
-
* @param model combo user data
|
|
1870
|
+
* @param model combo user data.
|
|
1871
|
+
* @param childrenIds the ids of the children nodes / combos to move into the new combo.
|
|
1746
1872
|
* @returns whether success
|
|
1747
1873
|
* @group Combo
|
|
1748
1874
|
*/
|
|
@@ -1790,7 +1916,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1790
1916
|
}
|
|
1791
1917
|
/**
|
|
1792
1918
|
* Collapse a combo.
|
|
1793
|
-
* @param comboId combo ids
|
|
1919
|
+
* @param comboId combo id or ids' array.
|
|
1794
1920
|
* @group Combo
|
|
1795
1921
|
*/
|
|
1796
1922
|
public collapseCombo(comboIds: ID | ID[]) {
|
|
@@ -1810,7 +1936,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1810
1936
|
}
|
|
1811
1937
|
/**
|
|
1812
1938
|
* Expand a combo.
|
|
1813
|
-
* @param
|
|
1939
|
+
* @param comboId combo id or ids' array.
|
|
1814
1940
|
* @group Combo
|
|
1815
1941
|
*/
|
|
1816
1942
|
public expandCombo(comboIds: ID | ID[]) {
|
|
@@ -1833,7 +1959,11 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1833
1959
|
* Move one or more combos a distance (dx, dy) relatively,
|
|
1834
1960
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1835
1961
|
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1836
|
-
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1962
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
|
|
1963
|
+
* @param dx the distance alone x-axis to move the combo.
|
|
1964
|
+
* @param dy the distance alone y-axis to move the combo.
|
|
1965
|
+
* @param upsertAncestors whether update the ancestors in the combo tree.
|
|
1966
|
+
* @param callback callback function after move combo done.
|
|
1837
1967
|
* @group Combo
|
|
1838
1968
|
*/
|
|
1839
1969
|
public moveCombo(
|
|
@@ -1890,7 +2020,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1890
2020
|
/**
|
|
1891
2021
|
* Layout the graph (with current configurations if cfg is not assigned).
|
|
1892
2022
|
*/
|
|
1893
|
-
public async layout(
|
|
2023
|
+
public async layout(
|
|
2024
|
+
options?: Partial<LayoutOptions>,
|
|
2025
|
+
disableAnimate = false,
|
|
2026
|
+
) {
|
|
1894
2027
|
this.emit('beforelayout');
|
|
1895
2028
|
const { graphCore } = this.dataController;
|
|
1896
2029
|
const formattedOptions = {
|
|
@@ -1977,7 +2110,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
1977
2110
|
*/
|
|
1978
2111
|
public setCursor(cursor: Cursor) {
|
|
1979
2112
|
this.canvas.setCursor(cursor);
|
|
2113
|
+
this.labelCanvas.setCursor(cursor);
|
|
1980
2114
|
this.transientCanvas.setCursor(cursor);
|
|
2115
|
+
this.transientLabelCanvas.setCursor(cursor);
|
|
1981
2116
|
}
|
|
1982
2117
|
|
|
1983
2118
|
/**
|
|
@@ -2153,12 +2288,15 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2153
2288
|
| PluginBase,
|
|
2154
2289
|
) {
|
|
2155
2290
|
const { plugins } = this.specification;
|
|
2156
|
-
const { key } = plugin
|
|
2291
|
+
const { key, type } = plugin as {
|
|
2292
|
+
key: string;
|
|
2293
|
+
type: string;
|
|
2294
|
+
[cfg: string]: unknown;
|
|
2295
|
+
};
|
|
2157
2296
|
if (!key) {
|
|
2158
2297
|
console.warn(
|
|
2159
|
-
|
|
2298
|
+
`The key for the plugin is not found. G6 will update the first plugin with type ${type}`,
|
|
2160
2299
|
);
|
|
2161
|
-
return;
|
|
2162
2300
|
}
|
|
2163
2301
|
if (!plugins) {
|
|
2164
2302
|
console.warn(
|
|
@@ -2167,12 +2305,21 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2167
2305
|
return;
|
|
2168
2306
|
}
|
|
2169
2307
|
const oldPlugin = plugins?.find((p) => {
|
|
2170
|
-
if (typeof p === 'string') return p === key;
|
|
2171
|
-
return
|
|
2308
|
+
if (typeof p === 'string') return p === key || p === type;
|
|
2309
|
+
return (
|
|
2310
|
+
p.key === key ||
|
|
2311
|
+
(
|
|
2312
|
+
p as {
|
|
2313
|
+
key: string;
|
|
2314
|
+
type: string;
|
|
2315
|
+
[cfg: string]: unknown;
|
|
2316
|
+
}
|
|
2317
|
+
).type === type
|
|
2318
|
+
);
|
|
2172
2319
|
});
|
|
2173
2320
|
if (!oldPlugin) {
|
|
2174
2321
|
console.warn(
|
|
2175
|
-
|
|
2322
|
+
`Update plugin failed, the plugin with key ${key} or type ${type} is not found.`,
|
|
2176
2323
|
);
|
|
2177
2324
|
return;
|
|
2178
2325
|
}
|
|
@@ -2236,19 +2383,23 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2236
2383
|
* @returns A Promise that resolves to the Data URL string.
|
|
2237
2384
|
*/
|
|
2238
2385
|
public async toDataURL(type?: DataURLType): Promise<string> {
|
|
2239
|
-
const
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2386
|
+
const {
|
|
2387
|
+
backgroundCanvas,
|
|
2388
|
+
canvas,
|
|
2389
|
+
transientCanvas,
|
|
2390
|
+
labelCanvas,
|
|
2391
|
+
rendererType,
|
|
2392
|
+
} = this;
|
|
2243
2393
|
|
|
2244
2394
|
const pixelRatio =
|
|
2245
2395
|
typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
2246
|
-
const width = this.getSize()
|
|
2247
|
-
const height = this.getSize()[1];
|
|
2396
|
+
const [width, height] = this.getSize();
|
|
2248
2397
|
|
|
2249
2398
|
const vContainerDOM: HTMLElement = createDOM(
|
|
2250
2399
|
'<div id="virtual-image"></div>',
|
|
2251
2400
|
);
|
|
2401
|
+
|
|
2402
|
+
const camera = canvas.getCamera();
|
|
2252
2403
|
const vCanvas = createCanvas(
|
|
2253
2404
|
rendererType,
|
|
2254
2405
|
vContainerDOM,
|
|
@@ -2256,13 +2407,48 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2256
2407
|
height,
|
|
2257
2408
|
pixelRatio,
|
|
2258
2409
|
);
|
|
2410
|
+
await vCanvas.ready;
|
|
2411
|
+
|
|
2412
|
+
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
2413
|
+
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
2414
|
+
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
2415
|
+
const labelClonedGroup = labelCanvas.getRoot().cloneNode(true);
|
|
2416
|
+
|
|
2417
|
+
const originViewportLTCanvas = vCanvas.viewport2Canvas({ x: 0, y: 0 });
|
|
2418
|
+
const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
2419
|
+
labelClonedGroup.translate([
|
|
2420
|
+
currentViewportLTCanvas.x - originViewportLTCanvas.x,
|
|
2421
|
+
currentViewportLTCanvas.y - originViewportLTCanvas.y,
|
|
2422
|
+
]);
|
|
2423
|
+
labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
|
|
2424
|
+
// TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
|
|
2425
|
+
labelClonedGroup.children[0].children.forEach((childGroup) => {
|
|
2426
|
+
childGroup.children.forEach((shape) => {
|
|
2427
|
+
if (
|
|
2428
|
+
shape.getAttribute('data-is-label-background') &&
|
|
2429
|
+
shape.style.transform
|
|
2430
|
+
)
|
|
2431
|
+
shape.remove();
|
|
2432
|
+
});
|
|
2433
|
+
});
|
|
2434
|
+
|
|
2435
|
+
vCanvas.appendChild(backgroundClonedGroup);
|
|
2436
|
+
vCanvas.appendChild(clonedGroup);
|
|
2437
|
+
vCanvas.appendChild(labelClonedGroup);
|
|
2438
|
+
vCanvas.appendChild(transientClonedGroup);
|
|
2439
|
+
|
|
2440
|
+
const vCamera = vCanvas.getCamera();
|
|
2441
|
+
vCamera.setZoom(camera.getZoom());
|
|
2442
|
+
vCamera.setPosition(camera.getPosition());
|
|
2443
|
+
vCamera.setFocalPoint(camera.getFocalPoint());
|
|
2444
|
+
|
|
2259
2445
|
const vCanvasContextService = vCanvas.getContextService();
|
|
2260
2446
|
let bgRect;
|
|
2261
2447
|
if (rendererType !== 'svg') {
|
|
2448
|
+
const backPositionCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
2262
2449
|
bgRect = new Rect({
|
|
2263
2450
|
style: {
|
|
2264
|
-
|
|
2265
|
-
y: 0,
|
|
2451
|
+
...backPositionCanvas,
|
|
2266
2452
|
z: -1,
|
|
2267
2453
|
width: vCanvasContextService.getDomElement().width,
|
|
2268
2454
|
height: vCanvasContextService.getDomElement().height,
|
|
@@ -2270,24 +2456,22 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2270
2456
|
fill: backgroundCanvas.getContextService().getDomElement().style[
|
|
2271
2457
|
'background-color'
|
|
2272
2458
|
],
|
|
2459
|
+
zIndex: -10,
|
|
2273
2460
|
},
|
|
2274
2461
|
});
|
|
2275
2462
|
vCanvas.appendChild(bgRect);
|
|
2276
2463
|
}
|
|
2277
|
-
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
2278
|
-
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
2279
|
-
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
2280
|
-
vCanvas.appendChild(backgroundClonedGroup);
|
|
2281
|
-
vCanvas.appendChild(clonedGroup);
|
|
2282
|
-
vCanvas.appendChild(transientClonedGroup);
|
|
2283
|
-
vCanvas.render();
|
|
2284
2464
|
|
|
2285
2465
|
if (!type) type = 'image/png';
|
|
2286
2466
|
let dataURL = '';
|
|
2287
|
-
|
|
2288
|
-
|
|
2467
|
+
return new Promise((resolve) => {
|
|
2468
|
+
setTimeout(() => {
|
|
2469
|
+
vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
2470
|
+
dataURL = url;
|
|
2471
|
+
resolve(dataURL);
|
|
2472
|
+
});
|
|
2473
|
+
}, 50);
|
|
2289
2474
|
});
|
|
2290
|
-
return dataURL;
|
|
2291
2475
|
}
|
|
2292
2476
|
|
|
2293
2477
|
/**
|
|
@@ -2301,17 +2485,22 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2301
2485
|
type?: DataURLType,
|
|
2302
2486
|
imageConfig?: { padding?: number | number[] },
|
|
2303
2487
|
) {
|
|
2304
|
-
const
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2488
|
+
const {
|
|
2489
|
+
backgroundCanvas,
|
|
2490
|
+
canvas,
|
|
2491
|
+
transientCanvas,
|
|
2492
|
+
labelCanvas,
|
|
2493
|
+
rendererType,
|
|
2494
|
+
} = this;
|
|
2495
|
+
const backgroundRoot = backgroundCanvas.getRoot();
|
|
2308
2496
|
const root = canvas.getRoot();
|
|
2309
2497
|
const transientRoot = transientCanvas.getRoot();
|
|
2310
|
-
const
|
|
2498
|
+
const labelRoot = labelCanvas.getRoot();
|
|
2311
2499
|
|
|
2312
|
-
const backgroundBBox = backgroundRoot.
|
|
2313
|
-
const BBox = root.
|
|
2314
|
-
const transientBBox = transientRoot.
|
|
2500
|
+
const backgroundBBox = backgroundRoot.getRenderBounds();
|
|
2501
|
+
const BBox = root.getRenderBounds();
|
|
2502
|
+
const transientBBox = transientRoot.getRenderBounds();
|
|
2503
|
+
const labelBBox = labelRoot.getRenderBounds();
|
|
2315
2504
|
|
|
2316
2505
|
let padding = imageConfig ? imageConfig.padding : undefined;
|
|
2317
2506
|
if (!padding) {
|
|
@@ -2321,29 +2510,33 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2321
2510
|
}
|
|
2322
2511
|
|
|
2323
2512
|
const left =
|
|
2324
|
-
(
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2513
|
+
Math.min(
|
|
2514
|
+
backgroundBBox.min[0] || Infinity,
|
|
2515
|
+
BBox.min[0] || Infinity,
|
|
2516
|
+
transientBBox.min[0] || Infinity,
|
|
2517
|
+
labelBBox.min[0] || Infinity,
|
|
2518
|
+
) - padding[3];
|
|
2329
2519
|
const right =
|
|
2330
|
-
(
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2520
|
+
Math.max(
|
|
2521
|
+
backgroundBBox.max[0] || -Infinity,
|
|
2522
|
+
BBox.max[0] || -Infinity,
|
|
2523
|
+
transientBBox.max[0] || -Infinity,
|
|
2524
|
+
labelBBox.max[0] || -Infinity,
|
|
2525
|
+
) - padding[1];
|
|
2335
2526
|
const top =
|
|
2336
|
-
(
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2527
|
+
Math.min(
|
|
2528
|
+
backgroundBBox.min[1] || Infinity,
|
|
2529
|
+
BBox.min[1] || Infinity,
|
|
2530
|
+
transientBBox.min[1] || Infinity,
|
|
2531
|
+
labelBBox.min[1] || Infinity,
|
|
2532
|
+
) - padding[0];
|
|
2341
2533
|
const bottom =
|
|
2342
|
-
(
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2534
|
+
Math.max(
|
|
2535
|
+
backgroundBBox.max[1] || -Infinity,
|
|
2536
|
+
BBox.max[1] || -Infinity,
|
|
2537
|
+
transientBBox.max[1] || -Infinity,
|
|
2538
|
+
labelBBox.max[1] || -Infinity,
|
|
2539
|
+
) - padding[2];
|
|
2347
2540
|
|
|
2348
2541
|
const graphCenterX = (left + right) / 2;
|
|
2349
2542
|
const graphCenterY = (top + bottom) / 2;
|
|
@@ -2364,6 +2557,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2364
2557
|
vHeight,
|
|
2365
2558
|
pixelRatio,
|
|
2366
2559
|
);
|
|
2560
|
+
await vCanvas.ready;
|
|
2367
2561
|
const vCanvasContextService = vCanvas.getContextService();
|
|
2368
2562
|
if (rendererType !== 'svg') {
|
|
2369
2563
|
const bgRect = new Rect({
|
|
@@ -2384,6 +2578,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2384
2578
|
const backgroundClonedGroup = backgroundRoot.cloneNode(true);
|
|
2385
2579
|
const clonedGroup = root.cloneNode(true);
|
|
2386
2580
|
const transientClonedGroup = transientRoot.cloneNode(true);
|
|
2581
|
+
const labelClonedGroup = labelRoot.cloneNode(true);
|
|
2387
2582
|
const transPosition: [number, number] = [
|
|
2388
2583
|
-graphCenterX + halfX,
|
|
2389
2584
|
-graphCenterY + halfY,
|
|
@@ -2391,17 +2586,40 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2391
2586
|
backgroundClonedGroup.setPosition(transPosition);
|
|
2392
2587
|
clonedGroup.setPosition(transPosition);
|
|
2393
2588
|
transientClonedGroup.setPosition(transPosition);
|
|
2589
|
+
|
|
2590
|
+
const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
2591
|
+
const labelTransPosition: [number, number] = [
|
|
2592
|
+
transPosition[0] + currentViewportLTCanvas.x,
|
|
2593
|
+
transPosition[1] + currentViewportLTCanvas.y,
|
|
2594
|
+
];
|
|
2595
|
+
labelClonedGroup.setPosition(labelTransPosition);
|
|
2596
|
+
labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
|
|
2597
|
+
// TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
|
|
2598
|
+
labelClonedGroup.children[0].children.forEach((childGroup) => {
|
|
2599
|
+
childGroup.children.forEach((shape) => {
|
|
2600
|
+
if (
|
|
2601
|
+
shape.getAttribute('data-is-label-background') &&
|
|
2602
|
+
shape.style.transform
|
|
2603
|
+
)
|
|
2604
|
+
shape.remove();
|
|
2605
|
+
});
|
|
2606
|
+
});
|
|
2607
|
+
|
|
2394
2608
|
vCanvas.appendChild(backgroundClonedGroup);
|
|
2395
2609
|
vCanvas.appendChild(clonedGroup);
|
|
2610
|
+
vCanvas.appendChild(labelClonedGroup);
|
|
2396
2611
|
vCanvas.appendChild(transientClonedGroup);
|
|
2397
|
-
vCanvas.render();
|
|
2398
2612
|
|
|
2399
2613
|
if (!type) type = 'image/png';
|
|
2400
2614
|
let dataURL = '';
|
|
2401
|
-
|
|
2402
|
-
|
|
2615
|
+
return new Promise((resolve) => {
|
|
2616
|
+
setTimeout(() => {
|
|
2617
|
+
vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
2618
|
+
dataURL = url;
|
|
2619
|
+
resolve(dataURL);
|
|
2620
|
+
});
|
|
2621
|
+
}, 50);
|
|
2403
2622
|
});
|
|
2404
|
-
return dataURL;
|
|
2405
2623
|
}
|
|
2406
2624
|
|
|
2407
2625
|
/**
|
|
@@ -2544,7 +2762,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2544
2762
|
|
|
2545
2763
|
setTimeout(async () => {
|
|
2546
2764
|
await this.toFullDataURL(type, imageConfig).then((url) => {
|
|
2547
|
-
dataURL = url;
|
|
2765
|
+
dataURL = url as string;
|
|
2548
2766
|
});
|
|
2549
2767
|
if (callback) callback(dataURL);
|
|
2550
2768
|
}, 16);
|
|
@@ -2713,7 +2931,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2713
2931
|
* @returns
|
|
2714
2932
|
* @group Tree
|
|
2715
2933
|
*/
|
|
2716
|
-
public collapse(ids: ID | ID[], disableAnimate = false
|
|
2934
|
+
public collapse(ids: ID | ID[], disableAnimate = false) {
|
|
2717
2935
|
this.hooks.treecollapseexpand.emit({
|
|
2718
2936
|
ids: isArray(ids) ? ids : [ids],
|
|
2719
2937
|
action: 'collapse',
|
|
@@ -2729,7 +2947,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2729
2947
|
* @returns
|
|
2730
2948
|
* @group Tree
|
|
2731
2949
|
*/
|
|
2732
|
-
public expand(ids: ID | ID[], disableAnimate = false
|
|
2950
|
+
public expand(ids: ID | ID[], disableAnimate = false) {
|
|
2733
2951
|
this.hooks.treecollapseexpand.emit({
|
|
2734
2952
|
ids: isArray(ids) ? ids : [ids],
|
|
2735
2953
|
action: 'expand',
|
|
@@ -2744,17 +2962,25 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2744
2962
|
* @group Graph Instance
|
|
2745
2963
|
*/
|
|
2746
2964
|
public destroy(callback?: Function) {
|
|
2747
|
-
|
|
2748
|
-
|
|
2965
|
+
const camera = this.canvas.getCamera();
|
|
2966
|
+
const transientCamera = this.transientCanvas.getCamera();
|
|
2967
|
+
// @ts-ignore
|
|
2968
|
+
if (camera.landmarks?.length) {
|
|
2969
|
+
camera.cancelLandmarkAnimation();
|
|
2970
|
+
transientCamera.cancelLandmarkAnimation();
|
|
2971
|
+
this.emit('cancelviewportanimation');
|
|
2972
|
+
}
|
|
2973
|
+
|
|
2749
2974
|
this.canvas.destroy();
|
|
2975
|
+
this.labelCanvas.destroy();
|
|
2750
2976
|
this.backgroundCanvas.destroy();
|
|
2751
2977
|
this.transientCanvas.destroy();
|
|
2978
|
+
this.transientLabelCanvas.destroy();
|
|
2752
2979
|
|
|
2753
2980
|
// clear history stack
|
|
2754
2981
|
this.cleanHistory();
|
|
2755
2982
|
|
|
2756
2983
|
callback?.();
|
|
2757
|
-
// }, 500);
|
|
2758
2984
|
|
|
2759
2985
|
this.hooks.destroy.emit({});
|
|
2760
2986
|
|
|
@@ -2764,7 +2990,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2764
2990
|
// this.layoutController.destroy();
|
|
2765
2991
|
// this.themeController.destroy();
|
|
2766
2992
|
// this.itemController.destroy();
|
|
2767
|
-
// this.extensionController.destroy();
|
|
2768
2993
|
|
|
2769
2994
|
this.destroyed = true;
|
|
2770
2995
|
}
|