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.

85 lines
2.8 KiB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>Network | On Load Animation</title>
  6. <script type="text/javascript" src="../../../dist/vis.js"></script>
  7. <link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" />
  8. <style type="text/css">
  9. #mynetwork {
  10. width: 600px;
  11. height: 400px;
  12. border: 1px solid lightgray;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <h2>Vis.js network onLoad animation</h2>
  18. <p>easeIn functions accelerate from zero velocity.</p>
  19. <p>easeOut functions decelerate to zero velocity.</p>
  20. <p>easeInOut functions accelerate from zero till halfway then after the halfway point they decrease until zero.</p>
  21. <div>
  22. Onload Animation Easing Function -
  23. <select id="easingFunction">
  24. <option value="linear">linear</option>
  25. <option value="easeInQuad">easeInQuad</option>
  26. <option value="easeOutQuad">easeOutQuad</option>
  27. <option value="easeInOutQuad">easeInOutQuad</option>
  28. <option value="easeInCubic">easeInCubic</option>
  29. <option value="easeOutCubic">easeOutCubic</option>
  30. <option value="easeInOutCubic">easeInOutCubic</option>
  31. <option value="easeInQuart">easeInQuart</option>
  32. <option value="easeOutQuart">easeOutQuart</option>
  33. <option value="easeInOutQuart">easeInOutQuart</option>
  34. <option value="easeInQuint">easeInQuint</option>
  35. <option value="easeOutQuint">easeOutQuint</option>
  36. <option value="easeInOutQuint">easeInOutQuint</option>
  37. </select>
  38. <button onClick="createNetwork(document.getElementById('easingFunction').value);">Demo Easing Function</button>
  39. </div>
  40. <p>For more information on easing functions check out <a href="http://easings.net/">easings.net</a></p>
  41. <div id="mynetwork"></div>
  42. <script type="text/javascript">
  43. document.getElementById("easingFunction").selectedIndex = 0;
  44. function createNetwork(easingType) {
  45. var nodes = new vis.DataSet([
  46. {id: 1, label: 'Node 1'},
  47. {id: 2, label: 'Node 2'},
  48. {id: 3, label: 'Node 3'},
  49. {id: 4, label: 'Node 4'},
  50. {id: 5, label: 'Node 5'}
  51. ]);
  52. var edges = new vis.DataSet([
  53. {from: 1, to: 3},
  54. {from: 1, to: 2},
  55. {from: 2, to: 4},
  56. {from: 2, to: 5}
  57. ]);
  58. var container = document.getElementById('mynetwork');
  59. var data = {
  60. nodes: nodes,
  61. edges: edges
  62. };
  63. var options = {};
  64. var network = new vis.Network(container, data, options);
  65. network.once("beforeDrawing", function() {
  66. network.focus(2, {
  67. scale: 12
  68. });
  69. });
  70. network.once("afterDrawing", function() {
  71. network.fit({
  72. animation: {
  73. duration: 3000,
  74. easingFunction: easingType
  75. }
  76. });
  77. });
  78. }
  79. createNetwork("linear");
  80. </script>
  81. </body>
  82. </html>