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.

80 lines
2.1 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="../dist/vis.js"></script>
  5. <link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.9.0/vis.min.css">
  6. <style>
  7. #mynetwork {
  8. width: 1400px;
  9. height: 800px;
  10. border: 1px solid gray;
  11. }
  12. </style>
  13. </head>
  14. <body onload="draw()">
  15. <script src="https://rawgit.com/Tooa/6e17f2d7b8e34ef94719/raw/a10096a6b88c992c57d032b1ed3079d7cc4b1f51/data.js"></script>
  16. <div id="mynetwork"></div>
  17. <script>
  18. function draw() {
  19. nodes = [];
  20. edges = [];
  21. // create a network
  22. var container = document.getElementById('mynetwork');
  23. var data = {
  24. nodes: nodes,
  25. edges: edges
  26. };
  27. nodes.push({id: 0, label: 'Root'});
  28. nodes.push({id: 1, label: 'Child 1'});
  29. nodes.push({id: 2, label: 'Child 2'});
  30. nodes.push({id: 3, label: 'Child 3'});
  31. nodes.push({id: 4, label: 'Child 2.1'});
  32. nodes.push({id: 5, label: 'Child 2.1.1'});
  33. nodes.push({id: 6, label: 'Child 2.1.2'});
  34. nodes.push({id: 7, label: 'Child 2.1.1.1'});
  35. edges.push({from: 0, to: 1});
  36. edges.push({from: 0, to: 2});
  37. edges.push({from: 0, to: 3});
  38. edges.push({from: 2, to: 4});
  39. edges.push({from: 4, to: 5});
  40. edges.push({from: 4, to: 6});
  41. edges.push({from: 5, to: 7});
  42. nodes[7].level = 0;
  43. nodes[6].level = 1;
  44. nodes[5].level = 1;
  45. nodes[4].level = 2;
  46. nodes[3].level = 3;
  47. nodes[2].level = 3;
  48. nodes[1].level = 3;
  49. nodes[0].level = 4;
  50. var options = {
  51. edges: {
  52. smooth: {
  53. type: 'cubicBezier',
  54. forceDirection: 'horizontal',
  55. roundness: 0.4
  56. }
  57. },
  58. layout: {
  59. hierarchical: {
  60. direction: 'LR'
  61. }
  62. }
  63. };
  64. network = new vis.Network(container, data, options);
  65. }
  66. var network, nodes, edges;
  67. </script>
  68. </body>
  69. </html>