react-graph-vis
react-graph-vis copied to clipboard
how to set init scale
Hi ! I want to resize chart, because it's too small
and i found in doc moveTo
& once
can help me set scale in the beginning
but i can't use that kind function in event
,
const events = {
selectNode: function (params) {
// console.log("select");
console.log(params);
},
once: function () {
console.log("once"); // not working
},
moveTo: function () {
console.log("it's happening"); // not working
},
};
is there any better way to help me resize chart in the first time or use once
and moveTo
plz
Has any solution?
The events you can use are listed here: https://visjs.github.io/vis-network/docs/network/#Events
If you want to call functions on the network object, you can access it using the component's state like this:
const [network, setNetwork] = useState({})
const events = {
stabilized: function () {
network.fit()
},
}
return (
<Graph
graph={graph}
options={options}
events={events}
getNetwork={setNetwork}
/>
)