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.

96 lines
3.5 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Graph | Social Network</title>
  5. <style>
  6. body {font: 10pt arial;}
  7. </style>
  8. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  9. <script type="text/javascript" src="../../vis.js"></script>
  10. <script type="text/javascript">
  11. var nodes = null;
  12. var edges = null;
  13. var graph = null;
  14. var DIR = 'img/soft-scraps-icons/';
  15. google.load('visualization', '1');
  16. // Set callback to run when API is loaded
  17. google.setOnLoadCallback(drawVisualization);
  18. // Called when the Visualization API is loaded.
  19. function drawVisualization() {
  20. // Create a data table with nodes.
  21. nodes = new google.visualization.DataTable();
  22. nodes.addColumn('number', 'id');
  23. nodes.addColumn('string', 'text'); // optional
  24. nodes.addColumn('string', 'image'); // optional
  25. nodes.addColumn('string', 'style'); // optional
  26. // Create a data table with links.
  27. edges = new google.visualization.DataTable();
  28. edges.addColumn('number', 'from');
  29. edges.addColumn('number', 'to');
  30. edges.addColumn('number', 'value'); // optional
  31. edges.addColumn('string', 'color'); // optional
  32. edges.addColumn('number', 'length'); // optional
  33. // create people
  34. nodes.addRow([1, 'Algie', DIR + 'Smiley-Angry-icon.png', 'image']);
  35. nodes.addRow([2, 'Alston', DIR + 'Smiley-Grin-icon.png', 'image']);
  36. nodes.addRow([3, 'Barney', DIR + 'User-Administrator-Blue-icon.png', 'image']);
  37. nodes.addRow([4, 'Coley', DIR + 'User-Administrator-Green-icon.png', 'image']);
  38. nodes.addRow([5, 'Grant', DIR + 'User-Coat-Blue-icon.png', 'image']);
  39. nodes.addRow([6, 'Langdon', DIR + 'User-Coat-Green-icon.png', 'image']);
  40. nodes.addRow([7, 'Lee', DIR + 'User-Coat-Red-icon.png', 'image']);
  41. nodes.addRow([8, 'Merlin', DIR + 'User-Executive-Green-icon.png', 'image']);
  42. nodes.addRow([9, 'Mick', DIR + 'User-Preppy-Blue-icon.png', 'image']);
  43. nodes.addRow([10, 'Tod', DIR + 'User-Preppy-Red-icon.png', 'image']);
  44. // create connections
  45. var color = '#BFBFBF';
  46. var len = 100; // pixels
  47. var len = undefined;
  48. edges.addRow([2, 8, 3, color, len]);
  49. edges.addRow([2, 9, 5, color, len]);
  50. edges.addRow([2, 10, 1, color, len]);
  51. edges.addRow([4, 6, 8, color, len]);
  52. edges.addRow([5, 7, 2, color, len]);
  53. edges.addRow([4, 5, 1, color, len]);
  54. edges.addRow([9, 10, 2, color, len]);
  55. edges.addRow([2, 3, 6, color, len]);
  56. edges.addRow([3, 9, 4, color, len]);
  57. edges.addRow([5, 3, 1, color, len]);
  58. edges.addRow([2, 7, 4, color, len]);
  59. // specify options
  60. var options = {
  61. width: '600px',
  62. height: '600px',
  63. backgroundColor: {
  64. fill: '#F3F3F3'
  65. }
  66. };
  67. // Instantiate our graph object.
  68. graph = new vis.Graph(document.getElementById('mygraph'));
  69. // Draw our graph with the created data and options
  70. graph.draw(nodes, edges, options);
  71. }
  72. </script>
  73. </head>
  74. <body>
  75. <div id="mygraph"></div>
  76. <p>
  77. Icons: <a href="http://www.deleket.com/" target="_blank">Scrap Icons by Deleket</a>
  78. </p>
  79. <div id="info"></div>
  80. </body>
  81. </html>