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.5 KiB

  1. <!doctype html>
  2. <html>
  3. <head><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script>
  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. ];
  28. edges = [
  29. {from: 3, to: 1, style: 'arrow'},
  30. {from: 1, to: 4, style: 'dash-line'},
  31. {from: 1, to: 2, style: 'arrow-center'}
  32. ];
  33. var mainId = 5;
  34. nodes.push({id: mainId, label: 'shapes\nand\nsizes', shape: 'box', group: 'group_main'});
  35. var shapes = ['dot', 'square', 'triangle', 'triangleDown', 'star'];
  36. var id = 6;
  37. for (var size = 1; size < 4; size++) {
  38. var groupId = id;
  39. nodes.push({id: id, label: 'size ' + size, shape: 'box', group: 'group' + size});
  40. edges.push({from: mainId, to: groupId, color: 'gray', width: size});
  41. id++;
  42. for (var i in shapes) {
  43. if (shapes.hasOwnProperty(i)) {
  44. nodes.push({id: id, value: size, label: shapes[i], shape: shapes[i], group: 'group' + size});
  45. edges.push({from: groupId, to: id, color: 'gray', width: size});
  46. id++;
  47. }
  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>