react-kggraph 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.es.js +1 -0
- package/lib/index10.es.js +2 -2
- package/lib/index11.es.js +2 -2
- package/lib/index12.es.js +2 -2
- package/lib/index13.es.js +2 -2
- package/lib/index14.es.js +2 -2
- package/lib/index15.es.js +2 -2
- package/lib/index16.es.js +3 -24
- package/lib/index17.es.js +22 -327
- package/lib/index18.es.js +329 -4
- package/lib/index19.es.js +4 -283
- package/lib/index20.es.js +284 -0
- package/lib/{index23.es.js → index24.es.js} +1 -1
- package/lib/index26.es.js +71 -31
- package/lib/index27.es.js +28 -824
- package/lib/index28.es.js +828 -0
- package/lib/index35.es.js +1 -1
- package/lib/index36.es.js +6 -6
- package/lib/index5.es.js +12386 -3
- package/lib/index6.es.js +2 -2
- package/lib/index7.es.js +2 -2
- package/lib/index8.es.js +2 -2
- package/lib/index9.es.js +2 -2
- package/package.json +3 -3
- package/lib/index25.es.js +0 -72
- package/lib/index4.es.js +0 -12387
- /package/lib/{index21.es.js → index22.es.js} +0 -0
package/lib/index17.es.js
CHANGED
|
@@ -1,330 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import i from "./index9.es.js";
|
|
6
|
-
import a from "./index10.es.js";
|
|
7
|
-
import o from "./index11.es.js";
|
|
8
|
-
import s from "./index12.es.js";
|
|
9
|
-
import c from "./index13.es.js";
|
|
10
|
-
import l from "./index14.es.js";
|
|
11
|
-
import u from "./index15.es.js";
|
|
12
|
-
import { jsonStringifyParse as d } from "./index16.es.js";
|
|
13
|
-
import { message as f } from "antd";
|
|
14
|
-
//#region src/components/Graph/utils/tools.ts
|
|
15
|
-
var p = [
|
|
16
|
-
e,
|
|
17
|
-
t,
|
|
18
|
-
n,
|
|
19
|
-
r,
|
|
20
|
-
i,
|
|
21
|
-
a,
|
|
22
|
-
o,
|
|
23
|
-
s,
|
|
24
|
-
c,
|
|
25
|
-
l
|
|
26
|
-
], m = (e) => {
|
|
27
|
-
let t = {}, n = {}, r = [];
|
|
28
|
-
return e.forEach((e) => {
|
|
29
|
-
let { group: i } = e;
|
|
30
|
-
if (i === "nodes") {
|
|
31
|
-
let n = e.data, i = n.properties?.type, a = n.type;
|
|
32
|
-
!a && i === "uri" || (!r.includes(a) && i === "uri" ? (r.push(a), t = {
|
|
33
|
-
...t,
|
|
34
|
-
[a]: {
|
|
35
|
-
...t[a],
|
|
36
|
-
count: 1,
|
|
37
|
-
img: n.image
|
|
38
|
-
}
|
|
39
|
-
}) : i === "uri" && a && (t = {
|
|
40
|
-
...t,
|
|
41
|
-
[a]: {
|
|
42
|
-
...t[a],
|
|
43
|
-
img: n.image,
|
|
44
|
-
count: t[a].count + 1
|
|
45
|
-
}
|
|
46
|
-
}));
|
|
47
|
-
} else if (i === "edges") {
|
|
48
|
-
let { label: t } = e.data;
|
|
49
|
-
n[t] ? n[t] = n[t] + 1 : n[t] = 1;
|
|
50
|
-
} else console.log("nonono");
|
|
51
|
-
}), {
|
|
52
|
-
typeListArr: r,
|
|
53
|
-
typeListObj: t,
|
|
54
|
-
relationListObj: n
|
|
55
|
-
};
|
|
56
|
-
}, h = (e, { graphData: t = [], typeObj: n, zktype: r, graphInfo: i = {} }) => {
|
|
57
|
-
let a = d(n), o = Object.keys(n), s = i.searchNodes || [], c = new Set(t?.map((e) => e.group === "nodes" ? e.data?.id : e.data?.source + "-" + e.data?.target).filter(Boolean) || []), { nodes: l = [], links: f = [] } = e || {}, h = [];
|
|
58
|
-
((e) => {
|
|
59
|
-
e.forEach((e) => {
|
|
60
|
-
let { label: t } = e, n = `${e.source}-${e.target}`;
|
|
61
|
-
c.has(n) || h.push({
|
|
62
|
-
group: "edges",
|
|
63
|
-
data: {
|
|
64
|
-
...e,
|
|
65
|
-
name: t,
|
|
66
|
-
zktype: r
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
})(f), ((e) => {
|
|
71
|
-
e.forEach((e) => {
|
|
72
|
-
if (!c.has(e.id)) {
|
|
73
|
-
let t = e.properties?.type, n = e.type, r = e.label.split("#").pop(), i = -1;
|
|
74
|
-
if (!n && t === "uri") i = e.image || p[0];
|
|
75
|
-
else if (!o.includes(n) && t === "uri") {
|
|
76
|
-
o.push(n);
|
|
77
|
-
let t = o.indexOf(n);
|
|
78
|
-
i = e.image || p[t] || p[0], a = {
|
|
79
|
-
...a,
|
|
80
|
-
[n]: {
|
|
81
|
-
...a[n],
|
|
82
|
-
img: i
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
} else t === "uri" && n && (i = a[n]?.img);
|
|
86
|
-
let c = {
|
|
87
|
-
...e,
|
|
88
|
-
name: r,
|
|
89
|
-
"properties-type": t,
|
|
90
|
-
image: s.includes(r) ? u : i,
|
|
91
|
-
baseWidth: 80,
|
|
92
|
-
baseHeight: 80
|
|
93
|
-
};
|
|
94
|
-
h.push({
|
|
95
|
-
group: "nodes",
|
|
96
|
-
data: c
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
})(l);
|
|
101
|
-
let { typeListObj: g, relationListObj: _ } = m([...h, ...t]);
|
|
102
|
-
return {
|
|
103
|
-
elements: h,
|
|
104
|
-
typeListObj: g,
|
|
105
|
-
relationListObj: _
|
|
106
|
-
};
|
|
107
|
-
}, g = (e, t) => {
|
|
108
|
-
let n = e.current;
|
|
109
|
-
if (!n) return;
|
|
110
|
-
let r = { color: "#000" };
|
|
111
|
-
switch (t) {
|
|
112
|
-
case "center":
|
|
113
|
-
r = {
|
|
114
|
-
"text-halign": "center",
|
|
115
|
-
"text-valign": "center"
|
|
116
|
-
};
|
|
117
|
-
break;
|
|
118
|
-
case "left":
|
|
119
|
-
r = {
|
|
120
|
-
...r,
|
|
121
|
-
"text-halign": "left",
|
|
122
|
-
"text-valign": "center",
|
|
123
|
-
"text-margin-x": "-5px"
|
|
124
|
-
};
|
|
125
|
-
break;
|
|
126
|
-
case "right":
|
|
127
|
-
r = {
|
|
128
|
-
...r,
|
|
129
|
-
"text-halign": "right",
|
|
130
|
-
"text-valign": "center",
|
|
131
|
-
"text-margin-x": "5px"
|
|
132
|
-
};
|
|
133
|
-
break;
|
|
134
|
-
case "top":
|
|
135
|
-
r = {
|
|
136
|
-
...r,
|
|
137
|
-
"text-halign": "center",
|
|
138
|
-
"text-valign": "top",
|
|
139
|
-
"text-margin-y": "-5px"
|
|
140
|
-
};
|
|
141
|
-
break;
|
|
142
|
-
case "bottom":
|
|
143
|
-
r = {
|
|
144
|
-
...r,
|
|
145
|
-
"text-halign": "center",
|
|
146
|
-
"text-valign": "bottom",
|
|
147
|
-
"text-margin-y": "5px"
|
|
148
|
-
};
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
n.nodes().style(r), n.style().update();
|
|
152
|
-
}, _ = async (e, { pathNodes: t, isGrayed: n = !0 }) => {
|
|
153
|
-
let r = e.current;
|
|
154
|
-
if (!r) return;
|
|
155
|
-
if (t?.length < 2) {
|
|
156
|
-
f.warning("请至少设置 2 个路径节点!");
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
if ([...new Set(t)].length !== t.length) {
|
|
160
|
-
f.warning("路径中存在重复节点,请检查!");
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
let i = [];
|
|
164
|
-
for (let e of t) {
|
|
165
|
-
let t = r.nodes().filter((t) => t.data("name") === e);
|
|
166
|
-
if (t.length > 0) i.push(t.id());
|
|
167
|
-
else {
|
|
168
|
-
r.nodes().removeClass("path-node"), r.edges().removeClass("path-edge"), f.warning(`找不到节点:${e}`);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
try {
|
|
173
|
-
r.nodes().removeClass("path-node").removeClass("grayed"), r.edges().removeClass("path-edge").removeClass("grayed");
|
|
174
|
-
let e = r.collection(), a = 0, o = !0, s = [];
|
|
175
|
-
for (let n = 0; n < i.length - 1; n++) {
|
|
176
|
-
let c = i[n], l = i[n + 1], u = r.getElementById(c), d = r.getElementById(l), f = u.edgesWith(d).filter(function(e) {
|
|
177
|
-
return e.data("source") === c && e.data("target") === l;
|
|
178
|
-
}), p = d.edgesWith(u).filter(function(e) {
|
|
179
|
-
return e.data("source") === l && e.data("target") === c;
|
|
180
|
-
});
|
|
181
|
-
if (f.length > 0 || p.length > 0) {
|
|
182
|
-
let t = f.add(p);
|
|
183
|
-
e = e.union(t).union(u).union(d), a += t.length, u.addClass("path-node"), d.addClass("path-node"), t.addClass("path-edge"), s.push(u.data("name"), d.data("name")), console.log(`找到直接连接的边:正向${f.length}条,反向${p.length}条`);
|
|
184
|
-
} else {
|
|
185
|
-
let i = r.elements().aStar({
|
|
186
|
-
root: u,
|
|
187
|
-
goal: d,
|
|
188
|
-
directed: !1
|
|
189
|
-
});
|
|
190
|
-
if (i.found && i.path) {
|
|
191
|
-
e = e.union(i.path), a += i.distance, i.path.nodes().addClass("path-node"), i.path.edges().addClass("path-edge");
|
|
192
|
-
let t = i.path.nodes().map((e) => e.data("name"));
|
|
193
|
-
s.push(...t);
|
|
194
|
-
} else {
|
|
195
|
-
o = !1, console.log(`节点 ${t[n]} 和 ${t[n + 1]} 之间没有路径`);
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if (o && e.length > 0) {
|
|
201
|
-
let t = e.nodes(), i = e.edges();
|
|
202
|
-
t.addClass("path-node"), i.addClass("path-edge"), n && (r.nodes().not(t).addClass("grayed"), r.edges().not(i).addClass("grayed"));
|
|
203
|
-
} else f.warning("无法找到完整的路径!");
|
|
1
|
+
//#region src/utils/tools.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
if (n(e) || Array.isArray(e)) try {
|
|
4
|
+
return JSON.stringify(e);
|
|
204
5
|
} catch (e) {
|
|
205
|
-
console.
|
|
206
|
-
}
|
|
207
|
-
}, v = (e) => ({
|
|
208
|
-
nodes: e.nodes().map((e) => ({
|
|
209
|
-
data: e.data(),
|
|
210
|
-
position: e.position(),
|
|
211
|
-
style: {
|
|
212
|
-
width: e.style("width"),
|
|
213
|
-
height: e.style("height"),
|
|
214
|
-
backgroundColor: e.style("background-color")
|
|
215
|
-
}
|
|
216
|
-
})),
|
|
217
|
-
edges: e.edges().map((e) => ({
|
|
218
|
-
data: e.data(),
|
|
219
|
-
style: {
|
|
220
|
-
width: e.style("width"),
|
|
221
|
-
"line-color": e.style("line-color"),
|
|
222
|
-
"target-arrow-color": e.style("target-arrow-color")
|
|
223
|
-
}
|
|
224
|
-
}))
|
|
225
|
-
}), y = (e) => {
|
|
226
|
-
let t = v(e), n = new Blob([JSON.stringify(t, null, 2)], { type: "application/json" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
227
|
-
i.href = r, i.download = `graph-data-${Date.now()}.json`, i.click(), URL.revokeObjectURL(r);
|
|
228
|
-
}, b = [
|
|
229
|
-
{
|
|
230
|
-
label: "网络布局",
|
|
231
|
-
key: "cose-bilkent"
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
label: "弹性布局",
|
|
235
|
-
key: "fcose"
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
label: "网格布局",
|
|
239
|
-
key: "grid"
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
label: "球面布局",
|
|
243
|
-
key: "circle"
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
label: "层级布局",
|
|
247
|
-
key: "breadthfirst"
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
label: "同心圆布局",
|
|
251
|
-
key: "concentric"
|
|
6
|
+
console.log("JSON.stringify", e);
|
|
252
7
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
], S = [
|
|
270
|
-
{
|
|
271
|
-
label: "全选",
|
|
272
|
-
key: "all"
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
label: "反选",
|
|
276
|
-
key: "reverse"
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
label: "点选模式",
|
|
280
|
-
key: "click"
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
label: "框选模式",
|
|
284
|
-
key: "box"
|
|
285
|
-
}
|
|
286
|
-
], C = [
|
|
287
|
-
{
|
|
288
|
-
label: "下载JSON",
|
|
289
|
-
key: "downloadJson"
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
label: "预览JSON列表",
|
|
293
|
-
key: "previewJsonList"
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
label: "下载EXCEL",
|
|
297
|
-
key: "downloadExcel"
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
label: "下载JPG",
|
|
301
|
-
key: "downloadJpg"
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
label: "下载PNG",
|
|
305
|
-
key: "downloadPng"
|
|
306
|
-
}
|
|
307
|
-
], w = [
|
|
308
|
-
{
|
|
309
|
-
label: "居中",
|
|
310
|
-
key: "center"
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
label: "顶部",
|
|
314
|
-
key: "top"
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
label: "底部",
|
|
318
|
-
key: "bottom"
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
label: "左侧",
|
|
322
|
-
key: "left"
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
label: "右侧",
|
|
326
|
-
key: "right"
|
|
327
|
-
}
|
|
328
|
-
];
|
|
8
|
+
else return e;
|
|
9
|
+
}, t = (e) => {
|
|
10
|
+
if (n(e) || Array.isArray(e)) try {
|
|
11
|
+
return JSON.parse(JSON.stringify(e));
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.log("JSON.stringify-JSON.parse", e);
|
|
14
|
+
}
|
|
15
|
+
else return e;
|
|
16
|
+
};
|
|
17
|
+
function n(e) {
|
|
18
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
19
|
+
}
|
|
20
|
+
var r = (e, t) => {
|
|
21
|
+
let n = document.createElement("a");
|
|
22
|
+
n.href = e, n.download = t, document.body.appendChild(n), n.click(), document.body.removeChild(n);
|
|
23
|
+
};
|
|
329
24
|
//#endregion
|
|
330
|
-
export {
|
|
25
|
+
export { r as downloadFile, e as jsonStringify, t as jsonStringifyParse };
|
package/lib/index18.es.js
CHANGED
|
@@ -1,5 +1,330 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import e from "./index6.es.js";
|
|
2
|
+
import t from "./index7.es.js";
|
|
3
|
+
import n from "./index8.es.js";
|
|
4
|
+
import r from "./index9.es.js";
|
|
5
|
+
import i from "./index10.es.js";
|
|
6
|
+
import a from "./index11.es.js";
|
|
7
|
+
import o from "./index12.es.js";
|
|
8
|
+
import s from "./index13.es.js";
|
|
9
|
+
import c from "./index14.es.js";
|
|
10
|
+
import l from "./index15.es.js";
|
|
11
|
+
import u from "./index16.es.js";
|
|
12
|
+
import { jsonStringifyParse as d } from "./index17.es.js";
|
|
13
|
+
import { message as f } from "antd";
|
|
14
|
+
//#region src/components/Graph/utils/tools.ts
|
|
15
|
+
var p = [
|
|
16
|
+
e,
|
|
17
|
+
t,
|
|
18
|
+
n,
|
|
19
|
+
r,
|
|
20
|
+
i,
|
|
21
|
+
a,
|
|
22
|
+
o,
|
|
23
|
+
s,
|
|
24
|
+
c,
|
|
25
|
+
l
|
|
26
|
+
], m = (e) => {
|
|
27
|
+
let t = {}, n = {}, r = [];
|
|
28
|
+
return e.forEach((e) => {
|
|
29
|
+
let { group: i } = e;
|
|
30
|
+
if (i === "nodes") {
|
|
31
|
+
let n = e.data, i = n.properties?.type, a = n.type;
|
|
32
|
+
!a && i === "uri" || (!r.includes(a) && i === "uri" ? (r.push(a), t = {
|
|
33
|
+
...t,
|
|
34
|
+
[a]: {
|
|
35
|
+
...t[a],
|
|
36
|
+
count: 1,
|
|
37
|
+
img: n.image
|
|
38
|
+
}
|
|
39
|
+
}) : i === "uri" && a && (t = {
|
|
40
|
+
...t,
|
|
41
|
+
[a]: {
|
|
42
|
+
...t[a],
|
|
43
|
+
img: n.image,
|
|
44
|
+
count: t[a].count + 1
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
} else if (i === "edges") {
|
|
48
|
+
let { label: t } = e.data;
|
|
49
|
+
n[t] ? n[t] = n[t] + 1 : n[t] = 1;
|
|
50
|
+
} else console.log("nonono");
|
|
51
|
+
}), {
|
|
52
|
+
typeListArr: r,
|
|
53
|
+
typeListObj: t,
|
|
54
|
+
relationListObj: n
|
|
55
|
+
};
|
|
56
|
+
}, h = (e, { graphData: t = [], typeObj: n, zktype: r, graphInfo: i = {} }) => {
|
|
57
|
+
let a = d(n), o = Object.keys(n), s = i.searchNodes || [], c = new Set(t?.map((e) => e.group === "nodes" ? e.data?.id : e.data?.source + "-" + e.data?.target).filter(Boolean) || []), { nodes: l = [], links: f = [] } = e || {}, h = [];
|
|
58
|
+
((e) => {
|
|
59
|
+
e.forEach((e) => {
|
|
60
|
+
let { label: t } = e, n = `${e.source}-${e.target}`;
|
|
61
|
+
c.has(n) || h.push({
|
|
62
|
+
group: "edges",
|
|
63
|
+
data: {
|
|
64
|
+
...e,
|
|
65
|
+
name: t,
|
|
66
|
+
zktype: r
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
})(f), ((e) => {
|
|
71
|
+
e.forEach((e) => {
|
|
72
|
+
if (!c.has(e.id)) {
|
|
73
|
+
let t = e.properties?.type, n = e.type, r = e.label.split("#").pop(), i = -1;
|
|
74
|
+
if (!n && t === "uri") i = e.image || p[0];
|
|
75
|
+
else if (!o.includes(n) && t === "uri") {
|
|
76
|
+
o.push(n);
|
|
77
|
+
let t = o.indexOf(n);
|
|
78
|
+
i = e.image || p[t] || p[0], a = {
|
|
79
|
+
...a,
|
|
80
|
+
[n]: {
|
|
81
|
+
...a[n],
|
|
82
|
+
img: i
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
} else t === "uri" && n && (i = a[n]?.img);
|
|
86
|
+
let c = {
|
|
87
|
+
...e,
|
|
88
|
+
name: r,
|
|
89
|
+
"properties-type": t,
|
|
90
|
+
image: s.includes(r) ? u : i,
|
|
91
|
+
baseWidth: 80,
|
|
92
|
+
baseHeight: 80
|
|
93
|
+
};
|
|
94
|
+
h.push({
|
|
95
|
+
group: "nodes",
|
|
96
|
+
data: c
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
})(l);
|
|
101
|
+
let { typeListObj: g, relationListObj: _ } = m([...h, ...t]);
|
|
102
|
+
return {
|
|
103
|
+
elements: h,
|
|
104
|
+
typeListObj: g,
|
|
105
|
+
relationListObj: _
|
|
106
|
+
};
|
|
107
|
+
}, g = (e, t) => {
|
|
108
|
+
let n = e.current;
|
|
109
|
+
if (!n) return;
|
|
110
|
+
let r = { color: "#000" };
|
|
111
|
+
switch (t) {
|
|
112
|
+
case "center":
|
|
113
|
+
r = {
|
|
114
|
+
"text-halign": "center",
|
|
115
|
+
"text-valign": "center"
|
|
116
|
+
};
|
|
117
|
+
break;
|
|
118
|
+
case "left":
|
|
119
|
+
r = {
|
|
120
|
+
...r,
|
|
121
|
+
"text-halign": "left",
|
|
122
|
+
"text-valign": "center",
|
|
123
|
+
"text-margin-x": "-5px"
|
|
124
|
+
};
|
|
125
|
+
break;
|
|
126
|
+
case "right":
|
|
127
|
+
r = {
|
|
128
|
+
...r,
|
|
129
|
+
"text-halign": "right",
|
|
130
|
+
"text-valign": "center",
|
|
131
|
+
"text-margin-x": "5px"
|
|
132
|
+
};
|
|
133
|
+
break;
|
|
134
|
+
case "top":
|
|
135
|
+
r = {
|
|
136
|
+
...r,
|
|
137
|
+
"text-halign": "center",
|
|
138
|
+
"text-valign": "top",
|
|
139
|
+
"text-margin-y": "-5px"
|
|
140
|
+
};
|
|
141
|
+
break;
|
|
142
|
+
case "bottom":
|
|
143
|
+
r = {
|
|
144
|
+
...r,
|
|
145
|
+
"text-halign": "center",
|
|
146
|
+
"text-valign": "bottom",
|
|
147
|
+
"text-margin-y": "5px"
|
|
148
|
+
};
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
n.nodes().style(r), n.style().update();
|
|
152
|
+
}, _ = async (e, { pathNodes: t, isGrayed: n = !0 }) => {
|
|
153
|
+
let r = e.current;
|
|
154
|
+
if (!r) return;
|
|
155
|
+
if (t?.length < 2) {
|
|
156
|
+
f.warning("请至少设置 2 个路径节点!");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if ([...new Set(t)].length !== t.length) {
|
|
160
|
+
f.warning("路径中存在重复节点,请检查!");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
let i = [];
|
|
164
|
+
for (let e of t) {
|
|
165
|
+
let t = r.nodes().filter((t) => t.data("name") === e);
|
|
166
|
+
if (t.length > 0) i.push(t.id());
|
|
167
|
+
else {
|
|
168
|
+
r.nodes().removeClass("path-node"), r.edges().removeClass("path-edge"), f.warning(`找不到节点:${e}`);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
r.nodes().removeClass("path-node").removeClass("grayed"), r.edges().removeClass("path-edge").removeClass("grayed");
|
|
174
|
+
let e = r.collection(), a = 0, o = !0, s = [];
|
|
175
|
+
for (let n = 0; n < i.length - 1; n++) {
|
|
176
|
+
let c = i[n], l = i[n + 1], u = r.getElementById(c), d = r.getElementById(l), f = u.edgesWith(d).filter(function(e) {
|
|
177
|
+
return e.data("source") === c && e.data("target") === l;
|
|
178
|
+
}), p = d.edgesWith(u).filter(function(e) {
|
|
179
|
+
return e.data("source") === l && e.data("target") === c;
|
|
180
|
+
});
|
|
181
|
+
if (f.length > 0 || p.length > 0) {
|
|
182
|
+
let t = f.add(p);
|
|
183
|
+
e = e.union(t).union(u).union(d), a += t.length, u.addClass("path-node"), d.addClass("path-node"), t.addClass("path-edge"), s.push(u.data("name"), d.data("name")), console.log(`找到直接连接的边:正向${f.length}条,反向${p.length}条`);
|
|
184
|
+
} else {
|
|
185
|
+
let i = r.elements().aStar({
|
|
186
|
+
root: u,
|
|
187
|
+
goal: d,
|
|
188
|
+
directed: !1
|
|
189
|
+
});
|
|
190
|
+
if (i.found && i.path) {
|
|
191
|
+
e = e.union(i.path), a += i.distance, i.path.nodes().addClass("path-node"), i.path.edges().addClass("path-edge");
|
|
192
|
+
let t = i.path.nodes().map((e) => e.data("name"));
|
|
193
|
+
s.push(...t);
|
|
194
|
+
} else {
|
|
195
|
+
o = !1, console.log(`节点 ${t[n]} 和 ${t[n + 1]} 之间没有路径`);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (o && e.length > 0) {
|
|
201
|
+
let t = e.nodes(), i = e.edges();
|
|
202
|
+
t.addClass("path-node"), i.addClass("path-edge"), n && (r.nodes().not(t).addClass("grayed"), r.edges().not(i).addClass("grayed"));
|
|
203
|
+
} else f.warning("无法找到完整的路径!");
|
|
204
|
+
} catch (e) {
|
|
205
|
+
console.error(2e3, "计算路径时出错:", e), f.warning("计算路径时出错,请重试!");
|
|
206
|
+
}
|
|
207
|
+
}, v = (e) => ({
|
|
208
|
+
nodes: e.nodes().map((e) => ({
|
|
209
|
+
data: e.data(),
|
|
210
|
+
position: e.position(),
|
|
211
|
+
style: {
|
|
212
|
+
width: e.style("width"),
|
|
213
|
+
height: e.style("height"),
|
|
214
|
+
backgroundColor: e.style("background-color")
|
|
215
|
+
}
|
|
216
|
+
})),
|
|
217
|
+
edges: e.edges().map((e) => ({
|
|
218
|
+
data: e.data(),
|
|
219
|
+
style: {
|
|
220
|
+
width: e.style("width"),
|
|
221
|
+
"line-color": e.style("line-color"),
|
|
222
|
+
"target-arrow-color": e.style("target-arrow-color")
|
|
223
|
+
}
|
|
224
|
+
}))
|
|
225
|
+
}), y = (e) => {
|
|
226
|
+
let t = v(e), n = new Blob([JSON.stringify(t, null, 2)], { type: "application/json" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
227
|
+
i.href = r, i.download = `graph-data-${Date.now()}.json`, i.click(), URL.revokeObjectURL(r);
|
|
228
|
+
}, b = [
|
|
229
|
+
{
|
|
230
|
+
label: "网络布局",
|
|
231
|
+
key: "cose-bilkent"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
label: "弹性布局",
|
|
235
|
+
key: "fcose"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
label: "网格布局",
|
|
239
|
+
key: "grid"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
label: "球面布局",
|
|
243
|
+
key: "circle"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
label: "层级布局",
|
|
247
|
+
key: "breadthfirst"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
label: "同心圆布局",
|
|
251
|
+
key: "concentric"
|
|
252
|
+
}
|
|
253
|
+
], x = [
|
|
254
|
+
{
|
|
255
|
+
label: "查询节点",
|
|
256
|
+
key: "query",
|
|
257
|
+
func: "queryNode"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
label: "连接分析",
|
|
261
|
+
key: "link",
|
|
262
|
+
func: "onLevelClick"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
label: "路径分析",
|
|
266
|
+
key: "path",
|
|
267
|
+
func: "pathAnalysis"
|
|
268
|
+
}
|
|
269
|
+
], S = [
|
|
270
|
+
{
|
|
271
|
+
label: "全选",
|
|
272
|
+
key: "all"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
label: "反选",
|
|
276
|
+
key: "reverse"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
label: "点选模式",
|
|
280
|
+
key: "click"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
label: "框选模式",
|
|
284
|
+
key: "box"
|
|
285
|
+
}
|
|
286
|
+
], C = [
|
|
287
|
+
{
|
|
288
|
+
label: "下载JSON",
|
|
289
|
+
key: "downloadJson"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
label: "预览JSON列表",
|
|
293
|
+
key: "previewJsonList"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
label: "下载EXCEL",
|
|
297
|
+
key: "downloadExcel"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
label: "下载JPG",
|
|
301
|
+
key: "downloadJpg"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
label: "下载PNG",
|
|
305
|
+
key: "downloadPng"
|
|
306
|
+
}
|
|
307
|
+
], w = [
|
|
308
|
+
{
|
|
309
|
+
label: "居中",
|
|
310
|
+
key: "center"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
label: "顶部",
|
|
314
|
+
key: "top"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
label: "底部",
|
|
318
|
+
key: "bottom"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
label: "左侧",
|
|
322
|
+
key: "left"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
label: "右侧",
|
|
326
|
+
key: "right"
|
|
327
|
+
}
|
|
328
|
+
];
|
|
4
329
|
//#endregion
|
|
5
|
-
export {
|
|
330
|
+
export { S as choiceConfig, y as donwnGraphData, C as downloadData, v as getCyData, _ as handleCalcPath, b as layoutCongig, x as linkAnalysis, h as resDetailData, g as textLayout, w as textPositionConfig };
|