Murilo Bellatini
Murilo Bellatini

Reputation: 71

How can I get `vis.js` `vis-network` to run on React.js?

I'm trying to use vis.js to render a Network Visualization using React. For that, I've been following the guide from James Tharpe: https://www.jamestharpe.com/react-visjs/. However, the follwing errors are raised...

Console Errors

Please check out my code on this repo:

https://github.com/murilobellatini/try-vis-network

Can you guys help me get this code working?

Thanks!

Upvotes: 6

Views: 4590

Answers (2)

MertHaddad
MertHaddad

Reputation: 573

I used the react version of Vis js.

npm install --save react-visjs-timeline

and it is working properly

npm

Upvotes: -2

yozibak
yozibak

Reputation: 149

I've been facing the same issue. Add options in the Network constructor.

  useEffect(() => {
    const network =
      container.current &&
      new Network(container.current, { nodes, edges }, options);
  }, [container, nodes, edges]);

full working stack: https://stackblitz.com/edit/react-e1pbxf?file=src/Graph.js

Try remove options. And it'll say Cannot read the property 'solve' of undefined.

Upvotes: 7

Related Questions