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.

122 lines
3.5 KiB

  1. <!doctype html>
  2. <!-- saved from url=(0044)http://kenedict.com/networks/worldcup14/vis/ , thanks Andre!-->
  3. <html>
  4. <head>
  5. <meta http-equiv="content-type" content="text/html; charset=UTF8">
  6. <title>Network | Static smooth curves - World Cup Network</title>
  7. <script type="text/javascript" src="../dist/vis.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../dist/vis.css">
  9. <style type="text/css">
  10. #mynetwork {
  11. width: 800px;
  12. height: 800px;
  13. border: 1px solid lightgray;
  14. }
  15. </style>
  16. <script src="../../googleAnalytics.js"></script>
  17. </head>
  18. <body>
  19. <h2>Performance - World Cup Network</h2>
  20. <div style="width:700px; font-size:14px;">
  21. This example shows the performance of vis with a larger network. The edges in
  22. particular (~9200) are very computationally intensive
  23. to draw. Drag and hold the graph to see the performance difference if the
  24. edges are hidden.
  25. <br/><br/>
  26. We use the following physics configuration: <br/>
  27. <code>{barnesHut: {gravitationalConstant: -80000, springConstant: 0.001,
  28. springLength: 200}}</code>
  29. <br/><br/>
  30. </div>
  31. <div id="mynetwork"></div>
  32. <script type="text/javascript">
  33. var network;
  34. function loadJSON(path, success, error) {
  35. var xhr = new XMLHttpRequest();
  36. xhr.onreadystatechange = function () {
  37. if (xhr.readyState === 4) {
  38. if (xhr.status === 200) {
  39. success(JSON.parse(xhr.responseText));
  40. }
  41. else {
  42. error(xhr);
  43. }
  44. }
  45. };
  46. xhr.open('GET', path, true);
  47. xhr.send();
  48. }
  49. function redrawAll(data) {
  50. // remove positoins
  51. // for (var i = 0; i < nodes.length; i++) {
  52. // delete nodes[i].x;
  53. // delete nodes[i].y;
  54. // }
  55. // create a network
  56. var container = document.getElementById('mynetwork');
  57. console.log(data)
  58. var options = {
  59. edges:{
  60. // smooth:false,
  61. },
  62. layout:{
  63. improvedLayout:false
  64. },
  65. interaction: {
  66. hideEdgesOnDrag: true,
  67. keyboard: true,
  68. multiselect: true
  69. },
  70. physics: {
  71. enabled: true,
  72. solver: 'forceAtlas2Based',
  73. forceAtlas2Based: {
  74. gravitationalConstant: -100,
  75. springConstant: 0.40,
  76. springLength: 50,
  77. damping: 0.1,
  78. avoidOverlap: 0
  79. },
  80. stabilization: {
  81. enabled: true,
  82. iterations: 1000,
  83. fit: true
  84. },
  85. timestep: 0.5
  86. }
  87. };
  88. // Note: data is coming from ./datasources/WorldCup2014.js
  89. network = new vis.Network(container, data, options);
  90. network.on("startStabilizing", function (params) {
  91. console.log("started")
  92. });
  93. network.on("stabilizationProgress", function (params) {
  94. console.log("progress:",params);
  95. });
  96. network.on("stabilizationIterationsDone", function (params) {
  97. console.log("finished stabilization interations");
  98. });
  99. network.on("stabilized", function (params) {
  100. console.log("stabilized!", params);
  101. });
  102. }
  103. loadJSON('./dataTest.json', redrawAll, function(err) {console.log('error')});
  104. </script>
  105. </body>
  106. </html>