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.

82 lines
2.7 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Images</title>
  5. <style type="text/css">
  6. #mynetwork {
  7. width: 600px;
  8. height: 600px;
  9. border: 1px solid lightgray;
  10. }
  11. </style>
  12. <script type="text/javascript" src="../../../../dist/vis.js"></script>
  13. <link href="../../../../dist/vis.css" rel="stylesheet" type="text/css" />
  14. <script type="text/javascript">
  15. var nodes = null;
  16. var edges = null;
  17. var network = null;
  18. var DIR = '../../img/refresh-cl/';
  19. var EDGE_LENGTH_MAIN = 150;
  20. var EDGE_LENGTH_SUB = 50;
  21. // Called when the Visualization API is loaded.
  22. function draw() {
  23. // Create a data table with nodes.
  24. nodes = [];
  25. // Create a data table with links.
  26. edges = [];
  27. nodes.push({id: 1, label: 'Main', image: DIR + 'Network-Pipe-icon.png', shape: 'image'});
  28. nodes.push({id: 2, label: 'Office', image: DIR + 'Network-Pipe-icon.png', shape: 'image'});
  29. nodes.push({id: 3, label: 'Wireless', image: DIR + 'Network-Pipe-icon.png', shape: 'image'});
  30. edges.push({from: 1, to: 2, length: EDGE_LENGTH_MAIN});
  31. edges.push({from: 1, to: 3, length: EDGE_LENGTH_MAIN});
  32. for (var i = 4; i <= 7; i++) {
  33. nodes.push({id: i, label: 'Computer', image: DIR + 'Hardware-My-Computer-3-icon.png', shape: 'image'});
  34. edges.push({from: 2, to: i, length: EDGE_LENGTH_SUB});
  35. }
  36. nodes.push({id: 101, label: 'Printer', image: DIR + 'Hardware-Printer-Blue-icon.png', shape: 'image'});
  37. edges.push({from: 2, to: 101, length: EDGE_LENGTH_SUB});
  38. nodes.push({id: 102, label: 'Laptop', image: DIR + 'Hardware-Laptop-1-icon.png', shape: 'image'});
  39. edges.push({from: 3, to: 102, length: EDGE_LENGTH_SUB});
  40. nodes.push({id: 103, label: 'network drive', image: DIR + 'Network-Drive-icon.png', shape: 'image'});
  41. edges.push({from: 1, to: 103, length: EDGE_LENGTH_SUB});
  42. nodes.push({id: 104, label: 'Internet', image: DIR + 'System-Firewall-2-icon.png', shape: 'image'});
  43. edges.push({from: 1, to: 104, length: EDGE_LENGTH_SUB});
  44. for (var i = 200; i <= 201; i++ ) {
  45. nodes.push({id: i, label: 'Smartphone', image: DIR + 'Hardware-My-PDA-02-icon.png', shape: 'image'});
  46. edges.push({from: 3, to: i, length: EDGE_LENGTH_SUB});
  47. }
  48. // create a network
  49. var container = document.getElementById('mynetwork');
  50. var data = {
  51. nodes: nodes,
  52. edges: edges
  53. };
  54. var options = {};
  55. network = new vis.Network(container, data, options);
  56. }
  57. </script>
  58. <script src="../../../googleAnalytics.js"></script>
  59. <body onload="draw()">
  60. <p>
  61. Display nodes as images.
  62. </p>
  63. <div id="mynetwork"></div>
  64. </body>
  65. </html>