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.

95 lines
2.8 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Basic usage</title>
  5. <script type="text/javascript" src="../../dist/vis.js"></script>
  6. <link href="../../dist/vis.css" rel="stylesheet" type="text/css"/>
  7. <style type="text/css">
  8. #mynetwork {
  9. width: 1600px;
  10. height:800px;
  11. border: 1px solid lightgray;
  12. }
  13. </style>
  14. <body>
  15. <div id="mynetwork"></div>
  16. <script type="text/javascript">
  17. // create an array with nodes
  18. var nodes = [
  19. {id: 'network', shape:'database'},
  20. {id: 'body', shape:'database'},
  21. {id: 'nodes'},
  22. {id: 'canvas'},
  23. {id: 'edges'},
  24. {id: 'nodesHandler'},
  25. {id: 'edgesHandler'},
  26. {id: 'selectionHandler'},
  27. {id: 'interactionHandler'},
  28. {id: 'view'},
  29. {id: 'renderer'},
  30. {id: 'physics'},
  31. {id: 'layoutEngine'},
  32. {id: 'clustering'},
  33. {id: 'manipulation'},
  34. {id: 'events'},
  35. ];
  36. // create an array with edges
  37. var edges = [
  38. {from: 'network', to: 'body'},
  39. {from: 'body', to: 'nodesHandler'},
  40. {from: 'body', to: 'edgesHandler'},
  41. {from: 'body', to: 'selectionHandler'},
  42. {from: 'body', to: 'interactionHandler'},
  43. {from: 'body', to: 'view'},
  44. {from: 'body', to: 'renderer'},
  45. {from: 'body', to: 'physics'},
  46. {from: 'body', to: 'canvas'},
  47. {from: 'body', to: 'layoutEngine'},
  48. {from: 'body', to: 'clustering'},
  49. {from: 'body', to: 'manipulation'},
  50. {from: 'nodes', to: 'body'},
  51. {from: 'nodes', to: 'nodesHandler'},
  52. {from: 'edges', to: 'body'},
  53. {from: 'edges', to: 'edgesHandler'},
  54. {from: 'layoutEngine', to: 'nodesHandler'},
  55. {from: 'canvas', to: 'manipulation'},
  56. {from: 'canvas', to: 'renderer'},
  57. {from: 'canvas', to: 'view'},
  58. {from: 'canvas', to: 'selectionHandler'},
  59. {from: 'canvas', to: 'interactionHandler'},
  60. {from: 'selectionHandler', to: 'interactionHandler'},
  61. {from: 'selectionHandler', to: 'manipulation'},
  62. ];
  63. // create a network
  64. var container = document.getElementById('mynetwork');
  65. var data = {
  66. nodes: nodes,
  67. edges: edges
  68. };
  69. var options = {
  70. edges: {arrows: 'to', smooth:true},
  71. layout:{hierarchical:{direction:'UD',levelSeparation: "260"}},
  72. configure:'physics',
  73. // "physics": {
  74. // "hierarchicalRepulsion": {
  75. // "centralGravity": 0,
  76. // "nodeDistance": "220"
  77. // },
  78. // "solver": "hierarchicalRepulsion"
  79. // }
  80. // physics:{stabilization:true}
  81. }
  82. var network = new vis.Network(container, data, options);
  83. // network.setOptions({nodes:{color:'red'}})
  84. </script>
  85. </body>
  86. </html>