I am looking forward to some guidance on how to loop over an array and create the nodes out of it using react-viz-network-graph. Sharing the code below and the array structure. Any guidance would be greatly appreciated.
import React, { useState } from 'react'
import Graph from 'react-vis-network-graph'
export default function GraphView(empNames) {
const [graph, setGraph] = useState({
nodes: [
{ empNames } // here how to populate the node attributes like id,label etc
]
});
const options = {
nodes: {
borderWidth: 2,
size: 40,
color: {
border: "#222222",
background: "#666666"
},
font: { color: "yellow" }
},
height: "900px"
}
return (
<div className='container'>
<Graph
graph={graph}
options={options}
/>
</div>
)
}
The array structure
0: “Emp1”
1: “Emp2”
2: “Emp3”
…
N: “EmpN”