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.

75 lines
2.4 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Static smooth curves</title>
  5. <script type="text/javascript" src="../../dist/vis.js"></script>
  6. <style type="text/css">
  7. #mynetwork {
  8. width: 400px;
  9. height: 400px;
  10. border: 1px solid lightgray;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <h2>Static smooth curves</h2>
  16. <div style="width:700px; font-size:14px;">
  17. All the smooth curves in the examples so far have been using dynamic smooth curves. This means that each curve has a
  18. support node which takes part in the physics simulation. For large networks or dense clusters, this may not be the ideal
  19. solution. To solve this, static smooth curves have been added. The static smooth curves are based only on the positions of the connected
  20. nodes. There are multiple ways to determine the way this curve is drawn. This example shows the effect of the different
  21. types. <br /> <br />
  22. Drag the nodes around each other to see how the smooth curves are drawn for each setting. For animated system, we
  23. recommend only the continuous mode. In the next example you can see the effect of these methods on a large network. Keep in mind
  24. that the direction (the from and to) of the curve matters.
  25. <br /> <br />
  26. </div>
  27. Smooth curve type:
  28. <select id="dropdownID">
  29. <option value="continuous">continuous</option>
  30. <option value="discrete">discrete</option>
  31. <option value="diagonalCross">diagonalCross</option>
  32. <option value="straightCross">straightCross</option>
  33. <option value="horizontal">horizontal</option>
  34. <option value="vertical">vertical</option>
  35. </select>
  36. <div id="mynetwork"></div>
  37. <script type="text/javascript">
  38. var dropdown = document.getElementById("dropdownID");
  39. dropdown.onchange = update;
  40. // create an array with nodes
  41. var nodes = [
  42. {id: 1, label: 'Node 1'},
  43. {id: 2, label: 'Node 2', x:150, y:130, allowedToMoveX: true, allowedToMoveY: true}
  44. ];
  45. // create an array with edges
  46. var edges = [
  47. {from: 1, to: 2}
  48. ];
  49. // create a network
  50. var container = document.getElementById('mynetwork');
  51. var data = {
  52. nodes: nodes,
  53. edges: edges
  54. };
  55. var options = {physics:{barnesHut:{gravitationalConstant:0, springConstant:0, centralGravity: 0}},
  56. smoothCurves:{dynamic:false, type: '1'}};
  57. var network = new vis.Network(container, data, options);
  58. function update() {
  59. var type = dropdown.value;
  60. network.setOptions({smoothCurves:{type:type}});
  61. }
  62. </script>
  63. </body>
  64. </html>