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.

84 lines
3.0 KiB

  1. <!doctype html>
  2. <html>
  3. <head><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script>
  4. <title>Network | Images</title>
  5. <style type="text/css">
  6. body {
  7. font: 10pt arial;
  8. }
  9. #mynetwork {
  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. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  17. <script type="text/javascript">
  18. var nodes = null;
  19. var edges = null;
  20. var network = null;
  21. var DIR = 'img/refresh-cl/';
  22. var LENGTH_MAIN = 150;
  23. var LENGTH_SUB = 50;
  24. // Called when the Visualization API is loaded.
  25. function draw() {
  26. // Create a data table with nodes.
  27. nodes = [];
  28. // Create a data table with links.
  29. edges = [];
  30. nodes.push({id: 1, label: 'Main', image: DIR + 'Network-Pipe-icon.png', shape: 'image'});
  31. nodes.push({id: 2, label: 'Office', image: DIR + 'Network-Pipe-icon.png', shape: 'image'});
  32. nodes.push({id: 3, label: 'Wireless', image: DIR + 'Network-Pipe-icon.png', shape: 'image'});
  33. edges.push({from: 1, to: 2, length: LENGTH_MAIN});
  34. edges.push({from: 1, to: 3, length: LENGTH_MAIN});
  35. for (var i = 4; i <= 7; i++) {
  36. nodes.push({id: i, label: 'Computer', image: DIR + 'Hardware-My-Computer-3-icon.png', shape: 'image'});
  37. edges.push({from: 2, to: i, length: LENGTH_SUB});
  38. }
  39. nodes.push({id: 101, label: 'Printer', image: DIR + 'Hardware-Printer-Blue-icon.png', shape: 'image'});
  40. edges.push({from: 2, to: 101, length: LENGTH_SUB});
  41. nodes.push({id: 102, label: 'Laptop', image: DIR + 'Hardware-Laptop-1-icon.png', shape: 'image'});
  42. edges.push({from: 3, to: 102, length: LENGTH_SUB});
  43. nodes.push({id: 103, label: 'network drive', image: DIR + 'Network-Drive-icon.png', shape: 'image'});
  44. edges.push({from: 1, to: 103, length: LENGTH_SUB});
  45. nodes.push({id: 104, label: 'Internet', image: DIR + 'System-Firewall-2-icon.png', shape: 'image'});
  46. edges.push({from: 1, to: 104, length: LENGTH_SUB});
  47. for (var i = 200; i <= 201; i++ ) {
  48. nodes.push({id: i, label: 'Smartphone', image: DIR + 'Hardware-My-PDA-02-icon.png', shape: 'image'});
  49. edges.push({from: 3, to: i, length: LENGTH_SUB});
  50. }
  51. // create a network
  52. var container = document.getElementById('mynetwork');
  53. var data = {
  54. nodes: nodes,
  55. edges: edges
  56. };
  57. var options = {
  58. stabilize: false // stabilize positions before displaying
  59. };
  60. network = new vis.Network(container, data, options);
  61. }
  62. </script>
  63. </head>
  64. <body onload="draw()">
  65. <div id="mynetwork"></div>
  66. </body>
  67. </html>