Skip to content

Commit

Permalink
feat: Add IndentedTree infiniflow#162 (infiniflow#1792)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

feat: Add IndentedTree infiniflow#162

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
cike8899 authored Aug 2, 2024
1 parent 6f3b2de commit 8f2d402
Show file tree
Hide file tree
Showing 5 changed files with 472 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useFetchKnowledgeGraph } from '@/hooks/chunk-hooks';
import { ElementDatum, Graph, IElementEvent } from '@antv/g6';
import { useCallback, useEffect, useMemo, useRef } from 'react';
import { buildNodesAndCombos, isDataExist } from './util';
import { buildNodesAndCombos } from './util';

import styles from './index.less';

Expand All @@ -11,14 +10,18 @@ const TooltipColorMap = {
edge: 'blue',
};

const ForceGraph = () => {
interface IProps {
data: any;
show: boolean;
}

const ForceGraph = ({ data, show }: IProps) => {
const containerRef = useRef<HTMLDivElement>(null);
const graphRef = useRef<Graph | null>(null);
const { data } = useFetchKnowledgeGraph();

const nextData = useMemo(() => {
if (isDataExist(data)) {
const graphData = data.data;
if (data) {
const graphData = data;
const mi = buildNodesAndCombos(graphData.nodes);
return { edges: graphData.links, ...mi };
}
Expand Down Expand Up @@ -113,7 +116,7 @@ const ForceGraph = () => {
}, [nextData]);

useEffect(() => {
if (isDataExist(data)) {
if (data) {
render();
}
}, [data, render]);
Expand All @@ -122,7 +125,11 @@ const ForceGraph = () => {
<div
ref={containerRef}
className={styles.forceContainer}
style={{ width: '100%', height: '80vh' }}
style={{
width: '90vh',
height: '80vh',
display: show ? 'block' : 'none',
}}
/>
);
};
Expand Down
Loading

0 comments on commit 8f2d402

Please sign in to comment.