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.

78 lines
2.3 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. <link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" />
  7. <style type="text/css">
  8. #mynetwork {
  9. width: 500px;
  10. height: 500px;
  11. border: 1px solid lightgray;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16. <h2>Smooth curves</h2>
  17. <div style="width:700px; font-size:14px; text-align: justify;">
  18. All the smooth curves in the examples so far have been using dynamic smooth curves. This means that each curve has a
  19. support node which takes part in the physics simulation. For large networks or dense clusters, this may not be the ideal
  20. solution. To solve this, static smooth curves have been added. The static smooth curves are based only on the positions of the connected
  21. nodes. There are multiple ways to determine the way this curve is drawn. This example shows the effect of the different
  22. types. <br /> <br />
  23. Drag the node around to see how the smooth curves are drawn for each setting. For animated system, we
  24. recommend only the continuous mode. In the next example you can see the effect of these methods on a large network. Keep in mind
  25. that the direction (the from and to) of the curve matters.
  26. <br /> <br />
  27. When you select the dynamic type, you can see the interaction with the fixed node and the edge, any other type will not interact with other nodes.
  28. <br /> <br />
  29. </div>
  30. <div id="mynetwork"></div>
  31. <script type="text/javascript">
  32. // create an array with nodes
  33. var nodes = [
  34. {id: 1, label: 'Fixed node', x:0, y:0, fixed:true},
  35. {id: 2, label: 'Drag me', x:150, y:130, physics:false},
  36. {id: 3, label: 'Obstacle', x:80, y:-80, fixed:true, mass:10}
  37. ];
  38. // create an array with edges
  39. var edges = [
  40. {from: 1, to: 2, arrows:'to'}
  41. ];
  42. // create a network
  43. var container = document.getElementById('mynetwork');
  44. var data = {
  45. nodes: nodes,
  46. edges: edges
  47. };
  48. var options = {
  49. physics:true,
  50. configure:function (option, path) {
  51. if (path.indexOf('smooth') !== -1 || option === 'smooth') {
  52. return true;
  53. }
  54. return false;
  55. },
  56. edges: {
  57. smooth: {
  58. type: 'continuous'
  59. }
  60. }
  61. };
  62. var network = new vis.Network(container, data, options);
  63. </script>
  64. </body>
  65. </html>