react-kggraph 0.0.17 → 0.0.19
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 +197 -9
- package/lib/index.es.js +8 -6
- package/lib/index.es10.js +186 -69
- package/lib/index.es11.js +69 -28
- package/lib/index.es12.js +29 -69
- package/lib/index.es13.js +64 -224
- package/lib/index.es14.js +69 -4
- package/lib/index.es15.js +4 -35
- package/lib/index.es16.js +37 -0
- package/lib/index.es18.js +15462 -49
- package/lib/index.es19.js +50 -56
- package/lib/index.es20.js +57 -66
- package/lib/index.es21.js +68 -39
- package/lib/index.es22.js +40 -2
- package/lib/index.es23.js +1 -1
- package/lib/index.es24.js +2 -2
- package/lib/index.es25.js +1 -1
- package/lib/index.es26.js +1 -1
- package/lib/index.es27.js +1 -1
- package/lib/index.es28.js +1 -1
- package/lib/index.es29.js +1 -1
- package/lib/index.es3.js +201 -182
- package/lib/index.es30.js +1 -1
- package/lib/index.es31.js +1 -1
- package/lib/index.es32.js +2 -2
- package/lib/index.es33.js +4 -0
- package/lib/index.es35.js +4 -2
- package/lib/index.es36.js +4 -0
- package/lib/index.es4.js +17 -6
- package/lib/index.es5.js +6 -2
- package/lib/index.es6.js +2 -599
- package/lib/index.es7.js +578 -312
- package/lib/index.es8.js +294 -393
- package/lib/index.es9.js +408 -173
- package/lib/src/components/Graph/components/ActionBar/actionList.d.ts +10 -0
- package/lib/src/components/Graph/components/ActionBar/index.d.ts +15 -0
- package/lib/src/components/Graph/components/SettingCircle/index.d.ts +4 -2
- package/lib/src/components/Graph/types.d.ts +62 -1
- package/lib/src/components/Graph/utils/edge_node_styles.d.ts +5 -2
- package/lib/src/components/Graph/utils/menuItems.d.ts +12 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/lib/index.es17.js +0 -15469
- package/lib/index.es34.js +0 -6
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
- 🔍 支持节点搜索、高亮路径分析
|
|
11
11
|
- 📦 支持知识图谱展开、节点详情查看
|
|
12
12
|
- 📱 响应式设计,支持缩放、拖拽等交互
|
|
13
|
+
- ⚙️ 支持 ActionBar 工具栏配置(位置、按钮列表)
|
|
14
|
+
- 🖱️ 支持右键菜单(actionCircle)自定义
|
|
13
15
|
|
|
14
16
|
## 安装
|
|
15
17
|
|
|
@@ -22,7 +24,7 @@ npm install react-kggraph
|
|
|
22
24
|
react-kggraph 依赖以下 peerDependencies,请确保已安装:
|
|
23
25
|
|
|
24
26
|
```bash
|
|
25
|
-
npm install react react-dom antd
|
|
27
|
+
npm install react react-dom antd @ant-design/icons
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
## 使用
|
|
@@ -46,9 +48,7 @@ const App = () => {
|
|
|
46
48
|
|
|
47
49
|
return (
|
|
48
50
|
<div style={{ width: '100%', height: '600px' }}>
|
|
49
|
-
<CytoscapeReact
|
|
50
|
-
data={data}
|
|
51
|
-
/>
|
|
51
|
+
<CytoscapeReact data={data} />
|
|
52
52
|
</div>
|
|
53
53
|
);
|
|
54
54
|
};
|
|
@@ -57,8 +57,8 @@ const App = () => {
|
|
|
57
57
|
### 完整示例
|
|
58
58
|
|
|
59
59
|
```tsx
|
|
60
|
-
import { CytoscapeReact, SearchType } from 'react-kggraph';
|
|
61
|
-
import '
|
|
60
|
+
import { CytoscapeReact, SearchType, actionList } from 'react-kggraph';
|
|
61
|
+
import { MinusCircleOutlined } from '@ant-design/icons';
|
|
62
62
|
|
|
63
63
|
const App = () => {
|
|
64
64
|
const data = {
|
|
@@ -108,6 +108,18 @@ const App = () => {
|
|
|
108
108
|
graphInfo={{ kgId: 3, searchNodes: ['刘培', '许冉'] }}
|
|
109
109
|
stepNextApi={stepNextApi}
|
|
110
110
|
knowledgeCardApi={knowledgeCardApi}
|
|
111
|
+
// ActionBar 配置
|
|
112
|
+
actionBar={{
|
|
113
|
+
position: 'top-left',
|
|
114
|
+
actionList: actionList.filter(item => ['queryStatistics', 'layout'].includes(item.key)),
|
|
115
|
+
}}
|
|
116
|
+
// 右键菜单配置
|
|
117
|
+
actionCircle={[
|
|
118
|
+
{ ids: 'contract', label: '展收实体' },
|
|
119
|
+
{ ids: 'expanded', label: '展收属性' },
|
|
120
|
+
{ ids: 'nodeInfo', label: '节点信息' },
|
|
121
|
+
{ ids: 'customNew', label: '自定义菜单', onClick: (node) => console.log('自定义', node) },
|
|
122
|
+
]}
|
|
111
123
|
/>
|
|
112
124
|
</div>
|
|
113
125
|
);
|
|
@@ -118,16 +130,147 @@ const App = () => {
|
|
|
118
130
|
|
|
119
131
|
| 属性 | 类型 | 必填 | 说明 |
|
|
120
132
|
|------|------|------|------|
|
|
121
|
-
| data | `GraphData \| any[]` |
|
|
122
|
-
| getAllGraphData | `(params?: any) =>
|
|
133
|
+
| data | `GraphData \| any[]` | ❌ | 图谱数据 |
|
|
134
|
+
| getAllGraphData | `(params?: any) => void` | ❌ | 获取完整图谱数据的回调函数 |
|
|
123
135
|
| searchType | `SearchType` | ❌ | 搜索类型 |
|
|
124
136
|
| highPathAnalysis | `string[]` | ❌ | 高亮路径分析的节点ID数组 |
|
|
125
137
|
| graphInfo | `GraphInfo` | ❌ | 图谱配置信息 |
|
|
126
138
|
| stepNextApi | `(params: any) => Promise<any>` | ❌ | 下一步API(用于知识图谱展开) |
|
|
127
139
|
| knowledgeCardApi | `(params: any) => Promise<any>` | ❌ | 知识卡片API |
|
|
140
|
+
| colors | `GraphColors` | ❌ | 颜色配置 |
|
|
141
|
+
| actionBar | `ActionBarConfig` | ❌ | ActionBar 工具栏配置 |
|
|
142
|
+
| actionCircle | `ActionCircleItem[]` | ❌ | 右键菜单配置 |
|
|
128
143
|
|
|
129
|
-
##
|
|
144
|
+
## ActionBar 配置
|
|
145
|
+
|
|
146
|
+
ActionBar 工具栏支持自定义位置和按钮列表。
|
|
147
|
+
|
|
148
|
+
### ActionBarConfig
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
interface ActionBarConfig {
|
|
152
|
+
/** 位置配置 */
|
|
153
|
+
position?: ActionBarPosition;
|
|
154
|
+
/** 按钮列表配置 */
|
|
155
|
+
actionList?: ActionBarItem[];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
type ActionBarPosition = 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | {
|
|
159
|
+
top?: string | number;
|
|
160
|
+
right?: string | number;
|
|
161
|
+
bottom?: string | number;
|
|
162
|
+
left?: string | number;
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### ActionBarItem
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
interface ActionBarItem {
|
|
170
|
+
key: string; // 唯一标识
|
|
171
|
+
title: string; // 显示文本
|
|
172
|
+
icon?: React.ReactNode[]; // 图标(支持多个 antd icon)
|
|
173
|
+
onClick?: (params?: any) => void; // 点击事件
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 默认按钮列表
|
|
178
|
+
|
|
179
|
+
组件内置以下默认按钮:
|
|
180
|
+
|
|
181
|
+
| key | title | 说明 |
|
|
182
|
+
|-----|-------|------|
|
|
183
|
+
| queryStatistics | 查询统计 | 统计面板 |
|
|
184
|
+
| layout | 布局 | 布局切换 |
|
|
185
|
+
| graphDisplaySettings | 图显示设置 | 图形显示配置 |
|
|
186
|
+
| analysis | 分析 | 分析功能 |
|
|
187
|
+
| select | 选择 | 选择功能 |
|
|
188
|
+
| downloadData | 下载数据 | 导出数据 |
|
|
189
|
+
| hideAttributes | 隐藏属性 | 隐藏节点属性 |
|
|
190
|
+
| textPosition | 文字位置 | 文字位置调整 |
|
|
191
|
+
| clearCanvas | 清空画布 | 清空画布 |
|
|
192
|
+
| nodeZoom | 节点缩放 | 节点缩放控制 |
|
|
193
|
+
| canvasZoom | 画布缩放 | 画布缩放控制 |
|
|
194
|
+
|
|
195
|
+
### ActionBar 示例
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
// 方式1:使用预定义 actionList
|
|
199
|
+
import { actionList } from 'react-kggraph';
|
|
200
|
+
import { MinusCircleOutlined } from '@ant-design/icons';
|
|
201
|
+
|
|
202
|
+
<CytoscapeReact
|
|
203
|
+
actionBar={{
|
|
204
|
+
position: 'top-left',
|
|
205
|
+
actionList: actionList.filter(item => ['queryStatistics', 'layout'].includes(item.key)),
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
|
|
209
|
+
// 方式2:自定义按钮
|
|
210
|
+
<CytoscapeReact
|
|
211
|
+
actionBar={{
|
|
212
|
+
position: 'bottom-right',
|
|
213
|
+
actionList: [
|
|
214
|
+
{ key: 'customBtn', title: '自定义按钮', icon: [<MinusCircleOutlined key="icon" />], onClick: () => console.log('点击') },
|
|
215
|
+
],
|
|
216
|
+
}}
|
|
217
|
+
/>
|
|
218
|
+
```
|
|
130
219
|
|
|
220
|
+
## 右键菜单配置(actionCircle)
|
|
221
|
+
|
|
222
|
+
右键菜单支持过滤、追加自定义菜单项。
|
|
223
|
+
|
|
224
|
+
### ActionCircleItem
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
interface ActionCircleItem {
|
|
228
|
+
ids: string; // 唯一标识
|
|
229
|
+
label: string; // 显示文本
|
|
230
|
+
onClick?: (node: any) => void; // 点击事件回调
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 默认菜单项
|
|
235
|
+
|
|
236
|
+
| ids | label | 说明 |
|
|
237
|
+
|-----|-------|------|
|
|
238
|
+
| contract | 展收实体 | 收缩实体节点 |
|
|
239
|
+
| expanded | 展收属性 | 展开节点属性 |
|
|
240
|
+
| nodeInfo | 节点信息 | 查看节点详情 |
|
|
241
|
+
| knowledgeCard | 知识卡片 | 查看知识卡片 |
|
|
242
|
+
| selRelate | 选中关联 | 高亮关联节点 |
|
|
243
|
+
| pathAnalysis | 路径分析 | 路径分析功能 |
|
|
244
|
+
|
|
245
|
+
### actionCircle 示例
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
// 方式1:筛选默认菜单
|
|
249
|
+
<CytoscapeReact
|
|
250
|
+
actionCircle={[
|
|
251
|
+
{ ids: 'contract', label: '展收实体' },
|
|
252
|
+
{ ids: 'expanded', label: '展收属性' },
|
|
253
|
+
{ ids: 'nodeInfo', label: '节点信息' },
|
|
254
|
+
]}
|
|
255
|
+
/>
|
|
256
|
+
|
|
257
|
+
// 方式2:覆盖默认 action
|
|
258
|
+
<CytoscapeReact
|
|
259
|
+
actionCircle={[
|
|
260
|
+
{ ids: 'nodeInfo', label: '节点信息', onClick: (node) => console.log('自定义', node) },
|
|
261
|
+
]}
|
|
262
|
+
/>
|
|
263
|
+
|
|
264
|
+
// 方式3:追加自定义菜单项
|
|
265
|
+
<CytoscapeReact
|
|
266
|
+
actionCircle={[
|
|
267
|
+
{ ids: 'contract', label: '展收实体' },
|
|
268
|
+
{ ids: 'customNew', label: '自定义菜单', onClick: (node) => console.log('新增功能', node) },
|
|
269
|
+
]}
|
|
270
|
+
/>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## 类型定义
|
|
131
274
|
|
|
132
275
|
### GraphData
|
|
133
276
|
|
|
@@ -167,6 +310,51 @@ interface GraphInfo {
|
|
|
167
310
|
}
|
|
168
311
|
```
|
|
169
312
|
|
|
313
|
+
### GraphColors(颜色配置)
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
interface GraphColors {
|
|
317
|
+
/** 节点标签文字颜色,默认 #000 */
|
|
318
|
+
nodeLabelColor?: string;
|
|
319
|
+
/** 节点标签文字大小,默认 18 */
|
|
320
|
+
nodeLabelFontSize?: number;
|
|
321
|
+
/** 边标签文字颜色,默认 #666 */
|
|
322
|
+
edgeLabelColor?: string;
|
|
323
|
+
/** 边标签文字大小,默认 18 */
|
|
324
|
+
edgeLabelFontSize?: number;
|
|
325
|
+
/** URI类型节点背景色,默认 #f7de63 */
|
|
326
|
+
uriNodeColor?: string;
|
|
327
|
+
/** 普通节点背景色,默认 #1890FF */
|
|
328
|
+
normalNodeColor?: string;
|
|
329
|
+
/** 节点边框悬停颜色,默认 #0d6ac2 */
|
|
330
|
+
nodeBorderHoverColor?: string;
|
|
331
|
+
/** 边默认颜色,默认 #a29e9e */
|
|
332
|
+
edgeDefaultColor?: string;
|
|
333
|
+
/** 边悬停颜色,默认 #1890ff */
|
|
334
|
+
edgeHoverColor?: string;
|
|
335
|
+
/** 路径高亮颜色,默认 #145AFD */
|
|
336
|
+
pathHighlightColor?: string;
|
|
337
|
+
/** 路径节点颜色,默认 #145AFD */
|
|
338
|
+
pathNodeColor?: string;
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### 颜色配置示例
|
|
343
|
+
|
|
344
|
+
```tsx
|
|
345
|
+
<CytoscapeReact
|
|
346
|
+
data={data}
|
|
347
|
+
colors={{
|
|
348
|
+
nodeLabelColor: '#333',
|
|
349
|
+
edgeLabelColor: '#999',
|
|
350
|
+
normalNodeColor: '#52c41a',
|
|
351
|
+
uriNodeColor: '#faad14',
|
|
352
|
+
edgeDefaultColor: '#d9d9d9',
|
|
353
|
+
pathHighlightColor: '#f5222d',
|
|
354
|
+
}}
|
|
355
|
+
/>
|
|
356
|
+
```
|
|
357
|
+
|
|
170
358
|
## 图谱布局
|
|
171
359
|
|
|
172
360
|
组件支持多种布局算法:
|
package/lib/index.es.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import { default as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { default as r } from "./index.es3.js";
|
|
3
|
+
import { actionList as p } from "./index.es4.js";
|
|
4
|
+
import { default as m } from "./index.es5.js";
|
|
5
|
+
import { SearchType as s } from "./index.es6.js";
|
|
5
6
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
r as CytoscapeReact,
|
|
8
|
+
m as Demo,
|
|
9
|
+
s as SearchType,
|
|
10
|
+
p as actionList
|
|
9
11
|
};
|
package/lib/index.es10.js
CHANGED
|
@@ -1,75 +1,192 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const g = {
|
|
2
|
+
nodeLabelColor: "#000",
|
|
3
|
+
nodeLabelFontSize: 18,
|
|
4
|
+
edgeLabelColor: "#666",
|
|
5
|
+
edgeLabelFontSize: 18,
|
|
6
|
+
uriNodeColor: "#f7de63",
|
|
7
|
+
// 节点类型为uri的节点颜色,默认节点颜色
|
|
8
|
+
normalNodeColor: "#1890FF",
|
|
9
|
+
nodeBorderHoverColor: "#0d6ac2",
|
|
10
|
+
//节点hover边框效果
|
|
11
|
+
edgeDefaultColor: "#a29e9e",
|
|
12
|
+
//连线颜色
|
|
13
|
+
edgeHoverColor: "#145AFD",
|
|
14
|
+
//边悬停颜色
|
|
15
|
+
pathHighlightColor: "#145AFD",
|
|
16
|
+
//路径高亮颜色
|
|
17
|
+
pathNodeColor: "#145AFD"
|
|
18
|
+
//路径节点颜色-不生效
|
|
19
|
+
}, h = ({ elements: c, colors: n = {} }) => {
|
|
20
|
+
const e = { ...g, ...n }, l = [], t = 80;
|
|
21
|
+
c.map((o) => {
|
|
22
|
+
var a, d, i;
|
|
23
|
+
!l.includes((a = o == null ? void 0 : o.data) == null ? void 0 : a.type) && ((d = o == null ? void 0 : o.data) != null && d.type) && l.push((i = o.data) == null ? void 0 : i.type);
|
|
24
|
+
});
|
|
25
|
+
const r = [];
|
|
26
|
+
r.push({
|
|
27
|
+
selector: '[properties-type="uri"]',
|
|
28
|
+
style: {
|
|
29
|
+
"background-color": e.uriNodeColor,
|
|
30
|
+
"background-image": "data(image)",
|
|
31
|
+
"background-fit": "cover",
|
|
32
|
+
width: t,
|
|
33
|
+
height: t,
|
|
34
|
+
label: "data(name)",
|
|
35
|
+
color: e.nodeLabelColor,
|
|
36
|
+
"text-valign": "bottom",
|
|
37
|
+
"font-size": e.nodeLabelFontSize,
|
|
38
|
+
"text-max-width": "250px",
|
|
39
|
+
"text-wrap": "ellipsis",
|
|
40
|
+
"text-overflow-wrap": "anywhere"
|
|
8
41
|
}
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
action: (e) => {
|
|
25
|
-
console.log("节点信息:", e);
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: "知识卡片",
|
|
30
|
-
ids: "knowledgeCard",
|
|
31
|
-
action: (e) => {
|
|
32
|
-
const o = n.current;
|
|
33
|
-
console.log("知识卡片", o);
|
|
42
|
+
}), r.push({
|
|
43
|
+
selector: '[properties-type!="uri"]',
|
|
44
|
+
style: {
|
|
45
|
+
"background-color": e.normalNodeColor,
|
|
46
|
+
"background-image": "data(image)",
|
|
47
|
+
"background-fit": "cover",
|
|
48
|
+
width: t,
|
|
49
|
+
height: t,
|
|
50
|
+
label: "data(name)",
|
|
51
|
+
color: e.nodeLabelColor,
|
|
52
|
+
"text-valign": "bottom",
|
|
53
|
+
"font-size": e.nodeLabelFontSize,
|
|
54
|
+
"text-max-width": "250px",
|
|
55
|
+
"text-wrap": "ellipsis",
|
|
56
|
+
"text-overflow-wrap": "anywhere"
|
|
34
57
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
});
|
|
59
|
+
const s = [
|
|
60
|
+
{
|
|
61
|
+
selector: "node",
|
|
62
|
+
style: {
|
|
63
|
+
"text-margin-y": "5px"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
selector: "edge",
|
|
68
|
+
style: {
|
|
69
|
+
"line-color": e.edgeDefaultColor,
|
|
70
|
+
"target-arrow-color": e.edgeDefaultColor,
|
|
71
|
+
opacity: 1,
|
|
72
|
+
"target-arrow-shape": "triangle",
|
|
73
|
+
width: 2,
|
|
74
|
+
"curve-style": "bezier",
|
|
75
|
+
"transition-property": "line-color, target-arrow-color, opacity",
|
|
76
|
+
"transition-duration": "0.2s",
|
|
77
|
+
label: "data(name)",
|
|
78
|
+
"z-index": 9999,
|
|
79
|
+
"text-opacity": 1,
|
|
80
|
+
"font-size": e.edgeLabelFontSize,
|
|
81
|
+
color: e.edgeLabelColor,
|
|
82
|
+
"text-background-color": "#fff",
|
|
83
|
+
"text-background-opacity": 1,
|
|
84
|
+
"text-background-shape": "roundrectangle",
|
|
85
|
+
"text-background-padding": "3px"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
selector: ".highlight",
|
|
90
|
+
style: {
|
|
91
|
+
"border-color": "rgba(174, 255, 45, 0.2)",
|
|
92
|
+
"border-width": 4
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
selector: ".path-node",
|
|
97
|
+
style: {
|
|
98
|
+
"background-color": e.pathNodeColor,
|
|
99
|
+
"border-color": e.pathNodeColor,
|
|
100
|
+
"border-width": 2
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
selector: ".path-edge",
|
|
105
|
+
style: {
|
|
106
|
+
"line-color": e.pathHighlightColor,
|
|
107
|
+
"target-arrow-color": e.pathHighlightColor,
|
|
108
|
+
width: 4,
|
|
109
|
+
"border-width": 2,
|
|
110
|
+
"border-color": e.pathHighlightColor
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
selector: ".grayed",
|
|
115
|
+
style: {
|
|
116
|
+
opacity: 0.15,
|
|
117
|
+
"text-opacity": 0.15
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
selector: "node.selected, edge.selected",
|
|
122
|
+
style: {
|
|
123
|
+
"border-color": "rgba(174, 255, 45, 0.2)",
|
|
124
|
+
"border-width": 4
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
selector: ".correlationStyle",
|
|
129
|
+
style: {
|
|
130
|
+
width: 60,
|
|
131
|
+
height: 60,
|
|
132
|
+
"outline-width": "10px",
|
|
133
|
+
"outline-color": "rgba(188, 220, 255, 0.4)",
|
|
134
|
+
"outline-style": "solid",
|
|
135
|
+
"line-opacity": "0.2",
|
|
136
|
+
"outline-offset": "2px",
|
|
137
|
+
filter: "blur(20px)",
|
|
138
|
+
"z-index": 9999
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
selector: ".hover",
|
|
143
|
+
style: {
|
|
144
|
+
"border-width": 3,
|
|
145
|
+
"border-color": e.nodeBorderHoverColor
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
// 层级分析样式 - 目标节点
|
|
149
|
+
{
|
|
150
|
+
selector: ".level-selected",
|
|
151
|
+
style: {
|
|
152
|
+
"background-color": "#f8bbd0",
|
|
153
|
+
"border-color": "#e91e63",
|
|
154
|
+
"border-width": 4,
|
|
155
|
+
color: "#880e4f"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
// 层级分析样式 - 关联节点
|
|
159
|
+
{
|
|
160
|
+
selector: ".level-highlight",
|
|
161
|
+
style: {
|
|
162
|
+
"background-color": "#bbdefb",
|
|
163
|
+
"border-color": "#2196f3",
|
|
164
|
+
"border-width": 3,
|
|
165
|
+
color: "#0d47a1"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
// 层级分析样式 - 边高亮
|
|
169
|
+
{
|
|
170
|
+
selector: ".level-highlightedge",
|
|
171
|
+
style: {
|
|
172
|
+
"line-color": "#1976d2",
|
|
173
|
+
"target-arrow-color": "#1976d2",
|
|
174
|
+
width: 3,
|
|
175
|
+
opacity: 1
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
// 层级分析样式 - 置灰
|
|
179
|
+
{
|
|
180
|
+
selector: ".level-grayed",
|
|
181
|
+
style: {
|
|
182
|
+
opacity: 0.15,
|
|
183
|
+
"text-opacity": 0.15
|
|
51
184
|
}
|
|
52
|
-
const d = e, c = d.neighborhood().nodes().add(d);
|
|
53
|
-
c.edgesWith(c), o.nodes().not(c).removeClass("correlationStyle"), c.addClass("correlationStyle"), r((t) => ({ ...t, visible: !1 }));
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
label: "路径分析",
|
|
58
|
-
action: (e) => {
|
|
59
|
-
n.current, console.log(11, e.data("name")), l == null || l(), s([e.data("name"), ""]);
|
|
60
185
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// action: (node) => {
|
|
65
|
-
// const cy = cyRef.current;
|
|
66
|
-
// console.log('删除节点cy::::', cy)
|
|
67
|
-
// if (node && !node.removed()) {
|
|
68
|
-
// node.remove();
|
|
69
|
-
// }
|
|
70
|
-
// },
|
|
71
|
-
// },
|
|
72
|
-
];
|
|
186
|
+
];
|
|
187
|
+
return r.concat(s);
|
|
188
|
+
};
|
|
73
189
|
export {
|
|
74
|
-
|
|
190
|
+
g as defaultColors,
|
|
191
|
+
h as edgeNodeStyles
|
|
75
192
|
};
|
package/lib/index.es11.js
CHANGED
|
@@ -1,32 +1,73 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const f = ({ cyRef: n, setContextMenu: a, onPathAnalysis: t, setPathNodes: i, actionCircle: l }) => {
|
|
2
|
+
const d = [
|
|
3
|
+
{
|
|
4
|
+
label: "展收实体",
|
|
5
|
+
ids: "contract",
|
|
6
|
+
onClick: (e) => {
|
|
7
|
+
const o = n.current;
|
|
8
|
+
console.log("新增属性", o);
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: "展收属性",
|
|
13
|
+
ids: "expanded",
|
|
14
|
+
onClick: (e) => {
|
|
15
|
+
if (console.log("展开", e), !n.current) {
|
|
16
|
+
console.error("Cytoscape instance is not available");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "节点信息",
|
|
23
|
+
ids: "nodeInfo",
|
|
24
|
+
onClick: (e) => {
|
|
25
|
+
console.log("节点信息:", e);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: "知识卡片",
|
|
30
|
+
ids: "knowledgeCard",
|
|
31
|
+
onClick: (e) => {
|
|
32
|
+
const o = n.current;
|
|
33
|
+
console.log("知识卡片", o);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "选中关联",
|
|
38
|
+
ids: "selRelate",
|
|
39
|
+
onClick: (e) => {
|
|
40
|
+
const o = n.current;
|
|
41
|
+
if (!o || !e || typeof e.removed != "function" || e.removed()) {
|
|
42
|
+
console.error("节点或Cytoscape实例无效"), a((r) => ({ ...r, visible: !1 }));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const s = e, c = s.neighborhood().nodes().add(s);
|
|
46
|
+
c.edgesWith(c), o.nodes().not(c).removeClass("correlationStyle"), c.addClass("correlationStyle"), a((r) => ({ ...r, visible: !1 }));
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: "路径分析",
|
|
51
|
+
ids: "pathAnalysis",
|
|
52
|
+
onClick: (e) => {
|
|
53
|
+
n.current, console.log(11, e.data("name")), t == null || t(), i([e.data("name"), ""]);
|
|
54
|
+
}
|
|
7
55
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
const i = (r, e) => {
|
|
24
|
-
const o = document.createElement("a");
|
|
25
|
-
o.href = r, o.download = e, document.body.appendChild(o), o.click(), document.body.removeChild(o);
|
|
56
|
+
];
|
|
57
|
+
if (!l || l.length === 0)
|
|
58
|
+
return d;
|
|
59
|
+
const u = new Set(l.map((e) => e.ids)), b = d.filter((e) => u.has(e.ids)).map((e) => {
|
|
60
|
+
const o = l.find((s) => s.ids === e.ids);
|
|
61
|
+
return o != null && o.onClick ? { ...e, onClick: o.onClick } : e;
|
|
62
|
+
}), C = new Set(d.map((e) => e.ids)), g = l.filter((e) => !C.has(e.ids)).map((e) => ({
|
|
63
|
+
ids: e.ids,
|
|
64
|
+
label: e.label,
|
|
65
|
+
onClick: e.onClick || ((o) => {
|
|
66
|
+
console.log(e.label, o);
|
|
67
|
+
})
|
|
68
|
+
}));
|
|
69
|
+
return [...b, ...g];
|
|
26
70
|
};
|
|
27
71
|
export {
|
|
28
|
-
|
|
29
|
-
n as isObject,
|
|
30
|
-
t as jsonStringify,
|
|
31
|
-
c as jsonStringifyParse
|
|
72
|
+
f as menuItemsConfig
|
|
32
73
|
};
|