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
2.3 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Sizing</title>
  5. <style type="text/css">
  6. html, 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-network.min.css" rel="stylesheet" type="text/css" />
  17. <script type="text/javascript">
  18. var nodes = null;
  19. var edges = null;
  20. var network = null;
  21. function draw() {
  22. // create people.
  23. // value corresponds with the age of the person
  24. nodes = [
  25. {id: 1, value: 2, label: 'Algie' },
  26. {id: 2, value: 31, label: 'Alston'},
  27. {id: 3, value: 12, label: 'Barney'},
  28. {id: 4, value: 16, label: 'Coley' },
  29. {id: 5, value: 17, label: 'Grant' },
  30. {id: 6, value: 15, label: 'Langdon'},
  31. {id: 7, value: 6, label: 'Lee'},
  32. {id: 8, value: 5, label: 'Merlin'},
  33. {id: 9, value: 30, label: 'Mick'},
  34. {id: 10, value: 18, label: 'Tod'},
  35. ];
  36. // create connections between people
  37. // value corresponds with the amount of contact between two people
  38. edges = [
  39. {from: 2, to: 8, value: 3},
  40. {from: 2, to: 9, value: 5},
  41. {from: 2, to: 10,value: 1},
  42. {from: 4, to: 6, value: 8},
  43. {from: 5, to: 7, value: 2},
  44. {from: 4, to: 5, value: 1},
  45. {from: 9, to: 10,value: 2},
  46. {from: 2, to: 3, value: 6},
  47. {from: 3, to: 9, value: 4},
  48. {from: 5, to: 3, value: 1},
  49. {from: 2, to: 7, value: 4}
  50. ];
  51. // Instantiate our network object.
  52. var container = document.getElementById('mynetwork');
  53. var data = {
  54. nodes: nodes,
  55. edges: edges
  56. };
  57. var options = {
  58. nodes: {
  59. shape: 'dot',
  60. scaling: {
  61. customScalingFunction: function (min,max,total,value) {
  62. return value/total;
  63. },
  64. min:5,
  65. max:150
  66. }
  67. }
  68. };
  69. network = new vis.Network(container, data, options);
  70. }
  71. </script>
  72. <script src="../../googleAnalytics.js"></script>
  73. </head>
  74. <body onload="draw()">
  75. <p>
  76. Scale nodes and edges depending on their value. Hover over nodes and edges to get more information.
  77. </p>
  78. <div id="mynetwork"></div>
  79. </body>
  80. </html>