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
3.0 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, label: 'Algie', image: DIR + 'Smiley-Angry-icon.png', shape: 'image'},
  20. {id: 2, label: 'Alston', image: DIR + 'Smiley-Grin-icon.png', shape: 'image'},
  21. {id: 3, label: 'Barney', image: DIR + 'User-Administrator-Blue-icon.png', shape: 'image'},
  22. {id: 4, label: 'Coley', image: DIR + 'User-Administrator-Green-icon.png', shape: 'image'},
  23. {id: 5, label: 'Grant', image: DIR + 'User-Coat-Blue-icon.png', shape: 'image'},
  24. {id: 6, label: 'Langdon', image: DIR + 'User-Coat-Green-icon.png', shape: 'image'},
  25. {id: 7, label: 'Lee', image: DIR + 'User-Coat-Red-icon.png', shape: 'image'},
  26. {id: 8, label: 'Merlin', image: DIR + 'User-Executive-Green-icon.png', shape: 'image'},
  27. {id: 9, label: 'Mick', image: DIR + 'User-Preppy-Blue-icon.png', shape: 'image'},
  28. {id: 10, label: 'Tod', image: DIR + 'User-Preppy-Red-icon.png', shape: 'image'}
  29. ];
  30. // create connections
  31. var color = '#BFBFBF';
  32. edges = [
  33. {from: 2, to: 8, value: 3, label: 3, color: color},
  34. {from: 2, to: 9, value: 5, label: 5, color: color},
  35. {from: 2, to: 10, value: 1, label: 1, color: color},
  36. {from: 4, to: 6, value: 8, label: 8, color: color},
  37. {from: 5, to: 7, value: 2, label: 2, color: color},
  38. {from: 4, to: 5, value: 1, label: 1, color: color},
  39. {from: 9, to: 10, value: 2, label: 2, color: color},
  40. {from: 2, to: 3, value: 6, label: 6, color: color},
  41. {from: 3, to: 9, value: 4, label: 4, color: color},
  42. {from: 5, to: 3, value: 1, label: 1, color: color},
  43. {from: 2, to: 7, value: 4, label: 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>