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. // specify options
  44. var options = {
  45. width: '600px',
  46. height: '600px',
  47. stabilize: false // stabilize positions before displaying
  48. };
  49. // create a graph
  50. graph = new vis.Graph(document.getElementById('mygraph'));
  51. // draw data
  52. graph.draw(nodes, edges, options);
  53. }
  54. </script>
  55. </head>
  56. <body onload="draw()">
  57. <div id="mygraph"></div>
  58. </body>
  59. </html>