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.

77 lines
2.2 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Shapes</title>
  5. <style type="text/css">
  6. body {
  7. font: 10pt arial;
  8. }
  9. #mynetwork {
  10. width: 100%;
  11. height: 600px;
  12. border: 1px solid lightgray;
  13. }
  14. </style>
  15. <script type="text/javascript" src="../../dist/vis.js"></script>
  16. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  17. <script type="text/javascript">
  18. var nodes = null;
  19. var edges = null;
  20. var network = null;
  21. function draw() {
  22. nodes = [
  23. {id: 1, label: 'circle', shape: 'circle', group: 'group_x'},
  24. {id: 2, label: 'ellipse', shape: 'ellipse', group: 'group_x'},
  25. {id: 3, label: 'database',shape: 'database',group: 'group_x'},
  26. {id: 4, label: 'box', shape: 'box', group: 'group_x'},
  27. {id: 5, label: 'diamond', shape: 'diamond', group: 'group_x'}
  28. ];
  29. edges = [
  30. {from: 3, to: 1, arrows: 'to'},
  31. {from: 1, to: 4, dashes: true},
  32. {from: 1, to: 2, dashes: true, arrows: 'to, from'},
  33. {from: 1, to: 5, arrows: 'middle'}
  34. ];
  35. var mainId = 6;
  36. nodes.push({id: mainId, label: 'shapes and\nsizes', shape: 'box', group: 'group_main'});
  37. var shapes = ['dot', 'square', 'triangle', 'triangleDown', 'star','diamond'];
  38. var id = 7;
  39. for (var size = 1; size < 4; size++) {
  40. var groupId = id;
  41. nodes.push({id: id, label: 'size ' + size, shape: 'box', group: 'group' + size});
  42. edges.push({from: mainId, to: groupId, color: 'gray', width: size});
  43. id++;
  44. for (var i = 0; i < shapes.length; i++) {
  45. nodes.push({id: id, value: size, label: shapes[i], shape: shapes[i], group: 'group' + size});
  46. edges.push({from: groupId, to: id, color: 'gray', width: size});
  47. id++;
  48. }
  49. }
  50. // create a network
  51. var container = document.getElementById('mynetwork');
  52. var data = {
  53. nodes: nodes,
  54. edges: edges
  55. };
  56. var options = {
  57. stabilize: false
  58. };
  59. network = new vis.Network(container, data, options);
  60. }
  61. </script>
  62. </head>
  63. <body onload="draw()">
  64. <div id="mynetwork"></div>
  65. <div id="info"></div>
  66. </body>
  67. </html>