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.

83 lines
2.5 KiB

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