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 | Images</title>
  5. <style type="text/css">
  6. body {font: 10pt arial;}
  7. </style>
  8. <script type="text/javascript" src="../../vis.js"></script>
  9. <script type="text/javascript">
  10. var nodes = null;
  11. var edges = null;
  12. var graph = null;
  13. var DIR = 'img/refresh-cl/';
  14. var LENGTH_MAIN = 150;
  15. var LENGTH_SUB = 50;
  16. // Called when the Visualization API is loaded.
  17. function draw() {
  18. // Create a data table with nodes.
  19. nodes = [];
  20. // Create a data table with links.
  21. edges = [];
  22. nodes.push({id: 1, text: 'Main', image: DIR + 'Network-Pipe-icon.png', style: 'image'});
  23. nodes.push({id: 2, text: 'Office', image: DIR + 'Network-Pipe-icon.png', style: 'image'});
  24. nodes.push({id: 3, text: 'Wireless', image: DIR + 'Network-Pipe-icon.png', style: 'image'});
  25. edges.push({from: 1, to: 2, length: LENGTH_MAIN});
  26. edges.push({from: 1, to: 3, length: LENGTH_MAIN});
  27. for (var i = 4; i <= 7; i++) {
  28. nodes.push({id: i, text: 'Computer', image: DIR + 'Hardware-My-Computer-3-icon.png', style: 'image'});
  29. edges.push({from: 2, to: i, length: LENGTH_SUB});
  30. }
  31. nodes.push({id: 101, text: 'Printer', image: DIR + 'Hardware-Printer-Blue-icon.png', style: 'image'});
  32. edges.push({from: 2, to: 101, length: LENGTH_SUB});
  33. nodes.push({id: 102, text: 'Laptop', image: DIR + 'Hardware-Laptop-1-icon.png', style: 'image'});
  34. edges.push({from: 3, to: 102, length: LENGTH_SUB});
  35. nodes.push({id: 103, text: 'graph drive', image: DIR + 'Network-Drive-icon.png', style: 'image'});
  36. edges.push({from: 1, to: 103, length: LENGTH_SUB});
  37. nodes.push({id: 104, text: 'Internet', image: DIR + 'System-Firewall-2-icon.png', style: 'image'});
  38. edges.push({from: 1, to: 104, length: LENGTH_SUB});
  39. for (var i = 200; i <= 201; i++ ) {
  40. nodes.push({id: i, text: 'Smartphone', image: DIR + 'Hardware-My-PDA-02-icon.png', style: 'image'});
  41. edges.push({from: 3, to: i, length: LENGTH_SUB});
  42. }
  43. // create a graph
  44. var container = document.getElementById('mygraph');
  45. var data = {
  46. nodes: nodes,
  47. edges: edges
  48. };
  49. var options = {
  50. width: '600px',
  51. height: '600px',
  52. stabilize: false // stabilize positions before displaying
  53. };
  54. graph = new vis.Graph(container, data, options);
  55. }
  56. </script>
  57. </head>
  58. <body onload="draw()">
  59. <div id="mygraph"></div>
  60. </body>
  61. </html>