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.

79 lines
2.8 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Social Network</title>
  5. <style>
  6. body {
  7. font: 10pt arial;
  8. }
  9. #mynetwork {
  10. width: 600px;
  11. height: 600px;
  12. border: 1px solid lightgray;
  13. background: #F3F3F3;
  14. }
  15. </style>
  16. <script type="text/javascript" src="../../dist/vis.js"></script>
  17. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  18. <script type="text/javascript">
  19. var DIR = 'img/soft-scraps-icons/';
  20. var nodes = null;
  21. var edges = null;
  22. var network = null;
  23. function draw() {
  24. // create people
  25. nodes = [
  26. {id: 1, label: 'Algie', image: DIR + 'Smiley-Angry-icon.png', shape: 'image'},
  27. {id: 2, label: 'Alston', image: DIR + 'Smiley-Grin-icon.png', shape: 'image'},
  28. {id: 3, label: 'Barney', image: DIR + 'User-Administrator-Blue-icon.png', shape: 'image'},
  29. {id: 4, label: 'Coley', image: DIR + 'User-Administrator-Green-icon.png', shape: 'image'},
  30. {id: 5, label: 'Grant', image: DIR + 'User-Coat-Blue-icon.png', shape: 'image'},
  31. {id: 6, label: 'Langdon', image: DIR + 'User-Coat-Green-icon.png', shape: 'image'},
  32. {id: 7, label: 'Lee', image: DIR + 'User-Coat-Red-icon.png', shape: 'image'},
  33. {id: 8, label: 'Merlin', image: DIR + 'User-Executive-Green-icon.png', shape: 'image'},
  34. {id: 9, label: 'Mick', image: DIR + 'User-Preppy-Blue-icon.png', shape: 'image'},
  35. {id: 10, label: 'Tod', image: DIR + 'User-Preppy-Red-icon.png', shape: 'image'}
  36. ];
  37. // create connections
  38. var color = '#BFBFBF';
  39. edges = [
  40. {from: 2, to: 8, value: 3, label: 3, color: color},
  41. {from: 2, to: 9, value: 5, label: 5, color: color},
  42. {from: 2, to: 10, value: 1, label: 1, color: color},
  43. {from: 4, to: 6, value: 8, label: 8, color: color},
  44. {from: 5, to: 7, value: 2, label: 2, color: color},
  45. {from: 4, to: 5, value: 1, label: 1, color: color},
  46. {from: 9, to: 10, value: 2, label: 2, color: color},
  47. {from: 2, to: 3, value: 6, label: 6, color: color},
  48. {from: 3, to: 9, value: 4, label: 4, color: color},
  49. {from: 5, to: 3, value: 1, label: 1, color: color},
  50. {from: 2, to: 7, value: 4, label: 4, color: color}
  51. ];
  52. // create a network
  53. var container = document.getElementById('mynetwork');
  54. var data = {
  55. nodes: nodes,
  56. edges: edges
  57. };
  58. var options = {};
  59. network = new vis.Network(container, data, options);
  60. }
  61. </script>
  62. </head>
  63. <body onload="draw()">
  64. <div id="mynetwork"></div>
  65. <p>
  66. Icons: <a href="http://www.deleket.com/" target="_blank">Scrap Icons by Deleket</a>
  67. </p>
  68. <div id="info"></div>
  69. </body>
  70. </html>