File size: 852 Bytes
862b14b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React, {useRef} from 'react'
import ForceGraph3D from '3d-force-graph';
import SpriteText from 'three-spritetext';

function genRandomTree(N = 9000, reverse = false) {
    return {
      nodes: [...Array(N).keys()].map((i) => ({ id: i })),
      links: [...Array(N).keys()]
        .filter((id) => id)
        .map((id) => ({
          [reverse ? "target" : "source"]: id,
          [reverse ? "source" : "target"]: Math.round(Math.random() * (id - 1))
        }))
    };
  }
const Mindmap = () => {
    const fgRef = useRef();


    const data = genRandomTree();
    return (
        <div>

      {/* if data available then only render */}


      {data && (
        <ForceGraph3D
          ref={fgRef}
          graphData={data}
            nodeAutoColorBy="group"
        />
        )}
         </div>
    );
   };
   
export default Mindmap;