When the graph gets rendered it gives each node its x and y coordinates. My question is can I access the network and get each node coordinates. I tried using ref in order to print out the network and get the nodes details but I couldn't find anything about coordinates. please note that I'm new to react-graph-vis so go easy on me.
import React from "react";
import ReactDOM from "react-dom";
import Graph from "react-graph-vis";
function App() {
const graph = {
nodes: [
{ id: 1, label: "Node 1", title: "node 1 tootip text" },
{ id: 2, label: "Node 2", title: "node 2 tootip text" },
{ id: 3, label: "Node 3", title: "node 3 tootip text" },
{ id: 4, label: "Node 4", title: "node 4 tootip text" },
{ id: 5, label: "Node 5", title: "node 5 tootip text" }
],
edges: [
{ from: 1, to: 2 },
{ from: 1, to: 3 },
{ from: 2, to: 4 },
{ from: 2, to: 5 }
]
};
const options = {
width: (window.innerWidth) + 'px',
height: (window.innerWidth) + 'px',
layout: {
hierarchical: false
},
edges: {
color: "#000000"
},
physics:false,
interaction: {
dragNodes: true,
zoomView: true,
dragView: true
}
};
const events = {
select: function(event) {
var { nodes, edges } = event;
}
};
return (
<Graph
graph={graph}
options={options}
events={events}
getNetwork={network => {
}}
/>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);