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.

153 lines
4.4 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. <script src="./data/WorldCup2014.js"></script>
  10. <style type="text/css">
  11. #mynetwork {
  12. width: 800px;
  13. height: 800px;
  14. border: 1px solid lightgray;
  15. }
  16. </style>
  17. <script src="../googleAnalytics.js"></script>
  18. </head>
  19. <body>
  20. <h2>Static smooth curves - World Cup Network</h2>
  21. <div style="width:700px; font-size:14px;">
  22. The static smooth curves are based only on the positions of the connected
  23. nodes.
  24. There are multiple ways to determine the way this curve is drawn.
  25. This example shows the effect of the different types on a large network.
  26. <br/> <br/>
  27. Also shown in this example is the inheritColor option of the edges as well as
  28. the roundness factor. <br/>
  29. <br/><br/>
  30. To improve performance, the physics have been disabled with:
  31. <br/><code>{barnesHut: {gravitationalConstant: 0, centralGravity: 0,
  32. springConstant: 0}}</code><br/> and we have enabled
  33. the toggle hideEdgesOnDrag.
  34. <br/><br/>
  35. </div>
  36. Smooth curve type:
  37. <select id="dropdownID">
  38. <option value="continuous">continuous</option>
  39. <option value="discrete">discrete</option>
  40. <option value="diagonalCross">diagonalCross</option>
  41. <option value="straightCross">straightCross</option>
  42. <option value="horizontal">horizontal</option>
  43. <option value="vertical">vertical</option>
  44. <option value="curvedCW">curvedCW</option>
  45. <option value="curvedCCW">curvedCCW</option>
  46. </select><br/>
  47. inheritColor option:
  48. <select id="inheritColor">
  49. <option value="from">from / true</option>
  50. <option value="to">to</option>
  51. <option value="false">false</option>
  52. </select><br/>
  53. Roundness (0..1): <input type="range" min="0" max="1" value="0.5" step="0.05"
  54. style="width:200px" id="roundnessSlider"> <input
  55. id="roundnessScreen" value="0.5"> (0.5 is max roundness for continuous, 1.0
  56. for the others)
  57. <br/>
  58. Hide edges on drag: <input type="checkbox" checked="checked"
  59. id="hideEdgesOnDrag"><br/>
  60. Hide nodes on drag: <input type="checkbox" id="hideNodesOnDrag">
  61. <div id="mynetwork"></div>
  62. <script type="text/javascript">
  63. var dropdown = document.getElementById("dropdownID");
  64. dropdown.onchange = update;
  65. var roundnessSlider = document.getElementById("roundnessSlider");
  66. roundnessSlider.onchange = update;
  67. var roundnessScreen = document.getElementById("roundnessScreen");
  68. var hideEdgesOnDrag = document.getElementById("hideEdgesOnDrag");
  69. hideEdgesOnDrag.onchange = update;
  70. var hideNodesOnDrag = document.getElementById("hideNodesOnDrag");
  71. hideNodesOnDrag.onchange = update;
  72. var inheritColor = document.getElementById("inheritColor");
  73. inheritColor.onchange = redrawAll;
  74. var network;
  75. function redrawAll() {
  76. network = null;
  77. var inheritColorVal = inheritColor.value;
  78. var container = document.getElementById('mynetwork');
  79. var options = {
  80. nodes: {
  81. shape: 'dot',
  82. radiusMin: 10,
  83. radiusMax: 30,
  84. fontSize: 12,
  85. fontFace: "Tahoma"
  86. },
  87. edges: {
  88. width: 0.15,
  89. inheritColor: "from"
  90. },
  91. tooltip: {
  92. delay: 200,
  93. fontSize: 12,
  94. color: {
  95. background: "#fff"
  96. }
  97. },
  98. smoothCurves: {dynamic: false, type: "continuous"},
  99. stabilize: false,
  100. physics: {
  101. barnesHut: {
  102. gravitationalConstant: 0,
  103. centralGravity: 0,
  104. springConstant: 0
  105. }
  106. },
  107. hideEdgesOnDrag: true
  108. };
  109. if (inheritColorVal == "false") {
  110. options['edges']['inheritColor'] = false;
  111. }
  112. else {
  113. options['edges']['inheritColor'] = inheritColorVal;
  114. }
  115. // Note: data is coming from ./data/WorldCup2014.js
  116. network = new vis.Network(container, data, options);
  117. }
  118. function update() {
  119. var type = dropdown.value;
  120. var roundness = roundnessSlider.value;
  121. roundnessScreen.value = roundness;
  122. var options = {smoothCurves: {type: type, roundness: roundness}}
  123. options['hideEdgesOnDrag'] = hideEdgesOnDrag.checked;
  124. options['hideNodesOnDrag'] = hideNodesOnDrag.checked;
  125. //network.setOptions(options);
  126. }
  127. redrawAll()
  128. </script>
  129. </body>
  130. </html>