@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/lib/runtime/graph.js
CHANGED
|
@@ -31,10 +31,10 @@ const canvas_1 = require("../util/canvas");
|
|
|
31
31
|
const dom_1 = require("../util/dom");
|
|
32
32
|
const layout_1 = require("../util/layout");
|
|
33
33
|
const shape_1 = require("../util/shape");
|
|
34
|
+
const data_1 = require("../util/data");
|
|
35
|
+
const bbox_1 = require("../util/bbox");
|
|
34
36
|
const controller_1 = require("./controller");
|
|
35
|
-
const plugin_1 = require("./controller/plugin");
|
|
36
37
|
const hooks_1 = __importDefault(require("./hooks"));
|
|
37
|
-
const data_1 = require("../util/data");
|
|
38
38
|
class Graph extends event_emitter_1.default {
|
|
39
39
|
constructor(spec) {
|
|
40
40
|
super();
|
|
@@ -68,7 +68,9 @@ class Graph extends event_emitter_1.default {
|
|
|
68
68
|
canvases: {
|
|
69
69
|
background: this.backgroundCanvas,
|
|
70
70
|
main: this.canvas,
|
|
71
|
+
label: this.labelCanvas,
|
|
71
72
|
transient: this.transientCanvas,
|
|
73
|
+
transientLabel: this.transientLabelCanvas,
|
|
72
74
|
},
|
|
73
75
|
});
|
|
74
76
|
const { data } = spec;
|
|
@@ -85,13 +87,12 @@ class Graph extends event_emitter_1.default {
|
|
|
85
87
|
this.interactionController = new controller_1.InteractionController(this);
|
|
86
88
|
this.layoutController = new controller_1.LayoutController(this);
|
|
87
89
|
this.themeController = new controller_1.ThemeController(this);
|
|
88
|
-
this.itemController = new controller_1.ItemController(this);
|
|
89
90
|
this.viewportController = new controller_1.ViewportController(this);
|
|
90
|
-
this.
|
|
91
|
-
this.pluginController = new
|
|
91
|
+
this.itemController = new controller_1.ItemController(this);
|
|
92
|
+
this.pluginController = new controller_1.PluginController(this);
|
|
92
93
|
}
|
|
93
94
|
initCanvas() {
|
|
94
|
-
const { renderer, container, canvas, backgroundCanvas, transientCanvas, width, height, } = this.specification;
|
|
95
|
+
const { renderer, container, canvas, backgroundCanvas, transientCanvas, transientLabelCanvas, width, height, } = this.specification;
|
|
95
96
|
let pixelRatio;
|
|
96
97
|
if (renderer && !(0, util_1.isString)(renderer)) {
|
|
97
98
|
// @ts-ignore
|
|
@@ -110,6 +111,7 @@ class Graph extends event_emitter_1.default {
|
|
|
110
111
|
this.canvas = canvas;
|
|
111
112
|
this.backgroundCanvas = backgroundCanvas;
|
|
112
113
|
this.transientCanvas = transientCanvas;
|
|
114
|
+
this.transientLabelCanvas = transientLabelCanvas;
|
|
113
115
|
this.container = container;
|
|
114
116
|
}
|
|
115
117
|
else {
|
|
@@ -131,10 +133,24 @@ class Graph extends event_emitter_1.default {
|
|
|
131
133
|
}
|
|
132
134
|
this.backgroundCanvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
133
135
|
this.canvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
136
|
+
this.labelCanvas = (0, canvas_1.createCanvas)('canvas', containerDOM, size[0], size[1], pixelRatio);
|
|
134
137
|
this.transientCanvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
|
|
138
|
+
this.transientLabelCanvas = (0, canvas_1.createCanvas)('canvas', containerDOM, size[0], size[1], pixelRatio);
|
|
135
139
|
}
|
|
136
|
-
Promise.all([
|
|
137
|
-
|
|
140
|
+
Promise.all([
|
|
141
|
+
this.backgroundCanvas,
|
|
142
|
+
this.canvas,
|
|
143
|
+
this.labelCanvas,
|
|
144
|
+
this.transientCanvas,
|
|
145
|
+
this.transientLabelCanvas,
|
|
146
|
+
].map((canvas) => canvas.ready)).then(() => {
|
|
147
|
+
[
|
|
148
|
+
this.backgroundCanvas,
|
|
149
|
+
this.canvas,
|
|
150
|
+
this.labelCanvas,
|
|
151
|
+
this.transientCanvas,
|
|
152
|
+
this.transientLabelCanvas,
|
|
153
|
+
].forEach((canvas, i) => {
|
|
138
154
|
const $domElement = canvas
|
|
139
155
|
.getContextService()
|
|
140
156
|
.getDomElement();
|
|
@@ -286,6 +302,7 @@ class Graph extends event_emitter_1.default {
|
|
|
286
302
|
graphCore: this.dataController.graphCore,
|
|
287
303
|
theme: this.themeController.specification,
|
|
288
304
|
transientCanvas: this.transientCanvas,
|
|
305
|
+
transientLabelCanvas: this.transientLabelCanvas,
|
|
289
306
|
tileOptimize: {
|
|
290
307
|
tileFirstRender,
|
|
291
308
|
tileFirstRenderSize,
|
|
@@ -326,7 +343,13 @@ class Graph extends event_emitter_1.default {
|
|
|
326
343
|
yield emitRender();
|
|
327
344
|
}
|
|
328
345
|
else {
|
|
329
|
-
yield Promise.all([
|
|
346
|
+
yield Promise.all([
|
|
347
|
+
this.backgroundCanvas,
|
|
348
|
+
this.canvas,
|
|
349
|
+
this.labelCanvas,
|
|
350
|
+
this.transientCanvas,
|
|
351
|
+
this.transientLabelCanvas,
|
|
352
|
+
].map((canvas) => canvas.ready));
|
|
330
353
|
yield emitRender();
|
|
331
354
|
}
|
|
332
355
|
});
|
|
@@ -335,10 +358,11 @@ class Graph extends event_emitter_1.default {
|
|
|
335
358
|
* Change graph data.
|
|
336
359
|
* @param data new data
|
|
337
360
|
* @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)
|
|
361
|
+
* @param relayout whether relayout the nodes after data changing
|
|
338
362
|
* @returns
|
|
339
363
|
* @group Data
|
|
340
364
|
*/
|
|
341
|
-
changeData(data, type = 'mergeReplace') {
|
|
365
|
+
changeData(data, type = 'mergeReplace', relayout = true) {
|
|
342
366
|
return __awaiter(this, void 0, void 0, function* () {
|
|
343
367
|
const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
|
|
344
368
|
this.hooks.datachange.emit({ data, type });
|
|
@@ -346,13 +370,16 @@ class Graph extends event_emitter_1.default {
|
|
|
346
370
|
graphCore: this.dataController.graphCore,
|
|
347
371
|
theme: this.themeController.specification,
|
|
348
372
|
transientCanvas: this.transientCanvas,
|
|
373
|
+
transientLabelCanvas: this.transientLabelCanvas,
|
|
349
374
|
tileOptimize: {
|
|
350
375
|
tileFirstRender,
|
|
351
376
|
tileFirstRenderSize,
|
|
352
377
|
},
|
|
353
378
|
});
|
|
354
379
|
this.emit('afterrender');
|
|
355
|
-
|
|
380
|
+
if (relayout) {
|
|
381
|
+
yield this.layout();
|
|
382
|
+
}
|
|
356
383
|
});
|
|
357
384
|
}
|
|
358
385
|
/**
|
|
@@ -505,8 +532,8 @@ class Graph extends event_emitter_1.default {
|
|
|
505
532
|
const { direction = 'both', ratioRule = 'min', boundsType = 'render', onlyOutOfViewport = false, onlyZoomAtLargerThanViewport = false, } = rules || {};
|
|
506
533
|
const { min, max, center: [graphCenterX, graphCenterY], halfExtents, } = boundsType === 'render'
|
|
507
534
|
? // Get the bounds of the whole graph content.
|
|
508
|
-
this.canvas.
|
|
509
|
-
: // Get the
|
|
535
|
+
(0, bbox_1.getCombinedCanvasesBounds)([this.canvas, this.labelCanvas])
|
|
536
|
+
: // Get the b ounds of the nodes positions while the graph content is not ready.
|
|
510
537
|
(0, layout_1.getLayoutBounds)(this);
|
|
511
538
|
const origin = this.canvas.canvas2Viewport({
|
|
512
539
|
x: graphCenterX,
|
|
@@ -566,7 +593,7 @@ class Graph extends event_emitter_1.default {
|
|
|
566
593
|
return __awaiter(this, void 0, void 0, function* () {
|
|
567
594
|
const { center: [graphCenterX, graphCenterY], } = boundsType === 'render'
|
|
568
595
|
? // Get the bounds of the whole graph content.
|
|
569
|
-
this.canvas.
|
|
596
|
+
(0, bbox_1.getCombinedCanvasesBounds)([this.canvas, this.labelCanvas])
|
|
570
597
|
: // Get the bounds of the nodes positions while the graph content is not ready.
|
|
571
598
|
(0, layout_1.getLayoutBounds)(this);
|
|
572
599
|
yield this.translateTo(this.canvas.canvas2Viewport({ x: graphCenterX, y: graphCenterY }), effectTiming);
|
|
@@ -629,9 +656,15 @@ class Graph extends event_emitter_1.default {
|
|
|
629
656
|
this.emit('beforesetsize', { oldSize, size: size });
|
|
630
657
|
this.specification.width = size[0];
|
|
631
658
|
this.specification.height = size[1];
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
659
|
+
[
|
|
660
|
+
this.canvas,
|
|
661
|
+
this.labelCanvas,
|
|
662
|
+
this.transientCanvas,
|
|
663
|
+
this.transientLabelCanvas,
|
|
664
|
+
this.backgroundCanvas,
|
|
665
|
+
].forEach((canvas) => {
|
|
666
|
+
canvas.resize(size[0], size[1]);
|
|
667
|
+
});
|
|
635
668
|
this.emit('aftersetsize', { oldSize, size: size });
|
|
636
669
|
}
|
|
637
670
|
getCanvasRange() {
|
|
@@ -760,6 +793,16 @@ class Graph extends event_emitter_1.default {
|
|
|
760
793
|
getRelatedEdgesData(nodeId, direction = 'both') {
|
|
761
794
|
return this.dataController.findRelatedEdges(nodeId, direction);
|
|
762
795
|
}
|
|
796
|
+
/**
|
|
797
|
+
* Get nearby edges from a start node using quadtree collision detection.
|
|
798
|
+
* @param nodeId id of the start node
|
|
799
|
+
* @returns nearby edges' data array
|
|
800
|
+
*/
|
|
801
|
+
getNearEdgesData(nodeId, shouldBegin) {
|
|
802
|
+
const transientItem = this.itemController.getTransientItem(nodeId);
|
|
803
|
+
const itemMap = this.itemController.getItemMap();
|
|
804
|
+
return this.dataController.findNearEdges(nodeId, itemMap, transientItem, shouldBegin);
|
|
805
|
+
}
|
|
763
806
|
/**
|
|
764
807
|
* Get one-hop node ids from a start node.
|
|
765
808
|
* @param nodeId id of the start node
|
|
@@ -797,15 +840,6 @@ class Graph extends event_emitter_1.default {
|
|
|
797
840
|
getDisplayModel(id) {
|
|
798
841
|
return this.itemController.findDisplayModel(id);
|
|
799
842
|
}
|
|
800
|
-
/**
|
|
801
|
-
* Retrieve the nearby edges for a given node using quadtree collision detection.
|
|
802
|
-
* @param nodeId node id
|
|
803
|
-
* @group Data
|
|
804
|
-
*/
|
|
805
|
-
getNearEdgesForNode(nodeId) {
|
|
806
|
-
const { graphCore } = this.dataController;
|
|
807
|
-
return this.itemController.findNearEdgesByNode(nodeId, graphCore);
|
|
808
|
-
}
|
|
809
843
|
/**
|
|
810
844
|
* Find items which has the state.
|
|
811
845
|
* @param itemType item type
|
|
@@ -837,6 +871,7 @@ class Graph extends event_emitter_1.default {
|
|
|
837
871
|
// data controller and item controller subscribe additem in order
|
|
838
872
|
const { graphCore } = this.dataController;
|
|
839
873
|
const { specification } = this.themeController;
|
|
874
|
+
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
840
875
|
graphCore.once('changed', (event) => {
|
|
841
876
|
if (!event.changes.length)
|
|
842
877
|
return;
|
|
@@ -844,7 +879,7 @@ class Graph extends event_emitter_1.default {
|
|
|
844
879
|
const timingParameters = {
|
|
845
880
|
type: itemType,
|
|
846
881
|
action: 'add',
|
|
847
|
-
models,
|
|
882
|
+
models: modelArr,
|
|
848
883
|
apiName: 'addData',
|
|
849
884
|
changes,
|
|
850
885
|
};
|
|
@@ -857,7 +892,6 @@ class Graph extends event_emitter_1.default {
|
|
|
857
892
|
});
|
|
858
893
|
this.emit('afteritemchange', timingParameters);
|
|
859
894
|
});
|
|
860
|
-
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
861
895
|
const data = { nodes: [], edges: [], combos: [] };
|
|
862
896
|
data[`${itemType}s`] = modelArr;
|
|
863
897
|
this.hooks.datachange.emit({
|
|
@@ -869,7 +903,8 @@ class Graph extends event_emitter_1.default {
|
|
|
869
903
|
}
|
|
870
904
|
/**
|
|
871
905
|
* Remove one or more node/edge/combo data from the graph.
|
|
872
|
-
* @param
|
|
906
|
+
* @param itemType the type the item(s) to be removed.
|
|
907
|
+
* @param id the id or the ids' array of the items to be removed.
|
|
873
908
|
* @returns whether success
|
|
874
909
|
* @group Data
|
|
875
910
|
*/
|
|
@@ -963,8 +998,8 @@ class Graph extends event_emitter_1.default {
|
|
|
963
998
|
}
|
|
964
999
|
/**
|
|
965
1000
|
* Update one or more node/edge/combo data on the graph.
|
|
966
|
-
* @param {ITEM_TYPE} itemType
|
|
967
|
-
* @param models
|
|
1001
|
+
* @param {ITEM_TYPE} itemType the type the item(s) to be udated.
|
|
1002
|
+
* @param models update configs.
|
|
968
1003
|
* @group Data
|
|
969
1004
|
*/
|
|
970
1005
|
updateData(itemType, models) {
|
|
@@ -974,11 +1009,11 @@ class Graph extends event_emitter_1.default {
|
|
|
974
1009
|
const { graphCore } = this.dataController;
|
|
975
1010
|
const { specification } = this.themeController;
|
|
976
1011
|
graphCore.once('changed', (event) => {
|
|
977
|
-
const changes = this.extendChanges((0,
|
|
1012
|
+
const changes = this.extendChanges((0, data_1.cloneJSON)(event.changes));
|
|
978
1013
|
const timingParameters = {
|
|
979
1014
|
type: itemType,
|
|
980
1015
|
action: 'update',
|
|
981
|
-
models,
|
|
1016
|
+
models: modelArr,
|
|
982
1017
|
apiName: 'updateData',
|
|
983
1018
|
changes,
|
|
984
1019
|
};
|
|
@@ -1001,21 +1036,27 @@ class Graph extends event_emitter_1.default {
|
|
|
1001
1036
|
/**
|
|
1002
1037
|
* Update one or more nodes' positions,
|
|
1003
1038
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1004
|
-
* @param models new configurations with x and y for every node, which has id field to indicate the specific item
|
|
1039
|
+
* @param models new configurations with x and y for every node, which has id field to indicate the specific item.
|
|
1040
|
+
* @param upsertAncestors whether update the ancestors in combo tree.
|
|
1041
|
+
* @param disableAnimate whether disable the animation for this call.
|
|
1042
|
+
* @param callback callback function after update nodes done.
|
|
1005
1043
|
* @group Data
|
|
1006
1044
|
*/
|
|
1007
|
-
updateNodePosition(models, upsertAncestors, disableAnimate = false, callback
|
|
1008
|
-
return this.updatePosition('node', models, upsertAncestors, disableAnimate, callback
|
|
1045
|
+
updateNodePosition(models, upsertAncestors, disableAnimate = false, callback) {
|
|
1046
|
+
return this.updatePosition('node', models, upsertAncestors, disableAnimate, callback);
|
|
1009
1047
|
}
|
|
1010
1048
|
/**
|
|
1011
1049
|
* Update one or more combos' positions,
|
|
1012
1050
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1013
1051
|
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1014
|
-
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1052
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
|
|
1053
|
+
* @param upsertAncestors whether update the ancestors in combo tree.
|
|
1054
|
+
* @param disableAnimate whether disable the animation for this call.
|
|
1055
|
+
* @param callback callback function after update combos done.
|
|
1015
1056
|
* @group Data
|
|
1016
1057
|
*/
|
|
1017
|
-
updateComboPosition(models, upsertAncestors, disableAnimate = false, callback
|
|
1018
|
-
return this.updatePosition('combo', models, upsertAncestors, disableAnimate, callback
|
|
1058
|
+
updateComboPosition(models, upsertAncestors, disableAnimate = false, callback) {
|
|
1059
|
+
return this.updatePosition('combo', models, upsertAncestors, disableAnimate, callback);
|
|
1019
1060
|
}
|
|
1020
1061
|
/**
|
|
1021
1062
|
* Get history plugin instance
|
|
@@ -1028,7 +1069,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1028
1069
|
}
|
|
1029
1070
|
return this.pluginController.getPlugin('history');
|
|
1030
1071
|
}
|
|
1031
|
-
updatePosition(type, models, upsertAncestors, disableAnimate = false, callback
|
|
1072
|
+
updatePosition(type, models, upsertAncestors, disableAnimate = false, callback) {
|
|
1032
1073
|
const modelArr = (0, util_1.isArray)(models) ? models : [models];
|
|
1033
1074
|
const { graphCore } = this.dataController;
|
|
1034
1075
|
const { specification } = this.themeController;
|
|
@@ -1040,7 +1081,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1040
1081
|
type,
|
|
1041
1082
|
action: 'updatePosition',
|
|
1042
1083
|
upsertAncestors,
|
|
1043
|
-
models,
|
|
1084
|
+
models: modelArr,
|
|
1044
1085
|
apiName: 'updatePosition',
|
|
1045
1086
|
changes,
|
|
1046
1087
|
};
|
|
@@ -1086,22 +1127,40 @@ class Graph extends event_emitter_1.default {
|
|
|
1086
1127
|
* @returns
|
|
1087
1128
|
* @group Item
|
|
1088
1129
|
*/
|
|
1089
|
-
showItem(ids,
|
|
1130
|
+
showItem(ids, options) {
|
|
1131
|
+
const { disableAnimate = false, shapeIds } = options || {};
|
|
1090
1132
|
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
1091
1133
|
if ((0, util_1.isEmpty)(idArr))
|
|
1092
1134
|
return;
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1135
|
+
let changes;
|
|
1136
|
+
if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
|
|
1137
|
+
const shapeIdsArr = (0, util_1.isArray)(shapeIds) ? shapeIds : [shapeIds];
|
|
1138
|
+
changes = {
|
|
1139
|
+
newValue: [{ ids: idArr, visible: true, shapeIds: shapeIdsArr }],
|
|
1140
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1141
|
+
};
|
|
1142
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1143
|
+
ids: idArr,
|
|
1144
|
+
value: true,
|
|
1145
|
+
graphCore: this.dataController.graphCore,
|
|
1146
|
+
animate: !disableAnimate,
|
|
1147
|
+
shapeIds: shapeIdsArr,
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
else {
|
|
1151
|
+
changes = {
|
|
1152
|
+
newValue: [{ ids: idArr, visible: true }],
|
|
1153
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1154
|
+
};
|
|
1155
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1156
|
+
ids: idArr,
|
|
1157
|
+
value: true,
|
|
1158
|
+
graphCore: this.dataController.graphCore,
|
|
1159
|
+
animate: !disableAnimate,
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1103
1162
|
this.emit('afteritemvisibilitychange', {
|
|
1104
|
-
ids,
|
|
1163
|
+
ids: idArr,
|
|
1105
1164
|
value: true,
|
|
1106
1165
|
animate: !disableAnimate,
|
|
1107
1166
|
action: 'updateVisibility',
|
|
@@ -1111,27 +1170,49 @@ class Graph extends event_emitter_1.default {
|
|
|
1111
1170
|
}
|
|
1112
1171
|
/**
|
|
1113
1172
|
* Hide the item(s).
|
|
1114
|
-
* @param
|
|
1173
|
+
* @param id the id for the item to be hidden.
|
|
1174
|
+
* @param disableAnimate whether disable the hidden animations.
|
|
1175
|
+
* @param keepKeyShape whether keep the keyShape.
|
|
1176
|
+
* @param keepRelated whether keep the related nodes for edge.
|
|
1115
1177
|
* @returns
|
|
1116
1178
|
* @group Item
|
|
1117
1179
|
*/
|
|
1118
|
-
hideItem(ids,
|
|
1180
|
+
hideItem(ids, options) {
|
|
1181
|
+
const { disableAnimate = false, keepKeyShape = false, keepRelated = false, shapeIds, } = options || {};
|
|
1119
1182
|
const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
|
|
1120
1183
|
if ((0, util_1.isEmpty)(idArr))
|
|
1121
1184
|
return;
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1185
|
+
let changes;
|
|
1186
|
+
if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
|
|
1187
|
+
const shapeIdsArr = (0, util_1.isArray)(shapeIds) ? shapeIds : [shapeIds];
|
|
1188
|
+
changes = {
|
|
1189
|
+
newValue: [{ ids: idArr, visible: false, shapeIds: shapeIdsArr }],
|
|
1190
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1191
|
+
};
|
|
1192
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1193
|
+
ids: idArr,
|
|
1194
|
+
value: false,
|
|
1195
|
+
graphCore: this.dataController.graphCore,
|
|
1196
|
+
animate: !disableAnimate,
|
|
1197
|
+
shapeIds: shapeIdsArr,
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
else {
|
|
1201
|
+
changes = {
|
|
1202
|
+
newValue: [{ ids: idArr, visible: false }],
|
|
1203
|
+
oldValue: this.getItemPreviousVisibility(idArr),
|
|
1204
|
+
};
|
|
1205
|
+
this.hooks.itemvisibilitychange.emit({
|
|
1206
|
+
ids: idArr,
|
|
1207
|
+
value: false,
|
|
1208
|
+
graphCore: this.dataController.graphCore,
|
|
1209
|
+
animate: !disableAnimate,
|
|
1210
|
+
keepKeyShape,
|
|
1211
|
+
keepRelated,
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1133
1214
|
this.emit('afteritemvisibilitychange', {
|
|
1134
|
-
ids,
|
|
1215
|
+
ids: idArr,
|
|
1135
1216
|
value: false,
|
|
1136
1217
|
animate: !disableAnimate,
|
|
1137
1218
|
action: 'updateVisibility',
|
|
@@ -1292,11 +1373,20 @@ class Graph extends event_emitter_1.default {
|
|
|
1292
1373
|
getItemVisible(id) {
|
|
1293
1374
|
return this.itemController.getItemVisible(id);
|
|
1294
1375
|
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Get the visible shape ids in a node / edge / combo.
|
|
1378
|
+
* @param id the id for the node / edge / combo
|
|
1379
|
+
* @returns ids of the visible shapes
|
|
1380
|
+
*/
|
|
1381
|
+
getItemVisibleShapeIds(id) {
|
|
1382
|
+
return this.itemController.getItemVisibleShapeIds(id);
|
|
1383
|
+
}
|
|
1295
1384
|
// ===== combo operations =====
|
|
1296
1385
|
/**
|
|
1297
1386
|
* 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.
|
|
1298
1387
|
* Different from addData with combo type, this API update the succeeds' combo tree strucutres in the same time.
|
|
1299
|
-
* @param model combo user data
|
|
1388
|
+
* @param model combo user data.
|
|
1389
|
+
* @param childrenIds the ids of the children nodes / combos to move into the new combo.
|
|
1300
1390
|
* @returns whether success
|
|
1301
1391
|
* @group Combo
|
|
1302
1392
|
*/
|
|
@@ -1338,7 +1428,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1338
1428
|
}
|
|
1339
1429
|
/**
|
|
1340
1430
|
* Collapse a combo.
|
|
1341
|
-
* @param comboId combo ids
|
|
1431
|
+
* @param comboId combo id or ids' array.
|
|
1342
1432
|
* @group Combo
|
|
1343
1433
|
*/
|
|
1344
1434
|
collapseCombo(comboIds) {
|
|
@@ -1355,7 +1445,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1355
1445
|
}
|
|
1356
1446
|
/**
|
|
1357
1447
|
* Expand a combo.
|
|
1358
|
-
* @param
|
|
1448
|
+
* @param comboId combo id or ids' array.
|
|
1359
1449
|
* @group Combo
|
|
1360
1450
|
*/
|
|
1361
1451
|
expandCombo(comboIds) {
|
|
@@ -1374,7 +1464,11 @@ class Graph extends event_emitter_1.default {
|
|
|
1374
1464
|
* Move one or more combos a distance (dx, dy) relatively,
|
|
1375
1465
|
* do not update other styles which leads to better performance than updating positions by updateData.
|
|
1376
1466
|
* In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
|
|
1377
|
-
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item
|
|
1467
|
+
* @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
|
|
1468
|
+
* @param dx the distance alone x-axis to move the combo.
|
|
1469
|
+
* @param dy the distance alone y-axis to move the combo.
|
|
1470
|
+
* @param upsertAncestors whether update the ancestors in the combo tree.
|
|
1471
|
+
* @param callback callback function after move combo done.
|
|
1378
1472
|
* @group Combo
|
|
1379
1473
|
*/
|
|
1380
1474
|
moveCombo(ids, dx, dy, upsertAncestors, callback) {
|
|
@@ -1496,7 +1590,9 @@ class Graph extends event_emitter_1.default {
|
|
|
1496
1590
|
*/
|
|
1497
1591
|
setCursor(cursor) {
|
|
1498
1592
|
this.canvas.setCursor(cursor);
|
|
1593
|
+
this.labelCanvas.setCursor(cursor);
|
|
1499
1594
|
this.transientCanvas.setCursor(cursor);
|
|
1595
|
+
this.transientLabelCanvas.setCursor(cursor);
|
|
1500
1596
|
}
|
|
1501
1597
|
/**
|
|
1502
1598
|
* Add behavior(s) to mode(s).
|
|
@@ -1628,10 +1724,9 @@ class Graph extends event_emitter_1.default {
|
|
|
1628
1724
|
*/
|
|
1629
1725
|
updatePlugin(plugin) {
|
|
1630
1726
|
const { plugins } = this.specification;
|
|
1631
|
-
const { key } = plugin;
|
|
1727
|
+
const { key, type } = plugin;
|
|
1632
1728
|
if (!key) {
|
|
1633
|
-
console.warn(
|
|
1634
|
-
return;
|
|
1729
|
+
console.warn(`The key for the plugin is not found. G6 will update the first plugin with type ${type}`);
|
|
1635
1730
|
}
|
|
1636
1731
|
if (!plugins) {
|
|
1637
1732
|
console.warn('Update plugin failed, the plugin to be updated does not exist.');
|
|
@@ -1639,11 +1734,12 @@ class Graph extends event_emitter_1.default {
|
|
|
1639
1734
|
}
|
|
1640
1735
|
const oldPlugin = plugins === null || plugins === void 0 ? void 0 : plugins.find((p) => {
|
|
1641
1736
|
if (typeof p === 'string')
|
|
1642
|
-
return p === key;
|
|
1643
|
-
return p.key === key
|
|
1737
|
+
return p === key || p === type;
|
|
1738
|
+
return (p.key === key ||
|
|
1739
|
+
p.type === type);
|
|
1644
1740
|
});
|
|
1645
1741
|
if (!oldPlugin) {
|
|
1646
|
-
console.warn(
|
|
1742
|
+
console.warn(`Update plugin failed, the plugin with key ${key} or type ${type} is not found.`);
|
|
1647
1743
|
return;
|
|
1648
1744
|
}
|
|
1649
1745
|
const idx = plugins.indexOf(oldPlugin);
|
|
@@ -1679,45 +1775,62 @@ class Graph extends event_emitter_1.default {
|
|
|
1679
1775
|
*/
|
|
1680
1776
|
toDataURL(type) {
|
|
1681
1777
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1682
|
-
const backgroundCanvas = this
|
|
1683
|
-
const canvas = this.canvas;
|
|
1684
|
-
const transientCanvas = this.transientCanvas;
|
|
1685
|
-
const rendererType = this.rendererType;
|
|
1778
|
+
const { backgroundCanvas, canvas, transientCanvas, labelCanvas, rendererType, } = this;
|
|
1686
1779
|
const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
1687
|
-
const width = this.getSize()
|
|
1688
|
-
const height = this.getSize()[1];
|
|
1780
|
+
const [width, height] = this.getSize();
|
|
1689
1781
|
const vContainerDOM = (0, dom_1.createDOM)('<div id="virtual-image"></div>');
|
|
1782
|
+
const camera = canvas.getCamera();
|
|
1690
1783
|
const vCanvas = (0, canvas_1.createCanvas)(rendererType, vContainerDOM, width, height, pixelRatio);
|
|
1784
|
+
yield vCanvas.ready;
|
|
1785
|
+
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
1786
|
+
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
1787
|
+
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
1788
|
+
const labelClonedGroup = labelCanvas.getRoot().cloneNode(true);
|
|
1789
|
+
const originViewportLTCanvas = vCanvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1790
|
+
const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1791
|
+
labelClonedGroup.translate([
|
|
1792
|
+
currentViewportLTCanvas.x - originViewportLTCanvas.x,
|
|
1793
|
+
currentViewportLTCanvas.y - originViewportLTCanvas.y,
|
|
1794
|
+
]);
|
|
1795
|
+
labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
|
|
1796
|
+
// TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
|
|
1797
|
+
labelClonedGroup.children[0].children.forEach((childGroup) => {
|
|
1798
|
+
childGroup.children.forEach((shape) => {
|
|
1799
|
+
if (shape.getAttribute('data-is-label-background') &&
|
|
1800
|
+
shape.style.transform)
|
|
1801
|
+
shape.remove();
|
|
1802
|
+
});
|
|
1803
|
+
});
|
|
1804
|
+
vCanvas.appendChild(backgroundClonedGroup);
|
|
1805
|
+
vCanvas.appendChild(clonedGroup);
|
|
1806
|
+
vCanvas.appendChild(labelClonedGroup);
|
|
1807
|
+
vCanvas.appendChild(transientClonedGroup);
|
|
1808
|
+
const vCamera = vCanvas.getCamera();
|
|
1809
|
+
vCamera.setZoom(camera.getZoom());
|
|
1810
|
+
vCamera.setPosition(camera.getPosition());
|
|
1811
|
+
vCamera.setFocalPoint(camera.getFocalPoint());
|
|
1691
1812
|
const vCanvasContextService = vCanvas.getContextService();
|
|
1692
1813
|
let bgRect;
|
|
1693
1814
|
if (rendererType !== 'svg') {
|
|
1815
|
+
const backPositionCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1694
1816
|
bgRect = new g_1.Rect({
|
|
1695
|
-
style: {
|
|
1696
|
-
x: 0,
|
|
1697
|
-
y: 0,
|
|
1698
|
-
z: -1,
|
|
1699
|
-
width: vCanvasContextService.getDomElement().width,
|
|
1700
|
-
height: vCanvasContextService.getDomElement().height,
|
|
1817
|
+
style: Object.assign(Object.assign({}, backPositionCanvas), { z: -1, width: vCanvasContextService.getDomElement().width, height: vCanvasContextService.getDomElement().height,
|
|
1701
1818
|
//@ts-ignore
|
|
1702
|
-
fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
|
|
1703
|
-
},
|
|
1819
|
+
fill: backgroundCanvas.getContextService().getDomElement().style['background-color'], zIndex: -10 }),
|
|
1704
1820
|
});
|
|
1705
1821
|
vCanvas.appendChild(bgRect);
|
|
1706
1822
|
}
|
|
1707
|
-
const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
|
|
1708
|
-
const clonedGroup = canvas.getRoot().cloneNode(true);
|
|
1709
|
-
const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
|
|
1710
|
-
vCanvas.appendChild(backgroundClonedGroup);
|
|
1711
|
-
vCanvas.appendChild(clonedGroup);
|
|
1712
|
-
vCanvas.appendChild(transientClonedGroup);
|
|
1713
|
-
vCanvas.render();
|
|
1714
1823
|
if (!type)
|
|
1715
1824
|
type = 'image/png';
|
|
1716
1825
|
let dataURL = '';
|
|
1717
|
-
|
|
1718
|
-
|
|
1826
|
+
return new Promise((resolve) => {
|
|
1827
|
+
setTimeout(() => {
|
|
1828
|
+
vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
1829
|
+
dataURL = url;
|
|
1830
|
+
resolve(dataURL);
|
|
1831
|
+
});
|
|
1832
|
+
}, 50);
|
|
1719
1833
|
});
|
|
1720
|
-
return dataURL;
|
|
1721
1834
|
});
|
|
1722
1835
|
}
|
|
1723
1836
|
/**
|
|
@@ -1729,16 +1842,15 @@ class Graph extends event_emitter_1.default {
|
|
|
1729
1842
|
*/
|
|
1730
1843
|
toFullDataURL(type, imageConfig) {
|
|
1731
1844
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1732
|
-
const backgroundCanvas = this
|
|
1733
|
-
const
|
|
1734
|
-
const transientCanvas = this.transientCanvas;
|
|
1735
|
-
const backgroundRoot = canvas.getRoot();
|
|
1845
|
+
const { backgroundCanvas, canvas, transientCanvas, labelCanvas, rendererType, } = this;
|
|
1846
|
+
const backgroundRoot = backgroundCanvas.getRoot();
|
|
1736
1847
|
const root = canvas.getRoot();
|
|
1737
1848
|
const transientRoot = transientCanvas.getRoot();
|
|
1738
|
-
const
|
|
1739
|
-
const backgroundBBox = backgroundRoot.
|
|
1740
|
-
const BBox = root.
|
|
1741
|
-
const transientBBox = transientRoot.
|
|
1849
|
+
const labelRoot = labelCanvas.getRoot();
|
|
1850
|
+
const backgroundBBox = backgroundRoot.getRenderBounds();
|
|
1851
|
+
const BBox = root.getRenderBounds();
|
|
1852
|
+
const transientBBox = transientRoot.getRenderBounds();
|
|
1853
|
+
const labelBBox = labelRoot.getRenderBounds();
|
|
1742
1854
|
let padding = imageConfig ? imageConfig.padding : undefined;
|
|
1743
1855
|
if (!padding) {
|
|
1744
1856
|
padding = [0, 0, 0, 0];
|
|
@@ -1746,26 +1858,10 @@ class Graph extends event_emitter_1.default {
|
|
|
1746
1858
|
else if ((0, util_1.isNumber)(padding)) {
|
|
1747
1859
|
padding = [padding, padding, padding, padding];
|
|
1748
1860
|
}
|
|
1749
|
-
const left = (transientBBox.
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
: BBox.left) - padding[3];
|
|
1754
|
-
const right = (transientBBox.right
|
|
1755
|
-
? backgroundBBox.right
|
|
1756
|
-
? Math.max(backgroundBBox.right, BBox.right, transientBBox.right)
|
|
1757
|
-
: Math.max(BBox.right, transientBBox.right)
|
|
1758
|
-
: BBox.right) + padding[1];
|
|
1759
|
-
const top = (transientBBox.top
|
|
1760
|
-
? backgroundBBox.top
|
|
1761
|
-
? Math.min(backgroundBBox.top, BBox.top, transientBBox.top)
|
|
1762
|
-
: Math.min(BBox.top, transientBBox.top)
|
|
1763
|
-
: BBox.top) - padding[0];
|
|
1764
|
-
const bottom = (transientBBox.bottom
|
|
1765
|
-
? backgroundBBox.bottom
|
|
1766
|
-
? Math.max(backgroundBBox.bottom, BBox.bottom, transientBBox.bottom)
|
|
1767
|
-
: Math.max(BBox.bottom, transientBBox.bottom)
|
|
1768
|
-
: BBox.bottom) + padding[2];
|
|
1861
|
+
const left = Math.min(backgroundBBox.min[0] || Infinity, BBox.min[0] || Infinity, transientBBox.min[0] || Infinity, labelBBox.min[0] || Infinity) - padding[3];
|
|
1862
|
+
const right = Math.max(backgroundBBox.max[0] || -Infinity, BBox.max[0] || -Infinity, transientBBox.max[0] || -Infinity, labelBBox.max[0] || -Infinity) - padding[1];
|
|
1863
|
+
const top = Math.min(backgroundBBox.min[1] || Infinity, BBox.min[1] || Infinity, transientBBox.min[1] || Infinity, labelBBox.min[1] || Infinity) - padding[0];
|
|
1864
|
+
const bottom = Math.max(backgroundBBox.max[1] || -Infinity, BBox.max[1] || -Infinity, transientBBox.max[1] || -Infinity, labelBBox.max[1] || -Infinity) - padding[2];
|
|
1769
1865
|
const graphCenterX = (left + right) / 2;
|
|
1770
1866
|
const graphCenterY = (top + bottom) / 2;
|
|
1771
1867
|
const halfX = (right - left) / 2;
|
|
@@ -1775,6 +1871,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1775
1871
|
const vHeight = halfY * 2;
|
|
1776
1872
|
const vContainerDOM = (0, dom_1.createDOM)('<div id="virtual-image"></div>');
|
|
1777
1873
|
const vCanvas = (0, canvas_1.createCanvas)(rendererType, vContainerDOM, vWidth, vHeight, pixelRatio);
|
|
1874
|
+
yield vCanvas.ready;
|
|
1778
1875
|
const vCanvasContextService = vCanvas.getContextService();
|
|
1779
1876
|
if (rendererType !== 'svg') {
|
|
1780
1877
|
const bgRect = new g_1.Rect({
|
|
@@ -1793,6 +1890,7 @@ class Graph extends event_emitter_1.default {
|
|
|
1793
1890
|
const backgroundClonedGroup = backgroundRoot.cloneNode(true);
|
|
1794
1891
|
const clonedGroup = root.cloneNode(true);
|
|
1795
1892
|
const transientClonedGroup = transientRoot.cloneNode(true);
|
|
1893
|
+
const labelClonedGroup = labelRoot.cloneNode(true);
|
|
1796
1894
|
const transPosition = [
|
|
1797
1895
|
-graphCenterX + halfX,
|
|
1798
1896
|
-graphCenterY + halfY,
|
|
@@ -1800,17 +1898,36 @@ class Graph extends event_emitter_1.default {
|
|
|
1800
1898
|
backgroundClonedGroup.setPosition(transPosition);
|
|
1801
1899
|
clonedGroup.setPosition(transPosition);
|
|
1802
1900
|
transientClonedGroup.setPosition(transPosition);
|
|
1901
|
+
const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
|
|
1902
|
+
const labelTransPosition = [
|
|
1903
|
+
transPosition[0] + currentViewportLTCanvas.x,
|
|
1904
|
+
transPosition[1] + currentViewportLTCanvas.y,
|
|
1905
|
+
];
|
|
1906
|
+
labelClonedGroup.setPosition(labelTransPosition);
|
|
1907
|
+
labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
|
|
1908
|
+
// TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
|
|
1909
|
+
labelClonedGroup.children[0].children.forEach((childGroup) => {
|
|
1910
|
+
childGroup.children.forEach((shape) => {
|
|
1911
|
+
if (shape.getAttribute('data-is-label-background') &&
|
|
1912
|
+
shape.style.transform)
|
|
1913
|
+
shape.remove();
|
|
1914
|
+
});
|
|
1915
|
+
});
|
|
1803
1916
|
vCanvas.appendChild(backgroundClonedGroup);
|
|
1804
1917
|
vCanvas.appendChild(clonedGroup);
|
|
1918
|
+
vCanvas.appendChild(labelClonedGroup);
|
|
1805
1919
|
vCanvas.appendChild(transientClonedGroup);
|
|
1806
|
-
vCanvas.render();
|
|
1807
1920
|
if (!type)
|
|
1808
1921
|
type = 'image/png';
|
|
1809
1922
|
let dataURL = '';
|
|
1810
|
-
|
|
1811
|
-
|
|
1923
|
+
return new Promise((resolve) => {
|
|
1924
|
+
setTimeout(() => {
|
|
1925
|
+
vCanvasContextService.toDataURL({ type }).then((url) => {
|
|
1926
|
+
dataURL = url;
|
|
1927
|
+
resolve(dataURL);
|
|
1928
|
+
});
|
|
1929
|
+
}, 50);
|
|
1812
1930
|
});
|
|
1813
|
-
return dataURL;
|
|
1814
1931
|
});
|
|
1815
1932
|
}
|
|
1816
1933
|
/**
|
|
@@ -2072,7 +2189,7 @@ class Graph extends event_emitter_1.default {
|
|
|
2072
2189
|
* @returns
|
|
2073
2190
|
* @group Tree
|
|
2074
2191
|
*/
|
|
2075
|
-
collapse(ids, disableAnimate = false
|
|
2192
|
+
collapse(ids, disableAnimate = false) {
|
|
2076
2193
|
this.hooks.treecollapseexpand.emit({
|
|
2077
2194
|
ids: (0, util_1.isArray)(ids) ? ids : [ids],
|
|
2078
2195
|
action: 'collapse',
|
|
@@ -2088,7 +2205,7 @@ class Graph extends event_emitter_1.default {
|
|
|
2088
2205
|
* @returns
|
|
2089
2206
|
* @group Tree
|
|
2090
2207
|
*/
|
|
2091
|
-
expand(ids, disableAnimate = false
|
|
2208
|
+
expand(ids, disableAnimate = false) {
|
|
2092
2209
|
this.hooks.treecollapseexpand.emit({
|
|
2093
2210
|
ids: (0, util_1.isArray)(ids) ? ids : [ids],
|
|
2094
2211
|
action: 'expand',
|
|
@@ -2102,15 +2219,23 @@ class Graph extends event_emitter_1.default {
|
|
|
2102
2219
|
* @group Graph Instance
|
|
2103
2220
|
*/
|
|
2104
2221
|
destroy(callback) {
|
|
2105
|
-
|
|
2106
|
-
|
|
2222
|
+
var _a;
|
|
2223
|
+
const camera = this.canvas.getCamera();
|
|
2224
|
+
const transientCamera = this.transientCanvas.getCamera();
|
|
2225
|
+
// @ts-ignore
|
|
2226
|
+
if ((_a = camera.landmarks) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2227
|
+
camera.cancelLandmarkAnimation();
|
|
2228
|
+
transientCamera.cancelLandmarkAnimation();
|
|
2229
|
+
this.emit('cancelviewportanimation');
|
|
2230
|
+
}
|
|
2107
2231
|
this.canvas.destroy();
|
|
2232
|
+
this.labelCanvas.destroy();
|
|
2108
2233
|
this.backgroundCanvas.destroy();
|
|
2109
2234
|
this.transientCanvas.destroy();
|
|
2235
|
+
this.transientLabelCanvas.destroy();
|
|
2110
2236
|
// clear history stack
|
|
2111
2237
|
this.cleanHistory();
|
|
2112
2238
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
2113
|
-
// }, 500);
|
|
2114
2239
|
this.hooks.destroy.emit({});
|
|
2115
2240
|
// TODO: destroy controllers and off the listeners
|
|
2116
2241
|
// this.dataController.destroy();
|
|
@@ -2118,7 +2243,6 @@ class Graph extends event_emitter_1.default {
|
|
|
2118
2243
|
// this.layoutController.destroy();
|
|
2119
2244
|
// this.themeController.destroy();
|
|
2120
2245
|
// this.itemController.destroy();
|
|
2121
|
-
// this.extensionController.destroy();
|
|
2122
2246
|
this.destroyed = true;
|
|
2123
2247
|
}
|
|
2124
2248
|
}
|