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.9 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Graph | Social Network</title>
  5. <style>
  6. body {
  7. font: 10pt arial;
  8. }
  9. </style>
  10. <script type="text/javascript" src="../../vis.js"></script>
  11. <script type="text/javascript">
  12. var DIR = 'img/soft-scraps-icons/';
  13. var nodes = null;
  14. var edges = null;
  15. var graph = null;
  16. function draw() {
  17. // create people
  18. nodes = [
  19. {id: 1, text: 'Algie', image: DIR + 'Smiley-Angry-icon.png', style: 'image'},
  20. {id: 2, text: 'Alston', image: DIR + 'Smiley-Grin-icon.png', style: 'image'},
  21. {id: 3, text: 'Barney', image: DIR + 'User-Administrator-Blue-icon.png', style: 'image'},
  22. {id: 4, text: 'Coley', image: DIR + 'User-Administrator-Green-icon.png', style: 'image'},
  23. {id: 5, text: 'Grant', image: DIR + 'User-Coat-Blue-icon.png', style: 'image'},
  24. {id: 6, text: 'Langdon', image: DIR + 'User-Coat-Green-icon.png', style: 'image'},
  25. {id: 7, text: 'Lee', image: DIR + 'User-Coat-Red-icon.png', style: 'image'},
  26. {id: 8, text: 'Merlin', image: DIR + 'User-Executive-Green-icon.png', style: 'image'},
  27. {id: 9, text: 'Mick', image: DIR + 'User-Preppy-Blue-icon.png', style: 'image'},
  28. {id: 10, text: 'Tod', image: DIR + 'User-Preppy-Red-icon.png', style: 'image'}
  29. ];
  30. // create connections
  31. var color = '#BFBFBF';
  32. edges = [
  33. {from: 2, to: 8, value: 3, color: color},
  34. {from: 2, to: 9, value: 5, color: color},
  35. {from: 2, to: 10, value: 1, color: color},
  36. {from: 4, to: 6, value: 8, color: color},
  37. {from: 5, to: 7, value: 2, color: color},
  38. {from: 4, to: 5, value: 1, color: color},
  39. {from: 9, to: 10, value: 2, color: color},
  40. {from: 2, to: 3, value: 6, color: color},
  41. {from: 3, to: 9, value: 4, color: color},
  42. {from: 5, to: 3, value: 1, color: color},
  43. {from: 2, to: 7, value: 4, color: color}
  44. ];
  45. // create a graph
  46. var container = document.getElementById('mygraph');
  47. var data = {
  48. nodes: nodes,
  49. edges: edges
  50. };
  51. var options = {
  52. width: '600px',
  53. height: '600px',
  54. backgroundColor: {
  55. fill: '#F3F3F3'
  56. }
  57. };
  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>