Skip to content

Commit 80032b1

Browse files
authored
feat: Add IndentedTree #162 (#1792)
### What problem does this PR solve? feat: Add IndentedTree #162 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
1 parent 5d55e6a commit 80032b1

File tree

5 files changed

+472
-17
lines changed

5 files changed

+472
-17
lines changed

web/src/pages/add-knowledge/components/knowledge-chunk/components/knowledge-graph/force-graph.tsx

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { useFetchKnowledgeGraph } from '@/hooks/chunk-hooks';
21
import { ElementDatum, Graph, IElementEvent } from '@antv/g6';
32
import { useCallback, useEffect, useMemo, useRef } from 'react';
4-
import { buildNodesAndCombos, isDataExist } from './util';
3+
import { buildNodesAndCombos } from './util';
54

65
import styles from './index.less';
76

@@ -11,14 +10,18 @@ const TooltipColorMap = {
1110
edge: 'blue',
1211
};
1312

14-
const ForceGraph = () => {
13+
interface IProps {
14+
data: any;
15+
show: boolean;
16+
}
17+
18+
const ForceGraph = ({ data, show }: IProps) => {
1519
const containerRef = useRef<HTMLDivElement>(null);
1620
const graphRef = useRef<Graph | null>(null);
17-
const { data } = useFetchKnowledgeGraph();
1821

1922
const nextData = useMemo(() => {
20-
if (isDataExist(data)) {
21-
const graphData = data.data;
23+
if (data) {
24+
const graphData = data;
2225
const mi = buildNodesAndCombos(graphData.nodes);
2326
return { edges: graphData.links, ...mi };
2427
}
@@ -113,7 +116,7 @@ const ForceGraph = () => {
113116
}, [nextData]);
114117

115118
useEffect(() => {
116-
if (isDataExist(data)) {
119+
if (data) {
117120
render();
118121
}
119122
}, [data, render]);
@@ -122,7 +125,11 @@ const ForceGraph = () => {
122125
<div
123126
ref={containerRef}
124127
className={styles.forceContainer}
125-
style={{ width: '100%', height: '80vh' }}
128+
style={{
129+
width: '90vh',
130+
height: '80vh',
131+
display: show ? 'block' : 'none',
132+
}}
126133
/>
127134
);
128135
};

0 commit comments

Comments
 (0)