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.

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