react-graph-vis icon indicating copy to clipboard operation
react-graph-vis copied to clipboard

how to set init scale

Open oaoxd0314 opened this issue 3 years ago • 2 comments

Hi ! I want to resize chart, because it's too small image

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

oaoxd0314 avatar Sep 29 '21 11:09 oaoxd0314

Has any solution?

FengHuangDong avatar Jun 27 '22 03:06 FengHuangDong

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}
  />
)

SageRalph avatar Aug 03 '22 23:08 SageRalph