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.

76 lines
2.3 KiB

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