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.

78 lines
2.7 KiB

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