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.

86 lines
3.8 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 | Scalable 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 DIR = 'img/soft-scraps-icons/';
  19. var nodes = null;
  20. var edges = null;
  21. var network = null;
  22. // Called when the Visualization API is loaded.
  23. function draw() {
  24. // create people.
  25. // value corresponds with the age of the person
  26. var DIR = 'img/soft-scraps-icons/';
  27. nodes = [
  28. {id: 1, value: 2, shape: 'image', label: 'Algie', title: 'Algie (2 years old)', image: DIR + 'Smiley-Angry-icon.png'},
  29. {id: 2, value: 31, shape: 'image', label: 'Alston', title: 'Alston (31 years old)', image: DIR + 'Smiley-Grin-icon.png'},
  30. {id: 3, value: 12, shape: 'image', label: 'Barney', title: 'Barney (12 years old)', image: DIR + 'User-Administrator-Blue-icon.png'},
  31. {id: 4, value: 16, shape: 'image', label: 'Coley', title: 'Coley (16 years old)', image: DIR + 'User-Administrator-Green-icon.png'},
  32. {id: 5, value: 17, shape: 'image', label: 'Grant', title: 'Grant (17 years old)', image: DIR + 'User-Coat-Blue-icon.png'},
  33. {id: 6, value: 15, shape: 'image', label: 'Langdon', title: 'Langdon (15 years old)', image: DIR + 'User-Coat-Green-icon.png'},
  34. {id: 7, value: 6, shape: 'image', label: 'Lee', title: 'Lee (6 years old)', image: DIR + 'User-Coat-Red-icon.png'},
  35. {id: 8, value: 5, shape: 'image', label: 'Merlin', title: 'Merlin (5 years old)', image: DIR + 'User-Executive-Green-icon.png'},
  36. {id: 9, value: 30, shape: 'image', label: 'Mick', title: 'Mick (30 years old)', image: DIR + 'User-Preppy-Blue-icon.png'},
  37. {id: 10, value: 18, shape: 'image', label: 'Tod', title: 'Tod (18 years old)', image: DIR + 'User-Preppy-Red-icon.png'}
  38. ];
  39. // create connetions between people
  40. // value corresponds with the amount of contact between two people
  41. edges = [
  42. {from: 2, to: 8, value: 3, title: '3 emails per week'},
  43. {from: 2, to: 9, value: 5, title: '5 emails per week'},
  44. {from: 2, to: 10,value: 1, title: '1 emails per week'},
  45. {from: 4, to: 6, value: 8, title: '8 emails per week'},
  46. {from: 5, to: 7, value: 2, title: '2 emails per week'},
  47. {from: 4, to: 5, value: 1, title: '1 emails per week'},
  48. {from: 9, to: 10,value: 2, title: '2 emails per week'},
  49. {from: 2, to: 3, value: 6, title: '6 emails per week'},
  50. {from: 3, to: 9, value: 4, title: '4 emails per week'},
  51. {from: 5, to: 3, value: 1, title: '1 emails per week'},
  52. {from: 2, to: 7, value: 4, title: '4 emails per week'}
  53. ];
  54. // create a network
  55. var container = document.getElementById('mynetwork');
  56. var data = {
  57. nodes: nodes,
  58. edges: edges
  59. };
  60. var options = {
  61. nodes: {
  62. widthMin: 20, // min width in pixels
  63. widthMax: 100 // max width in pixels
  64. },
  65. edges: {
  66. color: 'lightgray'
  67. }
  68. };
  69. network = new vis.Network(container, data, options);
  70. }
  71. </script>
  72. </head>
  73. <body onload="draw()">
  74. <div id="mynetwork"></div>
  75. <div id="info"></div>
  76. </body>
  77. </html>