react-kggraph 0.0.1
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.md +16 -0
- package/lib/components/Graph/CytoscapeReact.css +1 -0
- package/lib/components/Graph/components/ActionBar/index.css +1 -0
- package/lib/components/Graph/components/PathAnalysis/index.css +1 -0
- package/lib/components/Graph/components/PathAnalysisLevel/index.css +1 -0
- package/lib/components/Graph/components/SettingCircle/index.css +1 -0
- package/lib/favicon.svg +1 -0
- package/lib/icons.svg +24 -0
- package/lib/index.cjs.js +1 -0
- package/lib/index.esm.js +3 -0
- package/lib/index10.cjs.js +1 -0
- package/lib/index10.esm.js +4 -0
- package/lib/index11.cjs.js +1 -0
- package/lib/index11.esm.js +4 -0
- package/lib/index12.cjs.js +1 -0
- package/lib/index12.esm.js +4 -0
- package/lib/index13.cjs.js +1 -0
- package/lib/index13.esm.js +4 -0
- package/lib/index14.cjs.js +1 -0
- package/lib/index14.esm.js +4 -0
- package/lib/index15.cjs.js +1 -0
- package/lib/index15.esm.js +4 -0
- package/lib/index16.cjs.js +1 -0
- package/lib/index16.esm.js +25 -0
- package/lib/index17.cjs.js +1 -0
- package/lib/index17.esm.js +330 -0
- package/lib/index18.cjs.js +1 -0
- package/lib/index18.esm.js +5 -0
- package/lib/index19.cjs.js +1 -0
- package/lib/index19.esm.js +284 -0
- package/lib/index2.cjs.js +1 -0
- package/lib/index2.esm.js +16 -0
- package/lib/index21.cjs.js +1 -0
- package/lib/index21.esm.js +27 -0
- package/lib/index22.cjs.js +16 -0
- package/lib/index22.esm.js +453 -0
- package/lib/index23.cjs.js +1 -0
- package/lib/index23.esm.js +10 -0
- package/lib/index24.cjs.js +1 -0
- package/lib/index24.esm.js +70 -0
- package/lib/index26.cjs.js +1 -0
- package/lib/index26.esm.js +68 -0
- package/lib/index28.cjs.js +1 -0
- package/lib/index28.esm.js +72 -0
- package/lib/index29.cjs.js +1 -0
- package/lib/index29.esm.js +32 -0
- package/lib/index30.cjs.js +1 -0
- package/lib/index30.esm.js +828 -0
- package/lib/index32.cjs.js +1 -0
- package/lib/index32.esm.js +4 -0
- package/lib/index33.cjs.js +1 -0
- package/lib/index33.esm.js +161 -0
- package/lib/index34.cjs.js +1 -0
- package/lib/index34.esm.js +71 -0
- package/lib/index36.cjs.js +1 -0
- package/lib/index36.esm.js +100 -0
- package/lib/index37.cjs.js +1 -0
- package/lib/index37.esm.js +250 -0
- package/lib/index38.cjs.js +1 -0
- package/lib/index38.esm.js +47 -0
- package/lib/index39.cjs.js +1 -0
- package/lib/index39.esm.js +378 -0
- package/lib/index4.cjs.js +95 -0
- package/lib/index4.esm.js +12387 -0
- package/lib/index40.cjs.js +1 -0
- package/lib/index40.esm.js +6 -0
- package/lib/index5.cjs.js +1 -0
- package/lib/index5.esm.js +4 -0
- package/lib/index6.cjs.js +1 -0
- package/lib/index6.esm.js +4 -0
- package/lib/index7.cjs.js +1 -0
- package/lib/index7.esm.js +4 -0
- package/lib/index8.cjs.js +1 -0
- package/lib/index8.esm.js +4 -0
- package/lib/index9.cjs.js +1 -0
- package/lib/index9.esm.js +4 -0
- package/lib/src/components/Graph/api.d.ts +2 -0
- package/lib/src/components/Graph/components/ActionBar/index.d.ts +9 -0
- package/lib/src/components/Graph/components/KnowledgeCard/index.d.ts +3 -0
- package/lib/src/components/Graph/components/NodeInfoDrawer/index.d.ts +3 -0
- package/lib/src/components/Graph/components/PathAnalysis/index.d.ts +9 -0
- package/lib/src/components/Graph/components/PathAnalysisLevel/index.d.ts +5 -0
- package/lib/src/components/Graph/components/QueryNode/index.d.ts +8 -0
- package/lib/src/components/Graph/components/SettingCircle/index.d.ts +13 -0
- package/lib/src/components/Graph/context.d.ts +2 -0
- package/lib/src/components/Graph/index.d.ts +8 -0
- package/lib/src/components/Graph/types.d.ts +6 -0
- package/lib/src/components/Graph/utils/edge_node_styles.d.ts +3 -0
- package/lib/src/components/Graph/utils/layouts.d.ts +108 -0
- package/lib/src/components/Graph/utils/menuItems.d.ts +1 -0
- package/lib/src/components/Graph/utils/tools.d.ts +38 -0
- package/package.json +64 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import e from "./index5.esm.js";
|
|
2
|
+
import t from "./index6.esm.js";
|
|
3
|
+
import n from "./index7.esm.js";
|
|
4
|
+
import r from "./index8.esm.js";
|
|
5
|
+
import i from "./index9.esm.js";
|
|
6
|
+
import a from "./index10.esm.js";
|
|
7
|
+
import o from "./index11.esm.js";
|
|
8
|
+
import s from "./index12.esm.js";
|
|
9
|
+
import c from "./index13.esm.js";
|
|
10
|
+
import l from "./index14.esm.js";
|
|
11
|
+
import u from "./index15.esm.js";
|
|
12
|
+
import { jsonStringifyParse as d } from "./index16.esm.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
|
+
];
|
|
329
|
+
//#endregion
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./index2.cjs.js`);var e=(0,require(`react`).createContext)({}),t=e.Provider;exports.GraphContext=e,exports.GraphProvider=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=(e,n,r,i=20)=>{let a=e.nodes(),o=a.filter(e=>e.data(`name`)===n),s=a.filter(e=>e.data(`name`)===r);if(console.log(111,!o.data()||!s.data(),o.data(),s.data()),!o.data()||!s.data()){console.warn(`fixNodesToEdges: 未找到左右节点`,n,r);let i=e.layout(t());return i.run(),i.on(`layoutstop`,()=>{e.fit(void 0,50)}),!1}let c=e.width();if(c===0)return!1;let l=o.width()||60,u=e.height()/2,d=l/2+i,f=c-l/2-i;o.position({x:d,y:u}),s.position({x:f,y:u}),o.lock(),s.lock();let p=e.nodes().difference(o).difference(s);if(p.length>0){p.forEach(e=>{let t=e.position().x,n=Math.min(d,t),r=Math.max(f,t);e.position({x:n+(r-n)*.5,y:u})});let n=e.layout({...t(),nodes:p});n.run(),n.on(`layoutstop`,()=>{e.fit(void 0,50),o.unlock(),s.unlock(),console.log(`布局完成`)})}else e.fit(void 0,50);return console.log(`fixNodesToEdges: 完成`),!0},t=()=>({name:`cose-bilkent`,nodeRepulsion:1005e3,idealEdgeLength:100,edgeElasticity:.3,numIter:2500,fit:!0,padding:50,randomize:!1,animate:`end`,animationDuration:1e3,nodeDimensionsIncludeLabels:!0,tile:!0,tilingPaddingVertical:15,tilingPaddingHorizontal:15,gravity:.6,nestingFactor:.1,gravityRange:3,gravityRangeCompound:1.5,gravityCompound:1,initialEnergyOnIncremental:.5,refresh:30}),n=(e,n)=>{console.log(111,n);let u=e.current;if(!u)return;let d={};switch(n){case`circle`:d=a();break;case`concentric`:console.log(`执行圆形布局`),d=o();break;case`grid`:console.log(`执行网格布局`),d=c();break;case`breadthfirst`:console.log(`执行树型布局`),d=l();break;case`random`:console.log(`执行随机布局`),d=r();break;case`cose`:console.log(`执行 cose 布局`),d=i();break;case`cose-bilkent`:console.log(`执行 cose-bilkent 布局`),d=t();break;case`fcose`:console.log(`执行 fcose 布局`),d=s();break;case`cise`:console.log(`执行 cise 布局`),d={name:`cise`,clusters:[],animate:!1,fit:!0,padding:30,nodeSeparation:80,idealEdgeLength:80,idealInterClusterEdgeLengthCoefficient:1.5,maxIteration:500};break;default:console.warn(`未知布局类型:`,n);return}u.layout(d).run()},r=()=>({name:`random`,fit:!0,padding:30,boundingBox:void 0,animate:!0,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}}),i=()=>({name:`cose`,ready:function(){},stop:function(){},animate:!0,animationEasing:void 0,animationDuration:void 0,animateFilter:function(e,t){return!0},animationThreshold:250,refresh:20,fit:!0,padding:30,boundingBox:void 0,nodeDimensionsIncludeLabels:!1,randomize:!1,componentSpacing:40,nodeRepulsion:function(e){return 2048},nodeOverlap:4,idealEdgeLength:function(e){return 32},edgeElasticity:function(e){return 32},nestingFactor:1.2,gravity:1,numIter:8e3,initialTemp:1e3,coolingFactor:.99,minTemp:1}),a=()=>({name:`circle`,fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:1.2,radius:void 0,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!0,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}}),o=()=>({name:`concentric`,fit:!0,padding:30,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:3,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!0,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}}),s=()=>({name:`fcose`,idealEdgeLength:50,edgeElasticity:80,nodeRepulsion:12e3,nodeOverlap:0,spacingFactor:2,nestingFactor:5,gravity:0,numIter:3e3,tile:!0,animate:`end`,animationDuration:1e3,randomize:!0,fit:!0,padding:50,nodeDimensionsIncludeLabels:!0}),c=()=>({name:`grid`,fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!0,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}}),l=()=>({name:`breadthfirst`,fit:!0,directed:!1,direction:`downward`,padding:30,circle:!1,grid:!1,spacingFactor:1,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,roots:void 0,depthSort:void 0,animate:!0,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}});exports.coseBilkentLayout=t,exports.fixNodesToEdges=e,exports.layout=n;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
//#region src/components/Graph/utils/layouts.ts
|
|
2
|
+
var e = (e, n, r, i = 20) => {
|
|
3
|
+
let a = e.nodes(), o = a.filter((e) => e.data("name") === n), s = a.filter((e) => e.data("name") === r);
|
|
4
|
+
if (console.log(111, !o.data() || !s.data(), o.data(), s.data()), !o.data() || !s.data()) {
|
|
5
|
+
console.warn("fixNodesToEdges: 未找到左右节点", n, r);
|
|
6
|
+
let i = e.layout(t());
|
|
7
|
+
return i.run(), i.on("layoutstop", () => {
|
|
8
|
+
e.fit(void 0, 50);
|
|
9
|
+
}), !1;
|
|
10
|
+
}
|
|
11
|
+
let c = e.width();
|
|
12
|
+
if (c === 0) return !1;
|
|
13
|
+
let l = o.width() || 60, u = e.height() / 2, d = l / 2 + i, f = c - l / 2 - i;
|
|
14
|
+
o.position({
|
|
15
|
+
x: d,
|
|
16
|
+
y: u
|
|
17
|
+
}), s.position({
|
|
18
|
+
x: f,
|
|
19
|
+
y: u
|
|
20
|
+
}), o.lock(), s.lock();
|
|
21
|
+
let p = e.nodes().difference(o).difference(s);
|
|
22
|
+
if (p.length > 0) {
|
|
23
|
+
p.forEach((e) => {
|
|
24
|
+
let t = e.position().x, n = Math.min(d, t), r = Math.max(f, t);
|
|
25
|
+
e.position({
|
|
26
|
+
x: n + (r - n) * .5,
|
|
27
|
+
y: u
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
let n = e.layout({
|
|
31
|
+
...t(),
|
|
32
|
+
nodes: p
|
|
33
|
+
});
|
|
34
|
+
n.run(), n.on("layoutstop", () => {
|
|
35
|
+
e.fit(void 0, 50), o.unlock(), s.unlock(), console.log("布局完成");
|
|
36
|
+
});
|
|
37
|
+
} else e.fit(void 0, 50);
|
|
38
|
+
return console.log("fixNodesToEdges: 完成"), !0;
|
|
39
|
+
}, t = () => ({
|
|
40
|
+
name: "cose-bilkent",
|
|
41
|
+
nodeRepulsion: 1005e3,
|
|
42
|
+
idealEdgeLength: 100,
|
|
43
|
+
edgeElasticity: .3,
|
|
44
|
+
numIter: 2500,
|
|
45
|
+
fit: !0,
|
|
46
|
+
padding: 50,
|
|
47
|
+
randomize: !1,
|
|
48
|
+
animate: "end",
|
|
49
|
+
animationDuration: 1e3,
|
|
50
|
+
nodeDimensionsIncludeLabels: !0,
|
|
51
|
+
tile: !0,
|
|
52
|
+
tilingPaddingVertical: 15,
|
|
53
|
+
tilingPaddingHorizontal: 15,
|
|
54
|
+
gravity: .6,
|
|
55
|
+
nestingFactor: .1,
|
|
56
|
+
gravityRange: 3,
|
|
57
|
+
gravityRangeCompound: 1.5,
|
|
58
|
+
gravityCompound: 1,
|
|
59
|
+
initialEnergyOnIncremental: .5,
|
|
60
|
+
refresh: 30
|
|
61
|
+
}), n = (e, n) => {
|
|
62
|
+
console.log(111, n);
|
|
63
|
+
let u = e.current;
|
|
64
|
+
if (!u) return;
|
|
65
|
+
let d = {};
|
|
66
|
+
switch (n) {
|
|
67
|
+
case "circle":
|
|
68
|
+
d = a();
|
|
69
|
+
break;
|
|
70
|
+
case "concentric":
|
|
71
|
+
console.log("执行圆形布局"), d = o();
|
|
72
|
+
break;
|
|
73
|
+
case "grid":
|
|
74
|
+
console.log("执行网格布局"), d = c();
|
|
75
|
+
break;
|
|
76
|
+
case "breadthfirst":
|
|
77
|
+
console.log("执行树型布局"), d = l();
|
|
78
|
+
break;
|
|
79
|
+
case "random":
|
|
80
|
+
console.log("执行随机布局"), d = r();
|
|
81
|
+
break;
|
|
82
|
+
case "cose":
|
|
83
|
+
console.log("执行 cose 布局"), d = i();
|
|
84
|
+
break;
|
|
85
|
+
case "cose-bilkent":
|
|
86
|
+
console.log("执行 cose-bilkent 布局"), d = t();
|
|
87
|
+
break;
|
|
88
|
+
case "fcose":
|
|
89
|
+
console.log("执行 fcose 布局"), d = s();
|
|
90
|
+
break;
|
|
91
|
+
case "cise":
|
|
92
|
+
console.log("执行 cise 布局"), d = {
|
|
93
|
+
name: "cise",
|
|
94
|
+
clusters: [],
|
|
95
|
+
animate: !1,
|
|
96
|
+
fit: !0,
|
|
97
|
+
padding: 30,
|
|
98
|
+
nodeSeparation: 80,
|
|
99
|
+
idealEdgeLength: 80,
|
|
100
|
+
idealInterClusterEdgeLengthCoefficient: 1.5,
|
|
101
|
+
maxIteration: 500
|
|
102
|
+
};
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
console.warn("未知布局类型:", n);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
u.layout(d).run();
|
|
109
|
+
}, r = () => ({
|
|
110
|
+
name: "random",
|
|
111
|
+
fit: !0,
|
|
112
|
+
padding: 30,
|
|
113
|
+
boundingBox: void 0,
|
|
114
|
+
animate: !0,
|
|
115
|
+
animationDuration: 500,
|
|
116
|
+
animationEasing: void 0,
|
|
117
|
+
animateFilter: function(e, t) {
|
|
118
|
+
return !0;
|
|
119
|
+
},
|
|
120
|
+
ready: void 0,
|
|
121
|
+
stop: void 0,
|
|
122
|
+
transform: function(e, t) {
|
|
123
|
+
return t;
|
|
124
|
+
}
|
|
125
|
+
}), i = () => ({
|
|
126
|
+
name: "cose",
|
|
127
|
+
ready: function() {},
|
|
128
|
+
stop: function() {},
|
|
129
|
+
animate: !0,
|
|
130
|
+
animationEasing: void 0,
|
|
131
|
+
animationDuration: void 0,
|
|
132
|
+
animateFilter: function(e, t) {
|
|
133
|
+
return !0;
|
|
134
|
+
},
|
|
135
|
+
animationThreshold: 250,
|
|
136
|
+
refresh: 20,
|
|
137
|
+
fit: !0,
|
|
138
|
+
padding: 30,
|
|
139
|
+
boundingBox: void 0,
|
|
140
|
+
nodeDimensionsIncludeLabels: !1,
|
|
141
|
+
randomize: !1,
|
|
142
|
+
componentSpacing: 40,
|
|
143
|
+
nodeRepulsion: function(e) {
|
|
144
|
+
return 2048;
|
|
145
|
+
},
|
|
146
|
+
nodeOverlap: 4,
|
|
147
|
+
idealEdgeLength: function(e) {
|
|
148
|
+
return 32;
|
|
149
|
+
},
|
|
150
|
+
edgeElasticity: function(e) {
|
|
151
|
+
return 32;
|
|
152
|
+
},
|
|
153
|
+
nestingFactor: 1.2,
|
|
154
|
+
gravity: 1,
|
|
155
|
+
numIter: 8e3,
|
|
156
|
+
initialTemp: 1e3,
|
|
157
|
+
coolingFactor: .99,
|
|
158
|
+
minTemp: 1
|
|
159
|
+
}), a = () => ({
|
|
160
|
+
name: "circle",
|
|
161
|
+
fit: !0,
|
|
162
|
+
padding: 30,
|
|
163
|
+
boundingBox: void 0,
|
|
164
|
+
avoidOverlap: !0,
|
|
165
|
+
nodeDimensionsIncludeLabels: !1,
|
|
166
|
+
spacingFactor: 1.2,
|
|
167
|
+
radius: void 0,
|
|
168
|
+
startAngle: 3 / 2 * Math.PI,
|
|
169
|
+
sweep: void 0,
|
|
170
|
+
clockwise: !0,
|
|
171
|
+
sort: void 0,
|
|
172
|
+
animate: !0,
|
|
173
|
+
animationDuration: 500,
|
|
174
|
+
animationEasing: void 0,
|
|
175
|
+
animateFilter: function(e, t) {
|
|
176
|
+
return !0;
|
|
177
|
+
},
|
|
178
|
+
ready: void 0,
|
|
179
|
+
stop: void 0,
|
|
180
|
+
transform: function(e, t) {
|
|
181
|
+
return t;
|
|
182
|
+
}
|
|
183
|
+
}), o = () => ({
|
|
184
|
+
name: "concentric",
|
|
185
|
+
fit: !0,
|
|
186
|
+
padding: 30,
|
|
187
|
+
startAngle: 3 / 2 * Math.PI,
|
|
188
|
+
sweep: void 0,
|
|
189
|
+
clockwise: !0,
|
|
190
|
+
equidistant: !1,
|
|
191
|
+
minNodeSpacing: 10,
|
|
192
|
+
boundingBox: void 0,
|
|
193
|
+
avoidOverlap: !0,
|
|
194
|
+
nodeDimensionsIncludeLabels: !1,
|
|
195
|
+
height: void 0,
|
|
196
|
+
width: void 0,
|
|
197
|
+
spacingFactor: 3,
|
|
198
|
+
concentric: function(e) {
|
|
199
|
+
return e.degree();
|
|
200
|
+
},
|
|
201
|
+
levelWidth: function(e) {
|
|
202
|
+
return e.maxDegree() / 4;
|
|
203
|
+
},
|
|
204
|
+
animate: !0,
|
|
205
|
+
animationDuration: 500,
|
|
206
|
+
animationEasing: void 0,
|
|
207
|
+
animateFilter: function(e, t) {
|
|
208
|
+
return !0;
|
|
209
|
+
},
|
|
210
|
+
ready: void 0,
|
|
211
|
+
stop: void 0,
|
|
212
|
+
transform: function(e, t) {
|
|
213
|
+
return t;
|
|
214
|
+
}
|
|
215
|
+
}), s = () => ({
|
|
216
|
+
name: "fcose",
|
|
217
|
+
idealEdgeLength: 50,
|
|
218
|
+
edgeElasticity: 80,
|
|
219
|
+
nodeRepulsion: 12e3,
|
|
220
|
+
nodeOverlap: 0,
|
|
221
|
+
spacingFactor: 2,
|
|
222
|
+
nestingFactor: 5,
|
|
223
|
+
gravity: 0,
|
|
224
|
+
numIter: 3e3,
|
|
225
|
+
tile: !0,
|
|
226
|
+
animate: "end",
|
|
227
|
+
animationDuration: 1e3,
|
|
228
|
+
randomize: !0,
|
|
229
|
+
fit: !0,
|
|
230
|
+
padding: 50,
|
|
231
|
+
nodeDimensionsIncludeLabels: !0
|
|
232
|
+
}), c = () => ({
|
|
233
|
+
name: "grid",
|
|
234
|
+
fit: !0,
|
|
235
|
+
padding: 30,
|
|
236
|
+
boundingBox: void 0,
|
|
237
|
+
avoidOverlap: !0,
|
|
238
|
+
avoidOverlapPadding: 10,
|
|
239
|
+
nodeDimensionsIncludeLabels: !1,
|
|
240
|
+
spacingFactor: void 0,
|
|
241
|
+
condense: !1,
|
|
242
|
+
rows: void 0,
|
|
243
|
+
cols: void 0,
|
|
244
|
+
position: function(e) {},
|
|
245
|
+
sort: void 0,
|
|
246
|
+
animate: !0,
|
|
247
|
+
animationDuration: 500,
|
|
248
|
+
animationEasing: void 0,
|
|
249
|
+
animateFilter: function(e, t) {
|
|
250
|
+
return !0;
|
|
251
|
+
},
|
|
252
|
+
ready: void 0,
|
|
253
|
+
stop: void 0,
|
|
254
|
+
transform: function(e, t) {
|
|
255
|
+
return t;
|
|
256
|
+
}
|
|
257
|
+
}), l = () => ({
|
|
258
|
+
name: "breadthfirst",
|
|
259
|
+
fit: !0,
|
|
260
|
+
directed: !1,
|
|
261
|
+
direction: "downward",
|
|
262
|
+
padding: 30,
|
|
263
|
+
circle: !1,
|
|
264
|
+
grid: !1,
|
|
265
|
+
spacingFactor: 1,
|
|
266
|
+
boundingBox: void 0,
|
|
267
|
+
avoidOverlap: !0,
|
|
268
|
+
nodeDimensionsIncludeLabels: !1,
|
|
269
|
+
roots: void 0,
|
|
270
|
+
depthSort: void 0,
|
|
271
|
+
animate: !0,
|
|
272
|
+
animationDuration: 500,
|
|
273
|
+
animationEasing: void 0,
|
|
274
|
+
animateFilter: function(e, t) {
|
|
275
|
+
return !0;
|
|
276
|
+
},
|
|
277
|
+
ready: void 0,
|
|
278
|
+
stop: void 0,
|
|
279
|
+
transform: function(e, t) {
|
|
280
|
+
return t;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
//#endregion
|
|
284
|
+
export { t as coseBilkentLayout, e as fixNodesToEdges, n as layout };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__commonJSMin=o,exports.__toESM=c;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
|
|
3
|
+
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
4
|
+
get: ((e) => i[e]).bind(null, d),
|
|
5
|
+
enumerable: !(s = n(i, d)) || s.enumerable
|
|
6
|
+
});
|
|
7
|
+
return e;
|
|
8
|
+
}, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
|
|
9
|
+
value: n,
|
|
10
|
+
enumerable: !0
|
|
11
|
+
}) : a, n)), l = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
12
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
13
|
+
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { o as __commonJSMin, l as __require, c as __toESM };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require(`./index2.cjs.js`).__commonJSMin((e=>{var t=require(`react`),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s}));Object.defineProperty(exports,`default`,{enumerable:!0,get:function(){return e()}});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __commonJSMin as e, __require as t } from "./index2.esm.js";
|
|
2
|
+
//#region node_modules/react/cjs/react-jsx-runtime.production.min.js
|
|
3
|
+
var n = /* @__PURE__ */ e(((e) => {
|
|
4
|
+
var n = t("react"), r = Symbol.for("react.element"), i = Symbol.for("react.fragment"), a = Object.prototype.hasOwnProperty, o = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = {
|
|
5
|
+
key: !0,
|
|
6
|
+
ref: !0,
|
|
7
|
+
__self: !0,
|
|
8
|
+
__source: !0
|
|
9
|
+
};
|
|
10
|
+
function c(e, t, n) {
|
|
11
|
+
var i, c = {}, l = null, u = null;
|
|
12
|
+
for (i in n !== void 0 && (l = "" + n), t.key !== void 0 && (l = "" + t.key), t.ref !== void 0 && (u = t.ref), t) a.call(t, i) && !s.hasOwnProperty(i) && (c[i] = t[i]);
|
|
13
|
+
if (e && e.defaultProps) for (i in t = e.defaultProps, t) c[i] === void 0 && (c[i] = t[i]);
|
|
14
|
+
return {
|
|
15
|
+
$$typeof: r,
|
|
16
|
+
type: e,
|
|
17
|
+
key: l,
|
|
18
|
+
ref: u,
|
|
19
|
+
props: c,
|
|
20
|
+
_owner: o.current
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
e.Fragment = i, e.jsx = c, e.jsxs = c;
|
|
24
|
+
}));
|
|
25
|
+
//#endregion
|
|
26
|
+
export default n();
|
|
27
|
+
export { n as require_react_jsx_runtime_production_min };
|