vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
900 B

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Graph | Basic usage</title>
  5. <script type="text/javascript" src="../../vis.js"></script>
  6. </head>
  7. <body>
  8. <div id="mygraph"></div>
  9. <script type="text/javascript">
  10. // create an array with nodes
  11. var nodes = [
  12. {id: 1, text: 'Node 1'},
  13. {id: 2, text: 'Node 2'},
  14. {id: 3, text: 'Node 3'},
  15. {id: 4, text: 'Node 4'},
  16. {id: 5, text: 'Node 5'}
  17. ];
  18. // create an array with edges
  19. var edges = [
  20. {from: 1, to: 2},
  21. {from: 1, to: 3},
  22. {from: 2, to: 4},
  23. {from: 2, to: 5}
  24. ];
  25. // create a graph
  26. var container = document.getElementById('mygraph');
  27. var data = {
  28. nodes: nodes,
  29. edges: edges
  30. };
  31. var options = {
  32. width: '400px',
  33. height: '400px'
  34. };
  35. var graph = new vis.Graph(container, data, options);
  36. </script>
  37. </body>
  38. </html>