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.

72 lines
1.9 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JS Bin</title>
  6. <script type="text/javascript" src="../dist/vis.js"></script>
  7. <link href="../dist/vis.css" rel="stylesheet" type="text/css" />
  8. <style>
  9. #mynetwork {
  10. width: 700px;
  11. height: 450px;
  12. border: 1px solid lightgray;
  13. }
  14. </style>
  15. <script>
  16. var network = null;
  17. function destroy() {
  18. if (network !== null) {
  19. network.destroy();
  20. network = null;
  21. }
  22. }
  23. function draw() {
  24. destroy();
  25. var container = document.getElementById('mynetwork');
  26. var nodes = new vis.DataSet();
  27. var edges = new vis.DataSet();
  28. nodes.add({id:1})
  29. data = {
  30. nodes: nodes,
  31. edges:edges
  32. }
  33. options = {
  34. edges: {
  35. arrows:{
  36. to: true
  37. },
  38. smooth:{
  39. enabled: true
  40. }
  41. },
  42. interaction:{
  43. navigationButtons:true
  44. },
  45. physics:{
  46. enabled: true,
  47. stabilization: true
  48. },
  49. manipulation:{
  50. enabled: false,
  51. addEdge: function (data, callback) {
  52. setTimeout(function () {network.addEdgeMode();},0);
  53. callback(data);
  54. }
  55. }
  56. };
  57. network = new vis.Network(container, data, options);
  58. network.addEdgeMode();
  59. }
  60. </script>
  61. </head>
  62. <body onLoad="draw()">
  63. <button id="addNodeLayer1">Layer 1</button>
  64. <button id="addNodeLayer2">Layer 2</button>
  65. <button id="addNodeLayer3">Layer 3</button>
  66. <div id="mynetwork"></div>
  67. </body>
  68. </html>