crubier / react-graph-vis

A react component to render nice graphs using vis.js

Home Page:http://crubier.github.io/react-graph-vis/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to set init scale

oaoxd0314 opened this issue · comments

commented

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

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