mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-03 06:17:29 +08:00
### What problem does this PR solve? feat: Add ForceGraph feat: Classify nodes based on edge relationships #162 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
38 lines
868 B
TypeScript
38 lines
868 B
TypeScript
import { useEffect, useRef } from 'react';
|
|
import { ForceGraph2D } from 'react-force-graph';
|
|
import { graphData } from './constant';
|
|
|
|
const Next = () => {
|
|
const graphRef = useRef<ForceGraph2D>();
|
|
|
|
useEffect(() => {
|
|
graphRef.current.d3Force('cluster');
|
|
}, []);
|
|
|
|
return (
|
|
<div>
|
|
<ForceGraph2D
|
|
ref={graphRef}
|
|
graphData={graphData}
|
|
nodeAutoColorBy={'type'}
|
|
nodeLabel={(node) => {
|
|
return node.id;
|
|
}}
|
|
// nodeVal={(node) => {
|
|
// return <div>xxx</div>;
|
|
// }}
|
|
// nodeVal={(node) => 100 / (node.level + 1)}
|
|
linkAutoColorBy={'type'}
|
|
nodeCanvasObjectMode={() => 'after'}
|
|
nodeCanvasObject={(node, ctx) => {
|
|
console.info(ctx);
|
|
return ctx.canvas;
|
|
}}
|
|
// nodeVal={'id'}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Next;
|