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.

67 lines
1.8 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JS Bin</title>
  6. <script type="text/javascript" src="../dist/vis.js"></script> <!-- network handling framework -->
  7. <link href="../dist/vis.css" rel="stylesheet" type="text/css"/>
  8. <style type="text/css">
  9. #network{
  10. width: 1900px;
  11. height: 800px;
  12. border: 1px solid lightgray;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <h1>Network Test</h1>
  18. <div id="network"></div>
  19. <script>
  20. var network = null;
  21. var idmap = {};
  22. for (var i = 0; i < nodes.length; i++) {
  23. nodes[i].label = i;
  24. idmap[nodes[i].id] = i;
  25. nodes[i].id = i;
  26. }
  27. for (var i = 0; i < edges.length; i++) {
  28. edges[i].from = idmap[edges[i].from];
  29. edges[i].to = idmap[edges[i].to];
  30. edges[i].id = 'e'+i;
  31. }
  32. console.log(JSON.stringify(nodes), JSON.stringify(edges));
  33. // randomly create some nodes and edges
  34. var data = {
  35. nodes: nodes,
  36. edges: edges
  37. }
  38. // create a network
  39. var status = document.getElementById('status');
  40. var container = document.getElementById('network');
  41. var options = {
  42. layout: {
  43. hierarchical: {
  44. direction: "UD",
  45. sortMethod: "directed"
  46. }
  47. },
  48. physics: {
  49. enabled: false,
  50. stabilization:false
  51. }
  52. };
  53. network = new vis.Network(container, data, options);
  54. network.on("stabilizationProgress", function(params) {
  55. var prog = params.iterations/params.total;
  56. status.innerText = Math.round(prog*100)+'%';
  57. });
  58. network.on("stabilizationIterationsDone", function() {
  59. status.innerText = "stabilized";
  60. });
  61. </script>
  62. </body>
  63. </html>