How can I import data in DOT language into vis.js?

47 views Asked by At

I am trying to apply Import data in DOT language example in vis.js, example could be seen bottom of the following page https://visjs.github.io/vis-network/docs/network/. I was not able to figure it out how to make it run successfully.

I have pasted the example piece if code in between <script type="text/javascript">...</script>, but when I open the html file, its result is empty window.

The way I installed:

npm install vis-network

<html>
  <head>
    <script
      type="text/javascript"
      src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"
      ></script>

    <style type="text/css">
      #mynetwork {
          width: 600px;
          height: 400px;
          border: 1px solid lightgray;
      }
    </style>
  </head>
  <body>
    <div id="mynetwork"></div>

    <script type="text/javascript">
      // provide data in the DOT language
      var DOTstring = 'dinetwork {1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }';
      var parsedData = vis.parseDOTNetwork(DOTstring);

      var data = {
          nodes: parsedData.nodes,
          edges: parsedData.edges
      }

      var options = parsedData.options;

      // you can extend the options like a normal JSON variable:
      options.nodes = {
          color: 'red'
      }

      // create a network
      var network = new vis.Network(container, data, options);
    </script>
  </body>
</html>

How can I import data in DOT language into vis.js and open its html page?

0

There are 0 answers