vue3-network-graph 0.2.2 → 0.2.4
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/README.en.md +741 -728
- package/README.md +742 -728
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +1269 -864
- package/dist/index.umd.cjs +5 -5
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -1,728 +1,741 @@
|
|
|
1
|
-
# vue3-network-graph Usage Guide
|
|
2
|
-
|
|
3
|
-
A lightweight network topology component based on **Vue 3 + SVG** with no third-party chart library dependencies. Supports node dragging, infinite canvas panning, zoom wheel, connection flow animations, three connection modes, multi-line overlap prevention for the same node pairs, and upright connection text along paths.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Table of Contents
|
|
8
|
-
|
|
9
|
-
- [Name](#name)
|
|
10
|
-
- [Description](#description)
|
|
11
|
-
- [Usage](#usage)
|
|
12
|
-
- [Examples](#examples)
|
|
13
|
-
- [Global Configuration Properties](#global-configuration-properties)
|
|
14
|
-
- [Node Properties](#node-properties)
|
|
15
|
-
- [Connection Properties](#connection-properties)
|
|
16
|
-
- [API Methods](#api-methods)
|
|
17
|
-
- [Events](#events)
|
|
18
|
-
- [Interactions](#interactions)
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Name
|
|
23
|
-
|
|
24
|
-
**vue3-network-graph** - Vue3 Network Topology Component
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## Description
|
|
29
|
-
|
|
30
|
-
A lightweight network topology component implemented with pure SVG, providing the following core capabilities:
|
|
31
|
-
|
|
32
|
-
### Core Features
|
|
33
|
-
|
|
34
|
-
- **Multiple Connection Modes**: Straight (straight) / Polyline (polyline) / Curve (curve)
|
|
35
|
-
- **Smart Multi-line Handling**: Multiple connections between the same pair of nodes automatically prevent overlap, staying parallel in any mode
|
|
36
|
-
- **Upright Connection Text**: `fromText` / `centerText` / `toText` rotate along the path tangentially, automatically flipping when exceeding ±90° to maintain readability
|
|
37
|
-
- **Rich Node Types**: 8 icon nodes + text nodes + border-only nodes
|
|
38
|
-
- **Image Nodes**: photo / avatar / bitmap nodes, fitted at their real aspect ratio (fully contained or cover-cropped, never stretched)
|
|
39
|
-
- **2D/3D Views**: Supports both 2D plane and 2.5D card styles
|
|
40
|
-
- **Flow Animations**: Dashed流光 + particle effects, with per-connection animation control
|
|
41
|
-
- **Edges never get swallowed**: nodes are painted in two passes (plate below, icon / label above), so a line crossing a node — or two overlapping nodes — stays visible; the selected path is promoted to the very top
|
|
42
|
-
|
|
43
|
-
### Interaction Capabilities
|
|
44
|
-
|
|
45
|
-
- **Node Operations**: Drag to move, drag to resize, multi-select overall drag
|
|
46
|
-
- **Canvas Operations**: Infinite panning (blank left-click/middle-click), zoom wheel (0.2x–5x)
|
|
47
|
-
- **Selection Modes**: Single-click select, Ctrl+click multi-select, Ctrl+left-drag box select
|
|
48
|
-
- **Connection Creation**: Auto-connect by dragging from node handle to target node
|
|
49
|
-
- **Layer Management**: Z-axis sorting, right-click menu, keyboard shortcuts (requires `enableZOrder`)
|
|
50
|
-
|
|
51
|
-
### Performance Optimization
|
|
52
|
-
|
|
53
|
-
- **Automatic Degradation**: Decorative animations automatically disabled based on scale (connections>200 disable流光,>500 disable glow, nodes>300 disable breathing)
|
|
54
|
-
- **Large-scale Performance**: Thousands of nodes can pan/drag smoothly, nodes always responsive to clicks in dense graphics
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Usage
|
|
59
|
-
|
|
60
|
-
### 1. Installation
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
npm install vue3-network-graph
|
|
64
|
-
# or: pnpm add vue3-network-graph | yarn add vue3-network-graph
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### 2. Import Component
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
// main.js
|
|
71
|
-
import { createApp } from "vue";
|
|
72
|
-
import { Topology } from "vue3-network-graph";
|
|
73
|
-
import "vue3-network-graph/style.css";
|
|
74
|
-
|
|
75
|
-
const app = createApp(App);
|
|
76
|
-
app.component("Topology", Topology);
|
|
77
|
-
app.mount("#app");
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Or local import:
|
|
81
|
-
|
|
82
|
-
```vue
|
|
83
|
-
<script setup>
|
|
84
|
-
import { Topology } from "vue3-network-graph";
|
|
85
|
-
import "vue3-network-graph/style.css";
|
|
86
|
-
</script>
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### 3. Basic Usage
|
|
90
|
-
|
|
91
|
-
```vue
|
|
92
|
-
<template>
|
|
93
|
-
<Topology
|
|
94
|
-
ref="topoRef"
|
|
95
|
-
:editable="true"
|
|
96
|
-
v-model:nodes="myNodes"
|
|
97
|
-
v-model:edges="myEdges"
|
|
98
|
-
:config="config"
|
|
99
|
-
@node-click="handleNodeClick"
|
|
100
|
-
@selection-change="handleSelectionChange"
|
|
101
|
-
/>
|
|
102
|
-
</template>
|
|
103
|
-
|
|
104
|
-
<script setup>
|
|
105
|
-
import { ref } from "vue";
|
|
106
|
-
import { Topology } from "vue3-network-graph";
|
|
107
|
-
|
|
108
|
-
const myNodes = ref([
|
|
109
|
-
{ id: "node1", label: "Node 1", type: "core", state: "normal", x: 0, y: 0 },
|
|
110
|
-
{
|
|
111
|
-
id: "node2",
|
|
112
|
-
label: "Node 2",
|
|
113
|
-
type: "server",
|
|
114
|
-
state: "normal",
|
|
115
|
-
x: 200,
|
|
116
|
-
y: 100,
|
|
117
|
-
},
|
|
118
|
-
]);
|
|
119
|
-
|
|
120
|
-
const myEdges = ref([
|
|
121
|
-
{ id: "edge1", from: "node1", to: "node2", centerText: "Connection" },
|
|
122
|
-
]);
|
|
123
|
-
|
|
124
|
-
const config = ref({
|
|
125
|
-
showGrid: true,
|
|
126
|
-
nodeDraggable: true,
|
|
127
|
-
nodeResizable: true,
|
|
128
|
-
});
|
|
129
|
-
</script>
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## Examples
|
|
135
|
-
|
|
136
|
-
### Complete Example
|
|
137
|
-
|
|
138
|
-
```vue
|
|
139
|
-
<template>
|
|
140
|
-
<div class="topology-container">
|
|
141
|
-
<Topology
|
|
142
|
-
ref="topoRef"
|
|
143
|
-
:editable="true"
|
|
144
|
-
v-model:nodes="nodes"
|
|
145
|
-
v-model:edges="edges"
|
|
146
|
-
v-model:line-mode="lineMode"
|
|
147
|
-
v-model:view-mode="viewMode"
|
|
148
|
-
:groups="groups"
|
|
149
|
-
:config="config"
|
|
150
|
-
@node-click="onNodeClick"
|
|
151
|
-
@edge-select="onEdgeSelect"
|
|
152
|
-
@selection-change="onSelectionChange"
|
|
153
|
-
@data-change="onDataChange"
|
|
154
|
-
@edge-create="onEdgeCreate"
|
|
155
|
-
>
|
|
156
|
-
<!-- Custom node icon slot -->
|
|
157
|
-
<template #node-icon="{ node, color, viewMode }">
|
|
158
|
-
<circle r="16" :fill="color" opacity="0.9" />
|
|
159
|
-
</template>
|
|
160
|
-
</Topology>
|
|
161
|
-
</div>
|
|
162
|
-
</template>
|
|
163
|
-
|
|
164
|
-
<script setup>
|
|
165
|
-
import { ref, onMounted } from "vue";
|
|
166
|
-
import { Topology } from "vue3-network-graph";
|
|
167
|
-
import "vue3-network-graph/style.css";
|
|
168
|
-
|
|
169
|
-
// Node data
|
|
170
|
-
const nodes = ref([
|
|
171
|
-
{
|
|
172
|
-
id: "core",
|
|
173
|
-
label: "Core Switch",
|
|
174
|
-
nodeType: "core",
|
|
175
|
-
state: "normal",
|
|
176
|
-
x: 0,
|
|
177
|
-
y: 0,
|
|
178
|
-
width: 80,
|
|
179
|
-
height: 80,
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
id: "server1",
|
|
183
|
-
label: "Web Server",
|
|
184
|
-
nodeType: "server",
|
|
185
|
-
state: "normal",
|
|
186
|
-
x: 300,
|
|
187
|
-
y: -150,
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
id: "db1",
|
|
191
|
-
label: "Database",
|
|
192
|
-
nodeType: "database",
|
|
193
|
-
state: "idle",
|
|
194
|
-
x: 300,
|
|
195
|
-
y: 150,
|
|
196
|
-
},
|
|
197
|
-
// Border-only node example
|
|
198
|
-
{
|
|
199
|
-
id: "border-box",
|
|
200
|
-
label: "",
|
|
201
|
-
nodeType: "border-only",
|
|
202
|
-
state: "none",
|
|
203
|
-
x: -400,
|
|
204
|
-
y: -200,
|
|
205
|
-
width: 250,
|
|
206
|
-
height: 150,
|
|
207
|
-
borderWidth: 2,
|
|
208
|
-
borderColor: "#00f0ff",
|
|
209
|
-
},
|
|
210
|
-
]);
|
|
211
|
-
|
|
212
|
-
// Connection data
|
|
213
|
-
const edges = ref([
|
|
214
|
-
{ id: "e1", from: "core", to: "server1", speed: 1.5, endMarker: "arrow" },
|
|
215
|
-
{
|
|
216
|
-
id: "e2",
|
|
217
|
-
from: "core",
|
|
218
|
-
to: "db1",
|
|
219
|
-
speed: 2,
|
|
220
|
-
centerText: "Query Traffic",
|
|
221
|
-
endMarker: "arrow",
|
|
222
|
-
},
|
|
223
|
-
]);
|
|
224
|
-
|
|
225
|
-
// Group example
|
|
226
|
-
const groups = ref([
|
|
227
|
-
{
|
|
228
|
-
id: "g1",
|
|
229
|
-
label: "Application Zone",
|
|
230
|
-
color: "#409eff",
|
|
231
|
-
nodeIds: ["server1", "db1"],
|
|
232
|
-
padding: 20,
|
|
233
|
-
},
|
|
234
|
-
]);
|
|
235
|
-
|
|
236
|
-
// Connection mode and view mode
|
|
237
|
-
const lineMode = ref("curve"); // straight | polyline | curve
|
|
238
|
-
const viewMode = ref("2d"); // 2d | 3d
|
|
239
|
-
|
|
240
|
-
// Configuration
|
|
241
|
-
const config = ref({
|
|
242
|
-
selectedBorderColor: "#ffd400",
|
|
243
|
-
selectedLineColor: "#ffd400",
|
|
244
|
-
nodeDraggable: true,
|
|
245
|
-
nodeResizable: true,
|
|
246
|
-
enableZoom: true,
|
|
247
|
-
enablePan: true,
|
|
248
|
-
enableMarquee: true,
|
|
249
|
-
showGrid: true,
|
|
250
|
-
gridColor: "#1a2240",
|
|
251
|
-
gridStep: 40,
|
|
252
|
-
gridOpacity: 0.5,
|
|
253
|
-
radialGradient: {
|
|
254
|
-
startColor: "#0f1729",
|
|
255
|
-
endColor: "#060a14",
|
|
256
|
-
},
|
|
257
|
-
showStatusDot: true,
|
|
258
|
-
motionFx: true,
|
|
259
|
-
maxSelectNodes: "unlimited",
|
|
260
|
-
maxSelectEdges: "unlimited",
|
|
261
|
-
enableZOrder: false,
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
// Component instance reference
|
|
265
|
-
const topoRef = ref(null);
|
|
266
|
-
|
|
267
|
-
// Event handlers
|
|
268
|
-
const onNodeClick = (node) => {
|
|
269
|
-
console.log("Node clicked:", node);
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
const onEdgeSelect = (edge) => {
|
|
273
|
-
console.log("Connection selected:", edge);
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
const onSelectionChange = (selection) => {
|
|
277
|
-
console.log("Selection changed:", selection);
|
|
278
|
-
console.log("Selected nodes:", selection.nodes);
|
|
279
|
-
console.log("Selected connections:", selection.edges);
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
const onDataChange = (payload) => {
|
|
283
|
-
console.log("Data changed:", payload);
|
|
284
|
-
console.log("Change summary:", payload.summary);
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
const onEdgeCreate = (edge) => {
|
|
288
|
-
console.log("New connection:", edge);
|
|
289
|
-
// Persist newly created connection
|
|
290
|
-
edges.value = [...edges.value, edge];
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
// Method call examples
|
|
294
|
-
const handleMethods = () => {
|
|
295
|
-
// Get current data
|
|
296
|
-
const data = topoRef.value.getData();
|
|
297
|
-
|
|
298
|
-
// Add nodes
|
|
299
|
-
topoRef.value.addNodes([
|
|
300
|
-
{ label: "New Node", nodeType: "server", x: 500, y: 0 },
|
|
301
|
-
]);
|
|
302
|
-
|
|
303
|
-
// Add connections
|
|
304
|
-
topoRef.value.addEdges([{ from: "core", to: "new-node-id" }]);
|
|
305
|
-
|
|
306
|
-
// Update nodes
|
|
307
|
-
topoRef.value.updateNodes([{ id: "core", label: "Updated Name" }]);
|
|
308
|
-
|
|
309
|
-
// Delete selected elements
|
|
310
|
-
topoRef.value.removeSelected();
|
|
311
|
-
|
|
312
|
-
// Coordinate conversion
|
|
313
|
-
const svgPos = topoRef.value.clientToSvg(event);
|
|
314
|
-
const clientPos = topoRef.value.svgToClient(node.x, node.y);
|
|
315
|
-
|
|
316
|
-
// Layer management (requires enableZOrder)
|
|
317
|
-
topoRef.value.moveToFront("node-id");
|
|
318
|
-
topoRef.value.moveToBack("node-id");
|
|
319
|
-
topoRef.value.moveLayerUp("node-id");
|
|
320
|
-
topoRef.value.moveLayerDown("node-id");
|
|
321
|
-
};
|
|
322
|
-
</script>
|
|
323
|
-
|
|
324
|
-
<style scoped>
|
|
325
|
-
.topology-container {
|
|
326
|
-
width: 100%;
|
|
327
|
-
height: 600px;
|
|
328
|
-
background: radial-gradient(ellipse at center, #0f1729 0%, #060a14 100%);
|
|
329
|
-
}
|
|
330
|
-
</style>
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
---
|
|
334
|
-
|
|
335
|
-
## Global Configuration Properties
|
|
336
|
-
|
|
337
|
-
| Config Item | Type | Default | Description |
|
|
338
|
-
| --------------------- | ----------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
339
|
-
| `selectedBorderColor` | `String` | `#fbbf24` | Selected node border color |
|
|
340
|
-
| `selectedLineColor` | `String` | `#fbbf24` | Selected connection color |
|
|
341
|
-
| `nodeDraggable` | `Boolean` | `true` | Node drag switch (requires `editable`) |
|
|
342
|
-
| `nodeResizable` | `Boolean` | `true` | Node resize switch (requires `editable`) |
|
|
343
|
-
| `enableZoom` | `Boolean` | `true` | Zoom wheel switch |
|
|
344
|
-
| `enablePan` | `Boolean` | `true` | Canvas pan switch |
|
|
345
|
-
| `enableMarquee` | `Boolean` | `true` | Ctrl + left-drag box select switch |
|
|
346
|
-
| `maxSelectNodes` | `Number \| "unlimited"` | Unlimited | Max selectable nodes: `0` (disabled) / `1` / `2` or any non-negative integer; unset or `"unlimited"` no limit |
|
|
347
|
-
| `maxSelectEdges` | `Number \| "unlimited"` | Unlimited | Max selectable connections (merged bundles count all connections in group) |
|
|
348
|
-
| `showGrid` | `Boolean` | `true` | Grid background (set `false` to disable) |
|
|
349
|
-
| `gridColor` | `String` | `#1a2240` | Grid line color |
|
|
350
|
-
| `gridStep` | `Number` | `40` | Grid spacing (px at 1x zoom, scales with zoom) |
|
|
351
|
-
| `gridOpacity` | `Number` | `0.5` | Grid overlay opacity (0–1) |
|
|
352
|
-
| `radialGradient` | `Object` | See notes | Canvas background radial gradient |
|
|
353
|
-
| `showCenterPoint` | `Boolean` | `false` | Canvas center cross marker |
|
|
354
|
-
| `showEdgeTextBg` | `Boolean` | `false` | Connection text background |
|
|
355
|
-
| `edgeTextBgColor` | `String` | `#0a0e1a` | Connection text background color |
|
|
356
|
-
| `edgeCenterTextFollowLine` | `Boolean` | `true` | Whether the center label rotates along the line: `true` follows the line tangent (current), `false` always stays horizontal |
|
|
357
|
-
| `
|
|
358
|
-
| `
|
|
359
|
-
| `
|
|
360
|
-
| `
|
|
361
|
-
| `
|
|
362
|
-
| `
|
|
363
|
-
| `
|
|
364
|
-
| `
|
|
365
|
-
| `
|
|
366
|
-
| `
|
|
367
|
-
| `
|
|
368
|
-
| `
|
|
369
|
-
| `
|
|
370
|
-
| `
|
|
371
|
-
| `
|
|
372
|
-
| `
|
|
373
|
-
| `
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
radialGradient
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
|
412
|
-
|
|
|
413
|
-
| `
|
|
414
|
-
| `
|
|
415
|
-
| `
|
|
416
|
-
| `
|
|
417
|
-
| `
|
|
418
|
-
| `
|
|
419
|
-
| `
|
|
420
|
-
| `
|
|
421
|
-
| `
|
|
422
|
-
| `
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
|
427
|
-
|
|
|
428
|
-
| `
|
|
429
|
-
| `"
|
|
430
|
-
| `
|
|
431
|
-
| `
|
|
432
|
-
| `"
|
|
433
|
-
| `
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
|
446
|
-
|
|
|
447
|
-
| `
|
|
448
|
-
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
|
458
|
-
|
|
|
459
|
-
| `
|
|
460
|
-
| `
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
|
469
|
-
|
|
|
470
|
-
| `
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
|
501
|
-
|
|
|
502
|
-
| `"
|
|
503
|
-
| `"
|
|
504
|
-
| `"
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
|
511
|
-
|
|
|
512
|
-
| `
|
|
513
|
-
| `
|
|
514
|
-
| `
|
|
515
|
-
| `
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
|
522
|
-
|
|
|
523
|
-
| `
|
|
524
|
-
| `
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
fromText
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
|
632
|
-
|
|
|
633
|
-
| `
|
|
634
|
-
| `
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
|
670
|
-
|
|
|
671
|
-
|
|
|
672
|
-
|
|
|
673
|
-
|
|
|
674
|
-
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
1
|
+
# vue3-network-graph Usage Guide
|
|
2
|
+
|
|
3
|
+
A lightweight network topology component based on **Vue 3 + SVG** with no third-party chart library dependencies. Supports node dragging, infinite canvas panning, zoom wheel, connection flow animations, three connection modes, multi-line overlap prevention for the same node pairs, and upright connection text along paths.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Name](#name)
|
|
10
|
+
- [Description](#description)
|
|
11
|
+
- [Usage](#usage)
|
|
12
|
+
- [Examples](#examples)
|
|
13
|
+
- [Global Configuration Properties](#global-configuration-properties)
|
|
14
|
+
- [Node Properties](#node-properties)
|
|
15
|
+
- [Connection Properties](#connection-properties)
|
|
16
|
+
- [API Methods](#api-methods)
|
|
17
|
+
- [Events](#events)
|
|
18
|
+
- [Interactions](#interactions)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Name
|
|
23
|
+
|
|
24
|
+
**vue3-network-graph** - Vue3 Network Topology Component
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Description
|
|
29
|
+
|
|
30
|
+
A lightweight network topology component implemented with pure SVG, providing the following core capabilities:
|
|
31
|
+
|
|
32
|
+
### Core Features
|
|
33
|
+
|
|
34
|
+
- **Multiple Connection Modes**: Straight (straight) / Polyline (polyline) / Curve (curve)
|
|
35
|
+
- **Smart Multi-line Handling**: Multiple connections between the same pair of nodes automatically prevent overlap, staying parallel in any mode
|
|
36
|
+
- **Upright Connection Text**: `fromText` / `centerText` / `toText` rotate along the path tangentially, automatically flipping when exceeding ±90° to maintain readability
|
|
37
|
+
- **Rich Node Types**: 8 icon nodes + text nodes + border-only nodes
|
|
38
|
+
- **Image Nodes**: photo / avatar / bitmap nodes, fitted at their real aspect ratio (fully contained or cover-cropped, never stretched)
|
|
39
|
+
- **2D/3D Views**: Supports both 2D plane and 2.5D card styles
|
|
40
|
+
- **Flow Animations**: Dashed流光 + particle effects, with per-connection animation control
|
|
41
|
+
- **Edges never get swallowed**: nodes are painted in two passes (plate below, icon / label above), so a line crossing a node — or two overlapping nodes — stays visible; the selected path is promoted to the very top
|
|
42
|
+
|
|
43
|
+
### Interaction Capabilities
|
|
44
|
+
|
|
45
|
+
- **Node Operations**: Drag to move, drag to resize, multi-select overall drag
|
|
46
|
+
- **Canvas Operations**: Infinite panning (blank left-click/middle-click), zoom wheel (0.2x–5x)
|
|
47
|
+
- **Selection Modes**: Single-click select, Ctrl+click multi-select, Ctrl+left-drag box select
|
|
48
|
+
- **Connection Creation**: Auto-connect by dragging from node handle to target node
|
|
49
|
+
- **Layer Management**: Z-axis sorting, right-click menu, keyboard shortcuts (requires `enableZOrder`)
|
|
50
|
+
|
|
51
|
+
### Performance Optimization
|
|
52
|
+
|
|
53
|
+
- **Automatic Degradation**: Decorative animations automatically disabled based on scale (connections>200 disable流光,>500 disable glow, nodes>300 disable breathing)
|
|
54
|
+
- **Large-scale Performance**: Thousands of nodes can pan/drag smoothly, nodes always responsive to clicks in dense graphics
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
### 1. Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install vue3-network-graph
|
|
64
|
+
# or: pnpm add vue3-network-graph | yarn add vue3-network-graph
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 2. Import Component
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
// main.js
|
|
71
|
+
import { createApp } from "vue";
|
|
72
|
+
import { Topology } from "vue3-network-graph";
|
|
73
|
+
import "vue3-network-graph/style.css";
|
|
74
|
+
|
|
75
|
+
const app = createApp(App);
|
|
76
|
+
app.component("Topology", Topology);
|
|
77
|
+
app.mount("#app");
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Or local import:
|
|
81
|
+
|
|
82
|
+
```vue
|
|
83
|
+
<script setup>
|
|
84
|
+
import { Topology } from "vue3-network-graph";
|
|
85
|
+
import "vue3-network-graph/style.css";
|
|
86
|
+
</script>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 3. Basic Usage
|
|
90
|
+
|
|
91
|
+
```vue
|
|
92
|
+
<template>
|
|
93
|
+
<Topology
|
|
94
|
+
ref="topoRef"
|
|
95
|
+
:editable="true"
|
|
96
|
+
v-model:nodes="myNodes"
|
|
97
|
+
v-model:edges="myEdges"
|
|
98
|
+
:config="config"
|
|
99
|
+
@node-click="handleNodeClick"
|
|
100
|
+
@selection-change="handleSelectionChange"
|
|
101
|
+
/>
|
|
102
|
+
</template>
|
|
103
|
+
|
|
104
|
+
<script setup>
|
|
105
|
+
import { ref } from "vue";
|
|
106
|
+
import { Topology } from "vue3-network-graph";
|
|
107
|
+
|
|
108
|
+
const myNodes = ref([
|
|
109
|
+
{ id: "node1", label: "Node 1", type: "core", state: "normal", x: 0, y: 0 },
|
|
110
|
+
{
|
|
111
|
+
id: "node2",
|
|
112
|
+
label: "Node 2",
|
|
113
|
+
type: "server",
|
|
114
|
+
state: "normal",
|
|
115
|
+
x: 200,
|
|
116
|
+
y: 100,
|
|
117
|
+
},
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
const myEdges = ref([
|
|
121
|
+
{ id: "edge1", from: "node1", to: "node2", centerText: "Connection" },
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
const config = ref({
|
|
125
|
+
showGrid: true,
|
|
126
|
+
nodeDraggable: true,
|
|
127
|
+
nodeResizable: true,
|
|
128
|
+
});
|
|
129
|
+
</script>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Examples
|
|
135
|
+
|
|
136
|
+
### Complete Example
|
|
137
|
+
|
|
138
|
+
```vue
|
|
139
|
+
<template>
|
|
140
|
+
<div class="topology-container">
|
|
141
|
+
<Topology
|
|
142
|
+
ref="topoRef"
|
|
143
|
+
:editable="true"
|
|
144
|
+
v-model:nodes="nodes"
|
|
145
|
+
v-model:edges="edges"
|
|
146
|
+
v-model:line-mode="lineMode"
|
|
147
|
+
v-model:view-mode="viewMode"
|
|
148
|
+
:groups="groups"
|
|
149
|
+
:config="config"
|
|
150
|
+
@node-click="onNodeClick"
|
|
151
|
+
@edge-select="onEdgeSelect"
|
|
152
|
+
@selection-change="onSelectionChange"
|
|
153
|
+
@data-change="onDataChange"
|
|
154
|
+
@edge-create="onEdgeCreate"
|
|
155
|
+
>
|
|
156
|
+
<!-- Custom node icon slot -->
|
|
157
|
+
<template #node-icon="{ node, color, viewMode }">
|
|
158
|
+
<circle r="16" :fill="color" opacity="0.9" />
|
|
159
|
+
</template>
|
|
160
|
+
</Topology>
|
|
161
|
+
</div>
|
|
162
|
+
</template>
|
|
163
|
+
|
|
164
|
+
<script setup>
|
|
165
|
+
import { ref, onMounted } from "vue";
|
|
166
|
+
import { Topology } from "vue3-network-graph";
|
|
167
|
+
import "vue3-network-graph/style.css";
|
|
168
|
+
|
|
169
|
+
// Node data
|
|
170
|
+
const nodes = ref([
|
|
171
|
+
{
|
|
172
|
+
id: "core",
|
|
173
|
+
label: "Core Switch",
|
|
174
|
+
nodeType: "core",
|
|
175
|
+
state: "normal",
|
|
176
|
+
x: 0,
|
|
177
|
+
y: 0,
|
|
178
|
+
width: 80,
|
|
179
|
+
height: 80,
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: "server1",
|
|
183
|
+
label: "Web Server",
|
|
184
|
+
nodeType: "server",
|
|
185
|
+
state: "normal",
|
|
186
|
+
x: 300,
|
|
187
|
+
y: -150,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
id: "db1",
|
|
191
|
+
label: "Database",
|
|
192
|
+
nodeType: "database",
|
|
193
|
+
state: "idle",
|
|
194
|
+
x: 300,
|
|
195
|
+
y: 150,
|
|
196
|
+
},
|
|
197
|
+
// Border-only node example
|
|
198
|
+
{
|
|
199
|
+
id: "border-box",
|
|
200
|
+
label: "",
|
|
201
|
+
nodeType: "border-only",
|
|
202
|
+
state: "none",
|
|
203
|
+
x: -400,
|
|
204
|
+
y: -200,
|
|
205
|
+
width: 250,
|
|
206
|
+
height: 150,
|
|
207
|
+
borderWidth: 2,
|
|
208
|
+
borderColor: "#00f0ff",
|
|
209
|
+
},
|
|
210
|
+
]);
|
|
211
|
+
|
|
212
|
+
// Connection data
|
|
213
|
+
const edges = ref([
|
|
214
|
+
{ id: "e1", from: "core", to: "server1", speed: 1.5, endMarker: "arrow" },
|
|
215
|
+
{
|
|
216
|
+
id: "e2",
|
|
217
|
+
from: "core",
|
|
218
|
+
to: "db1",
|
|
219
|
+
speed: 2,
|
|
220
|
+
centerText: "Query Traffic",
|
|
221
|
+
endMarker: "arrow",
|
|
222
|
+
},
|
|
223
|
+
]);
|
|
224
|
+
|
|
225
|
+
// Group example
|
|
226
|
+
const groups = ref([
|
|
227
|
+
{
|
|
228
|
+
id: "g1",
|
|
229
|
+
label: "Application Zone",
|
|
230
|
+
color: "#409eff",
|
|
231
|
+
nodeIds: ["server1", "db1"],
|
|
232
|
+
padding: 20,
|
|
233
|
+
},
|
|
234
|
+
]);
|
|
235
|
+
|
|
236
|
+
// Connection mode and view mode
|
|
237
|
+
const lineMode = ref("curve"); // straight | polyline | curve
|
|
238
|
+
const viewMode = ref("2d"); // 2d | 3d
|
|
239
|
+
|
|
240
|
+
// Configuration
|
|
241
|
+
const config = ref({
|
|
242
|
+
selectedBorderColor: "#ffd400",
|
|
243
|
+
selectedLineColor: "#ffd400",
|
|
244
|
+
nodeDraggable: true,
|
|
245
|
+
nodeResizable: true,
|
|
246
|
+
enableZoom: true,
|
|
247
|
+
enablePan: true,
|
|
248
|
+
enableMarquee: true,
|
|
249
|
+
showGrid: true,
|
|
250
|
+
gridColor: "#1a2240",
|
|
251
|
+
gridStep: 40,
|
|
252
|
+
gridOpacity: 0.5,
|
|
253
|
+
radialGradient: {
|
|
254
|
+
startColor: "#0f1729",
|
|
255
|
+
endColor: "#060a14",
|
|
256
|
+
},
|
|
257
|
+
showStatusDot: true,
|
|
258
|
+
motionFx: true,
|
|
259
|
+
maxSelectNodes: "unlimited",
|
|
260
|
+
maxSelectEdges: "unlimited",
|
|
261
|
+
enableZOrder: false,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// Component instance reference
|
|
265
|
+
const topoRef = ref(null);
|
|
266
|
+
|
|
267
|
+
// Event handlers
|
|
268
|
+
const onNodeClick = (node) => {
|
|
269
|
+
console.log("Node clicked:", node);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const onEdgeSelect = (edge) => {
|
|
273
|
+
console.log("Connection selected:", edge);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const onSelectionChange = (selection) => {
|
|
277
|
+
console.log("Selection changed:", selection);
|
|
278
|
+
console.log("Selected nodes:", selection.nodes);
|
|
279
|
+
console.log("Selected connections:", selection.edges);
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const onDataChange = (payload) => {
|
|
283
|
+
console.log("Data changed:", payload);
|
|
284
|
+
console.log("Change summary:", payload.summary);
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const onEdgeCreate = (edge) => {
|
|
288
|
+
console.log("New connection:", edge);
|
|
289
|
+
// Persist newly created connection
|
|
290
|
+
edges.value = [...edges.value, edge];
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// Method call examples
|
|
294
|
+
const handleMethods = () => {
|
|
295
|
+
// Get current data
|
|
296
|
+
const data = topoRef.value.getData();
|
|
297
|
+
|
|
298
|
+
// Add nodes
|
|
299
|
+
topoRef.value.addNodes([
|
|
300
|
+
{ label: "New Node", nodeType: "server", x: 500, y: 0 },
|
|
301
|
+
]);
|
|
302
|
+
|
|
303
|
+
// Add connections
|
|
304
|
+
topoRef.value.addEdges([{ from: "core", to: "new-node-id" }]);
|
|
305
|
+
|
|
306
|
+
// Update nodes
|
|
307
|
+
topoRef.value.updateNodes([{ id: "core", label: "Updated Name" }]);
|
|
308
|
+
|
|
309
|
+
// Delete selected elements
|
|
310
|
+
topoRef.value.removeSelected();
|
|
311
|
+
|
|
312
|
+
// Coordinate conversion
|
|
313
|
+
const svgPos = topoRef.value.clientToSvg(event);
|
|
314
|
+
const clientPos = topoRef.value.svgToClient(node.x, node.y);
|
|
315
|
+
|
|
316
|
+
// Layer management (requires enableZOrder)
|
|
317
|
+
topoRef.value.moveToFront("node-id");
|
|
318
|
+
topoRef.value.moveToBack("node-id");
|
|
319
|
+
topoRef.value.moveLayerUp("node-id");
|
|
320
|
+
topoRef.value.moveLayerDown("node-id");
|
|
321
|
+
};
|
|
322
|
+
</script>
|
|
323
|
+
|
|
324
|
+
<style scoped>
|
|
325
|
+
.topology-container {
|
|
326
|
+
width: 100%;
|
|
327
|
+
height: 600px;
|
|
328
|
+
background: radial-gradient(ellipse at center, #0f1729 0%, #060a14 100%);
|
|
329
|
+
}
|
|
330
|
+
</style>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Global Configuration Properties
|
|
336
|
+
|
|
337
|
+
| Config Item | Type | Default | Description |
|
|
338
|
+
| --------------------- | ----------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
339
|
+
| `selectedBorderColor` | `String` | `#fbbf24` | Selected node border color |
|
|
340
|
+
| `selectedLineColor` | `String` | `#fbbf24` | Selected connection color |
|
|
341
|
+
| `nodeDraggable` | `Boolean` | `true` | Node drag switch (requires `editable`) |
|
|
342
|
+
| `nodeResizable` | `Boolean` | `true` | Node resize switch (requires `editable`) |
|
|
343
|
+
| `enableZoom` | `Boolean` | `true` | Zoom wheel switch |
|
|
344
|
+
| `enablePan` | `Boolean` | `true` | Canvas pan switch |
|
|
345
|
+
| `enableMarquee` | `Boolean` | `true` | Ctrl + left-drag box select switch |
|
|
346
|
+
| `maxSelectNodes` | `Number \| "unlimited"` | Unlimited | Max selectable nodes: `0` (disabled) / `1` / `2` or any non-negative integer; unset or `"unlimited"` no limit |
|
|
347
|
+
| `maxSelectEdges` | `Number \| "unlimited"` | Unlimited | Max selectable connections (merged bundles count all connections in group) |
|
|
348
|
+
| `showGrid` | `Boolean` | `true` | Grid background (set `false` to disable) |
|
|
349
|
+
| `gridColor` | `String` | `#1a2240` | Grid line color |
|
|
350
|
+
| `gridStep` | `Number` | `40` | Grid spacing (px at 1x zoom, scales with zoom) |
|
|
351
|
+
| `gridOpacity` | `Number` | `0.5` | Grid overlay opacity (0–1) |
|
|
352
|
+
| `radialGradient` | `Object` | See notes | Canvas background radial gradient |
|
|
353
|
+
| `showCenterPoint` | `Boolean` | `false` | Canvas center cross marker |
|
|
354
|
+
| `showEdgeTextBg` | `Boolean` | `false` | Connection text background |
|
|
355
|
+
| `edgeTextBgColor` | `String` | `#0a0e1a` | Connection text background color |
|
|
356
|
+
| `edgeCenterTextFollowLine` | `Boolean` | `true` | Whether the center label rotates along the line: `true` follows the line tangent (current), `false` always stays horizontal |
|
|
357
|
+
| `edgeTextPosition` | `"above" \| "center" \| "below"` | `"center"` | Common default position for all three edge label slots (from / center / to): `above` the line / `center` on the line (default) / `below` the line |
|
|
358
|
+
| `edgeFromTextPosition` | `"above" \| "center" \| "below"` | Follow all | Position override for the start label (`fromText`) |
|
|
359
|
+
| `edgeCenterTextPosition` | `"above" \| "center" \| "below"` | Follow all | Position override for the center label (`centerText`; merged count badge follows this slot) |
|
|
360
|
+
| `edgeToTextPosition` | `"above" \| "center" \| "below"` | Follow all | Position override for the end label (`toText`) |
|
|
361
|
+
| `edgeTextGap` | `Number` | `2` | Gap (px) between the label plate and the line in above / below mode |
|
|
362
|
+
| `nodeLabelPosition` | `"top" \| "center" \| "bottom"` | `"bottom"` | Global default node label position: top / center / bottom; per-node override via `node.labelPosition` |
|
|
363
|
+
| `showNodeHandles` | `Boolean` | `false` | Node handles (four small circles appear at top/bottom/left/right of nodes, auto-connect when dragged to another node) |
|
|
364
|
+
| `showStatusDot` | `Boolean` | `true` | Status dot at top-right corner of each node |
|
|
365
|
+
| `labelGap` | `Number` | `18` | Fixed gap between node box edge and its label (px at 1x zoom) |
|
|
366
|
+
| `watchDataChanges` | `Boolean` | `false` | Component internal data change detection (debounce 300ms then trigger `data-change`) |
|
|
367
|
+
| `fx` | `Boolean` | Auto | Master decorative animation switch: `false` all off / `true` all on / unset = auto |
|
|
368
|
+
| `motionFx` | `Boolean` | Auto | Per-feature override - connection line animation (flow + particles) |
|
|
369
|
+
| `glowFx` | `Boolean` | Auto | Per-feature override - connection glow |
|
|
370
|
+
| `breatheFx` | `Boolean` | Auto | Per-feature override - alert breathing ring: `false` disables it, `true` forces it on (ignores the size gate) |
|
|
371
|
+
| `alertStates` | `String[]` | See notes | States that trigger the breathing ring; defaults to `["warning","error","master"]`. Every other state only recolors the node, no animation |
|
|
372
|
+
| `alertStyle` | `"ring" \| "fill" \| "ripple" \| "blink"` | `"ring"` | Alert animation style: ring = expanding outline (error/master add an offset second ring) / fill = solid breathing disc / ripple = three staggered waves / blink = hard strobe; per-node override via `node.alertStyle` |
|
|
373
|
+
| `alertGlow` | `Boolean` | `true` | Edge gradient glow of the `fill` solid breathing disc (bright rim + soft outward falloff); set `false` for a plain solid disc |
|
|
374
|
+
| `fxMotionMaxEdges` | `Number` | `200` | Edge count above which flow + particle animation auto-disables |
|
|
375
|
+
| `fxGlowMaxEdges` | `Number` | `500` | Edge count above which edge glow auto-disables |
|
|
376
|
+
| `fxAlertMaxNodes` | `Number` | `300` | Alert node count above which breathing rings auto-disable (counts alert nodes only, so a big graph no longer kills every alert) |
|
|
377
|
+
| `fxBreatheMaxNodes` | `Number` | `300` | Legacy node-count threshold (superseded by `fxAlertMaxNodes`, kept for compatibility) |
|
|
378
|
+
| `enableZOrder` | `Boolean` | `false` | **Enable Z-axis layer sorting**: After enabling, nodes render according to `zIndex` property, supporting layer operation API, right-click menu and keyboard shortcuts |
|
|
379
|
+
| `enableDeleteKey` | `Boolean` | `true` | Delete / Backspace removes the current selection (requires `editable`); when the parent listens to `delete-request` the component only emits the event |
|
|
380
|
+
| `imageFit` | `"contain" \| "cover"` | `"contain"` | How image nodes fill their box: `contain` keeps the whole picture inside the box (centred, letterboxed, never cropped); `cover` fills the box and crops the overflow. Both scale uniformly — the picture is never stretched |
|
|
381
|
+
| `imageNodeBySource` | `Boolean` | `false` | **Global image-node rule**: when `true`, any node carrying a picture source is rendered as an image node (its `nodeType` is ignored); text and border-only nodes are unaffected |
|
|
382
|
+
| `edgeLayer` | `"split" \| "below"` | `"split"` | Paint order of nodes vs edges: `split` paints each node in two passes — plate + border below, icon / image / label above, with edges in between (a line crossing a node stays visible); `below` is the classic "all edges under all nodes" |
|
|
383
|
+
| `highlightEdgeOnTop` | `Boolean` | `true` | Selected edges are re-painted above the node layer so the highlighted path is never hidden by a node plate or icon (decoration only — it never captures clicks) |
|
|
384
|
+
|
|
385
|
+
### radialGradient Configuration
|
|
386
|
+
|
|
387
|
+
```javascript
|
|
388
|
+
// Simple mode
|
|
389
|
+
radialGradient: {
|
|
390
|
+
startColor: "#0f1729",
|
|
391
|
+
endColor: "#060a14"
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Advanced mode (custom gradient center and color stops)
|
|
395
|
+
radialGradient: {
|
|
396
|
+
cx: "50%",
|
|
397
|
+
cy: "50%",
|
|
398
|
+
r: "50%",
|
|
399
|
+
stops: [
|
|
400
|
+
{ offset: "0%", color: "#0f1729", opacity: 1 },
|
|
401
|
+
{ offset: "60%", color: "#1e293b", opacity: 0.8 },
|
|
402
|
+
{ offset: "100%", color: "#060a14", opacity: 1 }
|
|
403
|
+
]
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## Node Properties
|
|
410
|
+
|
|
411
|
+
| Property | Type | Required | Default | Description |
|
|
412
|
+
| --------------- | ------------------------------- | -------- | ----------- | ---------------------------------------------------------------------------------- |
|
|
413
|
+
| `id` | `String` | ✅ | - | Unique node identifier |
|
|
414
|
+
| `label` | `String \| null` | ❌ | `null` | Node display text (supports `\n` newline), border-only and text nodes can be empty |
|
|
415
|
+
| `nodeType` | `String` | ❌ | `"server"` | Node type (see types list below) |
|
|
416
|
+
| `image` | `String` | ❌ | - | Picture URL; aliases `src` / `img` / `imageUrl` (see "Image Nodes" below) |
|
|
417
|
+
| `state` | `String` | ❌ | `"none"` | Node status (see status list below) |
|
|
418
|
+
| `alertStyle` | `String` | ❌ | - | Per-node alert animation override (`ring` / `fill` / `ripple` / `blink`, see `config.alertStyle`) |
|
|
419
|
+
| `x` | `Number` | ✅ | - | Node X coordinate (SVG coordinate system) |
|
|
420
|
+
| `y` | `Number` | ✅ | - | Node Y coordinate (SVG coordinate system) |
|
|
421
|
+
| `width` | `Number` | ❌ | `60` | Node width (required for border-only nodes) |
|
|
422
|
+
| `height` | `Number` | ❌ | `60` | Node height (required for border-only nodes) |
|
|
423
|
+
| `rotation` | `Number` | ❌ | `0` | Node rotation angle (degrees) |
|
|
424
|
+
| `fontColor` | `String` | ❌ | `"#ffffff"` | Text color |
|
|
425
|
+
| `fontSize` | `Number` | ❌ | `11` | Font size |
|
|
426
|
+
| `fontWeight` | `Number \| String` | ❌ | `500` | Font weight (100–900) |
|
|
427
|
+
| `borderColor` | `String` | ❌ | `"#94a3b8"` | Border color |
|
|
428
|
+
| `borderWidth` | `Number` | ❌ | `0` | Border width (0 means no border) |
|
|
429
|
+
| `borderStyle` | `"full" \| "dashed" \| "none"` | ❌ | `"full"` | Border style: `"full"` solid, `"dashed"` dashed, `"none"` no border |
|
|
430
|
+
| `background` | `String` | ❌ | `"#0f1729"` | Background color |
|
|
431
|
+
| `borderRadius` | `Number` | ❌ | `6` | Corner radius (px) |
|
|
432
|
+
| `labelPosition` | `"top" \| "center" \| "bottom"` | ❌ | Follow all | Label position (falls back to `config.nodeLabelPosition` when unset) |
|
|
433
|
+
| `zIndex` | `Number` | ❌ | `0` | Z-axis layer index (requires `enableZOrder`) |
|
|
434
|
+
|
|
435
|
+
### Node Types (nodeType)
|
|
436
|
+
|
|
437
|
+
| Type | Icon | Description |
|
|
438
|
+
| ---------------- | ----------------------------- | ------------------------------------------------ |
|
|
439
|
+
| `"core"` | Hexagon | Core device |
|
|
440
|
+
| `"server"` | Stacked rectangles | Server |
|
|
441
|
+
| `"firewall"` | Rectangle with lines | Firewall |
|
|
442
|
+
| `"loadbalancer"` | Circle + polyline | Load balancer |
|
|
443
|
+
| `"database"` | Cylinder | Database |
|
|
444
|
+
| `"cdn"` | Concentric circles | CDN node |
|
|
445
|
+
| `"cache"` | Hexagon + center circle | Cache |
|
|
446
|
+
| `"queue"` | Rectangle with vertical lines | Queue |
|
|
447
|
+
| `"text"` | Text lines | Pure text node |
|
|
448
|
+
| `"border-only"` | Hollow rectangle | Border-only node (only border outline displayed) |
|
|
449
|
+
|
|
450
|
+
### Image Nodes
|
|
451
|
+
|
|
452
|
+
A node can be rendered with a picture (photo / avatar / bitmap icon). The component always scales it uniformly — it is never stretched.
|
|
453
|
+
|
|
454
|
+
**Detection rules** (any one makes it an image node):
|
|
455
|
+
|
|
456
|
+
| Condition | Example |
|
|
457
|
+
| --------- | ------- |
|
|
458
|
+
| `nodeType` is `"image"` / `"img"` / `"picture"` (case-insensitive) | `{ nodeType: "image", image: "/a.png" }` |
|
|
459
|
+
| No `nodeType` at all, and a picture source is present | `{ image: "/a.png" }` |
|
|
460
|
+
| `config.imageNodeBySource` is on and a picture source is present (`nodeType` ignored) | `{ nodeType: "server", image: "/a.png" }` |
|
|
461
|
+
|
|
462
|
+
- The source is taken from the first non-empty field of **`image` → `src` → `img` → `imageUrl`**; it must be a non-empty (trimmed) string.
|
|
463
|
+
- Text (`"text"`) and border-only (`"border-only"`) nodes always keep their own rendering.
|
|
464
|
+
- A node with a `nodeType` is **not** an image node by default (its icon follows `nodeType`). For a fully photo-based graph, switch `imageNodeBySource: true`.
|
|
465
|
+
|
|
466
|
+
**Filling**: `config.imageFit`
|
|
467
|
+
|
|
468
|
+
| Value | Effect |
|
|
469
|
+
| ----- | ------ |
|
|
470
|
+
| `"contain"` (default) | The whole picture fits inside the node box, centred and letterboxed — never cropped |
|
|
471
|
+
| `"cover"` | Fills the box along its shortest edge; the overflow on the long edge is cropped |
|
|
472
|
+
|
|
473
|
+
**Slot props**: `#node-icon` receives
|
|
474
|
+
|
|
475
|
+
| prop | Description |
|
|
476
|
+
| ---- | ----------- |
|
|
477
|
+
| `isImage` | Whether this node is treated as an image node |
|
|
478
|
+
| `image` | Picture source (may be an empty string) |
|
|
479
|
+
| `fit` | `"contain"` / `"cover"` |
|
|
480
|
+
| `imageWidth` / `imageHeight` | Aspect-correct draw size for the picture (centre it on the node box) |
|
|
481
|
+
| `width` / `height` | Node box size |
|
|
482
|
+
|
|
483
|
+
```vue
|
|
484
|
+
<Topology :nodes="nodes" :edges="edges" :config="{ imageFit: 'contain' }">
|
|
485
|
+
<template #node-icon="{ isImage, image, imageWidth, imageHeight }">
|
|
486
|
+
<image
|
|
487
|
+
v-if="isImage"
|
|
488
|
+
:href="image"
|
|
489
|
+
:x="-imageWidth / 2"
|
|
490
|
+
:y="-imageHeight / 2"
|
|
491
|
+
:width="imageWidth"
|
|
492
|
+
:height="imageHeight"
|
|
493
|
+
/>
|
|
494
|
+
</template>
|
|
495
|
+
</Topology>
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### Node Status (state)
|
|
499
|
+
|
|
500
|
+
| Status | Color | Description |
|
|
501
|
+
| ------------ | ------------ | ------------------- |
|
|
502
|
+
| `"none"` | Hidden | No status indicator |
|
|
503
|
+
| `"normal"` | Green | Normal |
|
|
504
|
+
| `"warning"` | Yellow | Warning |
|
|
505
|
+
| `"error"` | Red | Error |
|
|
506
|
+
| `"info"` | Blue | Info |
|
|
507
|
+
| `"active"` | Cyan | Active |
|
|
508
|
+
| `"disabled"` | Gray | Disabled |
|
|
509
|
+
| `"locked"` | Purple | Locked |
|
|
510
|
+
| `"master"` | Dark red | Master node |
|
|
511
|
+
| `"expert"` | Pink | Expert node |
|
|
512
|
+
| `"advanced"` | Orange | Advanced node |
|
|
513
|
+
| `"adept"` | Light orange | Adept node |
|
|
514
|
+
| `"awakened"` | Blue | Awakened node |
|
|
515
|
+
| `"dormant"` | Gray-purple | Dormant node |
|
|
516
|
+
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
## Connection Properties
|
|
520
|
+
|
|
521
|
+
| Property | Type | Required | Default | Description |
|
|
522
|
+
| ------------ | ---------------------------- | -------- | ----------- | ------------------------------------------------------------------------------------ |
|
|
523
|
+
| `id` | `String` | ✅ | - | Unique connection identifier (auto-generated uuid) |
|
|
524
|
+
| `from` | `String` | ✅ | - | Source node id |
|
|
525
|
+
| `to` | `String` | ✅ | - | Target node id |
|
|
526
|
+
| `speed` | `Number` | ❌ | `1` | Flow speed multiplier (animation speed) |
|
|
527
|
+
| `animated` | `Boolean` | ❌ | `true` | Per-connection animation switch (`false` disables流光/particles for this connection) |
|
|
528
|
+
| `fromAnchor` | `"center" \| "edge"` | ❌ | `"edge"` | Start anchor: `"center"` center / `"edge"` boundary intersection |
|
|
529
|
+
| `toAnchor` | `"center" \| "edge"` | ❌ | `"edge"` | End anchor: `"center"` center / `"edge"` boundary intersection |
|
|
530
|
+
| `fromText` | `String \| Object` | ❌ | `""` | Start text (see text format below) |
|
|
531
|
+
| `centerText` | `String \| Object` | ❌ | `""` | Center text (see text format below) |
|
|
532
|
+
| `toText` | `String \| Object` | ❌ | `""` | End text (see text format below) |
|
|
533
|
+
| `endMarker` | `"none" \| "arrow" \| "dot"` | ❌ | `"none"` | End marker: `"none"` none / `"arrow"` arrow / `"dot"` dot |
|
|
534
|
+
| `fontSize` | `Number` | ❌ | `8` | Connection text size |
|
|
535
|
+
| `fontColor` | `String` | ❌ | `"#00f0ff"` | Connection text color |
|
|
536
|
+
|
|
537
|
+
### Connection Text Format
|
|
538
|
+
|
|
539
|
+
```javascript
|
|
540
|
+
// String shorthand form
|
|
541
|
+
fromText: "Start Text"
|
|
542
|
+
|
|
543
|
+
// Object full form
|
|
544
|
+
fromText: {
|
|
545
|
+
text: "Start Text", // Text content
|
|
546
|
+
rotation: 0, // Additional rotation angle (degrees)
|
|
547
|
+
fontSize: 10, // Font size
|
|
548
|
+
color: "#ffffff", // Color
|
|
549
|
+
position: "above" // above the line / center on the line / below the
|
|
550
|
+
// line (highest priority, overrides config)
|
|
551
|
+
}
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
---
|
|
555
|
+
|
|
556
|
+
## API Methods
|
|
557
|
+
|
|
558
|
+
Call methods exposed by the component via template ref:
|
|
559
|
+
|
|
560
|
+
```vue
|
|
561
|
+
<template>
|
|
562
|
+
<Topology ref="topoRef" />
|
|
563
|
+
</template>
|
|
564
|
+
|
|
565
|
+
<script setup>
|
|
566
|
+
import { ref } from "vue";
|
|
567
|
+
|
|
568
|
+
const topoRef = ref(null);
|
|
569
|
+
|
|
570
|
+
// All method call examples
|
|
571
|
+
const methods = () => {
|
|
572
|
+
// === Data Methods ===
|
|
573
|
+
|
|
574
|
+
// Get current latest data (deep copy)
|
|
575
|
+
const { nodes, edges } = topoRef.value.getData();
|
|
576
|
+
|
|
577
|
+
// Reset data change detection baseline
|
|
578
|
+
topoRef.value.resetDataBaseline();
|
|
579
|
+
|
|
580
|
+
// Replace entire dataset from outside
|
|
581
|
+
topoRef.value.setData({ nodes: nextNodes });
|
|
582
|
+
|
|
583
|
+
// Delete currently selected nodes and connections (deleting nodes cascades to delete all connected connections)
|
|
584
|
+
const removed = topoRef.value.removeSelected();
|
|
585
|
+
|
|
586
|
+
// Add nodes (array or single)
|
|
587
|
+
topoRef.value.addNodes([{ label: "New Node", x: 0, y: 0 }]);
|
|
588
|
+
|
|
589
|
+
// Add connections (array or single)
|
|
590
|
+
topoRef.value.addEdges([{ from: "a", to: "b" }]);
|
|
591
|
+
|
|
592
|
+
// Partially update nodes by id (shallow merge, undefined ignored, unknown ids skipped)
|
|
593
|
+
topoRef.value.updateNodes([{ id: "node-1", label: "Renamed", width: 120 }]);
|
|
594
|
+
|
|
595
|
+
// Partially update connections by id
|
|
596
|
+
topoRef.value.updateEdges([{ id: "edge-1", speed: 2 }]);
|
|
597
|
+
|
|
598
|
+
// === Layer Management (requires enableZOrder: true) ===
|
|
599
|
+
|
|
600
|
+
// Move up one layer
|
|
601
|
+
topoRef.value.moveLayerUp("node-id");
|
|
602
|
+
|
|
603
|
+
// Move down one layer
|
|
604
|
+
topoRef.value.moveLayerDown("node-id");
|
|
605
|
+
|
|
606
|
+
// Move to front (highest zIndex)
|
|
607
|
+
topoRef.value.moveToFront("node-id");
|
|
608
|
+
|
|
609
|
+
// Move to back (lowest zIndex)
|
|
610
|
+
topoRef.value.moveToBack("node-id");
|
|
611
|
+
|
|
612
|
+
// === Coordinate Conversion ===
|
|
613
|
+
|
|
614
|
+
// Scenario 1: Mouse coordinates → SVG coordinates (parameters can be event object or coordinate pair)
|
|
615
|
+
const p1 = topoRef.value.clientToSvg(e); // Pass event object directly
|
|
616
|
+
const p2 = topoRef.value.clientToSvg(clientX, y); // Pass coordinate pair
|
|
617
|
+
|
|
618
|
+
// Scenario 2: SVG coordinates → Screen coordinates (input node.x / node.y, output clientX/clientY)
|
|
619
|
+
const node = topoRef.value.getData().nodes[0];
|
|
620
|
+
const { x, y } = topoRef.value.svgToClient(node.x, node.y);
|
|
621
|
+
menu.style.left = `${x}px`;
|
|
622
|
+
menu.style.top = `${y}px`;
|
|
623
|
+
};
|
|
624
|
+
</script>
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
---
|
|
628
|
+
|
|
629
|
+
## Events
|
|
630
|
+
|
|
631
|
+
| Event Name | Parameters | Description |
|
|
632
|
+
| ------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
633
|
+
| `update:nodes` | `nodes` | Node data update (`v-model:nodes`); continuously triggered during drag/resize |
|
|
634
|
+
| `update:lineMode` | `string` | Connection mode change (`v-model:line-mode`) |
|
|
635
|
+
| `update:viewMode` | `string` | View mode change (`v-model:view-mode`) |
|
|
636
|
+
| `node-click` | `node` | Node clicked |
|
|
637
|
+
| `node-select` | `node \| null` | Single node selection change (use `selection-change` for multi-select scenarios) |
|
|
638
|
+
| `edge-select` | `edge \| null` | Connection selection change (merged connections include `bundleEdges` array) |
|
|
639
|
+
| `selection-change` | `{ nodes, edges }` | Triggered when selection set changes; `nodes`/`edges` are arrays of selected node and connection objects |
|
|
640
|
+
| `data-change` | `{ nodes, edges, summary }` | When `watchDataChanges` is enabled, triggered after data change debounce (300ms) |
|
|
641
|
+
| `edge-create` | `edge` | Triggered after node handle drag connects two nodes |
|
|
642
|
+
| `edge-remove` | `edges` | Triggered after deleting connections (includes cascaded deletions due to node deletion) |
|
|
643
|
+
| `edge-update` | `edges` | Triggered after `updateEdges()` modifies connections |
|
|
644
|
+
| `node-drag-start` | `node` | Node drag starts; also triggered when dragging multi-select set, payload is the node being held |
|
|
645
|
+
| `node-drag-end` | — | Node drag ends |
|
|
646
|
+
| `node-resize-start` | `node` | Resize starts |
|
|
647
|
+
| `node-resize-end` | `node \| null` | Resize ends |
|
|
648
|
+
|
|
649
|
+
### selection-change Event Details
|
|
650
|
+
|
|
651
|
+
```javascript
|
|
652
|
+
// Supports multiple selection methods
|
|
653
|
+
// 1. Ctrl+click multi-select
|
|
654
|
+
// 2. Ctrl+left-drag box select
|
|
655
|
+
// 3. Normal click single select
|
|
656
|
+
// 4. Click blank to clear
|
|
657
|
+
|
|
658
|
+
@selection-change="(sel) => {
|
|
659
|
+
console.log('Selected nodes:', sel.nodes.map(n => n.id));
|
|
660
|
+
console.log('Selected connections:', sel.edges.map(e => e.id));
|
|
661
|
+
}"
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
---
|
|
665
|
+
|
|
666
|
+
## Interactions
|
|
667
|
+
|
|
668
|
+
| Operation | Gesture | Description |
|
|
669
|
+
| ---------------------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
670
|
+
| Select node/connection | Left-click | Repeated clicking unselects; clicking blank clears all |
|
|
671
|
+
| Multi-select (point) | Ctrl (macOS ⌘) + click | Add/remove nodes/connections from selection set, supports mixed node and connection multi-select |
|
|
672
|
+
| Multi-select (box) | Ctrl (macOS ⌘) + left-drag | Draw rectangular selection box on blank canvas, **nodes intersecting the box** are added to current selection (union semantics; only nodes participate in box select) |
|
|
673
|
+
| Drag single node | Hold and drag anywhere on node area | Requires `editable` enabled and `config.nodeDraggable !== false`; dragging unselected node will first select it |
|
|
674
|
+
| Drag multiple nodes | Drag any **selected** node | Selection set moves together, all nodes displace equally; selection state retained after release |
|
|
675
|
+
| Canvas pan (infinite) | Hold left-drag on blank; or hold **middle-click** anywhere | Panning has no boundaries; content and grid move together; does not change selection state |
|
|
676
|
+
| Zoom | Scroll wheel | Zoom centered on mouse position (0.2x–5x) |
|
|
677
|
+
| Resize node | After selecting **single** node, drag 8 control points | Requires `editable` and `config.nodeResizable !== false` |
|
|
678
|
+
| Create connection | Drag from node handle to target node | Requires `config.showNodeHandles: true` |
|
|
679
|
+
|
|
680
|
+
### Layer Management Keyboard Shortcuts (requires `enableZOrder`)
|
|
681
|
+
|
|
682
|
+
| Shortcut | Operation |
|
|
683
|
+
| ---------------------- | ------------------- |
|
|
684
|
+
| `Ctrl/Cmd + Shift + ↑` | Move up one layer |
|
|
685
|
+
| `Ctrl/Cmd + Shift + ↓` | Move down one layer |
|
|
686
|
+
| `Ctrl/Cmd + Shift + ←` | Move to back |
|
|
687
|
+
| `Ctrl/Cmd + Shift + →` | Move to front |
|
|
688
|
+
|
|
689
|
+
### Interaction Priority Notes
|
|
690
|
+
|
|
691
|
+
- **Node and connection overlap**: Click/drag acts on **node**; connections normally clickable where not occluded—nodes always selectable and draggable in dense graphics
|
|
692
|
+
- **Border-only node exception**: such a node is an empty frame — only its **border stroke** and **label text** are clickable, so the empty interior passes clicks through to the connections / canvas underneath (a line running through the frame stays selectable). Drag it by its border or label
|
|
693
|
+
- **The promoted-edge layer never captures clicks**: `highlightEdgeOnTop` re-paints selected edges above the nodes for visual clarity only; it does not steal clicks from nodes or anything else
|
|
694
|
+
- **Click vs drag distinction**: Left-click on blank distinguishes by small threshold (pan 4px / box select 3px / node drag 3px): below threshold treated as click (clear or toggle selection), above threshold enters drag mode
|
|
695
|
+
|
|
696
|
+
---
|
|
697
|
+
|
|
698
|
+
## Supplementary Notes
|
|
699
|
+
|
|
700
|
+
### Data Synchronization Mechanism
|
|
701
|
+
|
|
702
|
+
`props.nodes` / `props.edges` use deep synchronization—parent replacing entire array or modifying fields in-place will update component internally; component's drag/resize/add/delete/update will also emit via `update:nodes`, `edge-create`, `edge-update`, `edge-remove` in real-time. Parent writing component-emitted data back without modification won't cause loops or duplicate reconstruction.
|
|
703
|
+
|
|
704
|
+
When loading a complete new dataset, first update your `nodes` / `edges`, then call `setData()` to clean up component internal residual state.
|
|
705
|
+
|
|
706
|
+
### Node / Edge Paint Order
|
|
707
|
+
|
|
708
|
+
With the default `config.edgeLayer: "split"` the paint order is:
|
|
709
|
+
|
|
710
|
+
```
|
|
711
|
+
group boxes → node plate (background + border) → edges (base / glow / particles / text) → node content (icon / image / label / status dot)
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
An edge crossing a node — or a node overlapping another node — therefore keeps running **across the node plate**, and is only partly covered by the icon itself instead of disappearing. Set `edgeLayer: "below"` for the classic "all edges under all nodes" order.
|
|
715
|
+
|
|
716
|
+
With `config.highlightEdgeOnTop` (default `true`) selected edges are additionally painted above the node content, so the path under inspection is never hidden.
|
|
717
|
+
|
|
718
|
+
### TypeScript Support
|
|
719
|
+
|
|
720
|
+
```typescript
|
|
721
|
+
import type { TopologyInstance } from "vue3-network-graph";
|
|
722
|
+
|
|
723
|
+
const topoRef = ref<TopologyInstance | null>(null);
|
|
724
|
+
|
|
725
|
+
// Type-safe method calls
|
|
726
|
+
topoRef.value?.getData();
|
|
727
|
+
topoRef.value?.clientToSvg(event);
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
### Coordinate System Notes
|
|
731
|
+
|
|
732
|
+
- Component node coordinates (`node.x` / `node.y`) are in **SVG user coordinate system**
|
|
733
|
+
- Canvas zoom and pan are implemented via `viewBox`, so conversion between this coordinate system and screen pixels varies with view state
|
|
734
|
+
- `clientToSvg` uses matrix transformation, **automatically accounting for current zoom and pan**, returning coordinates identical to `node.x` / `node.y`
|
|
735
|
+
- `svgToClient` is its inverse: input node coordinates, output screen `clientX` / `clientY`, suitable for DOM floating layers
|
|
736
|
+
|
|
737
|
+
---
|
|
738
|
+
|
|
739
|
+
## License
|
|
740
|
+
|
|
741
|
+
[MIT](./LICENSE) © 2026 vnodegit
|