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, text: 'circle', style: 'circle', group: 'group_x'},
  18. {id: 2, text: 'circle', style: 'circle', group: 'group_x'},
  19. {id: 3, text: 'database', style: 'database', group: 'group_x'},
  20. {id: 4, text: 'rect', style: 'rect', group: 'group_x'}
  21. ];
  22. edges = [
  23. {from: 3, to: 1, style: 'arrow', width: 1},
  24. {from: 1, to: 4, style: 'moving-dot', width: 1},
  25. {from: 1, to: 2, style: 'moving-arrows', width: 2}
  26. ];
  27. var mainId = 5;
  28. nodes.push({id: mainId, text: 'styles\nand\nsizes', style: 'rect', group: 'group_main'});
  29. var styles = ['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, text: 'size ' + size, style: 'rect', group: 'group' + size});
  34. edges.push({from: mainId, to: groupId, color: 'gray', width: size});
  35. id++;
  36. for (var i in styles) {
  37. if (styles.hasOwnProperty(i)) {
  38. nodes.push({id: id, value: size, text: styles[i], style: styles[i], group: 'group' + size});
  39. edges.push({from: groupId, to: id, color: 'gray', width: size});
  40. id++;
  41. }
  42. }
  43. }
  44. // specify options
  45. var options = {
  46. width: '780px',
  47. height: '600px',
  48. stabilize: false
  49. };
  50. // Instantiate our graph object.
  51. graph = new vis.Graph(document.getElementById('mygraph'));
  52. // Draw our graph with the created data and options
  53. graph.draw(nodes, edges, options);
  54. }
  55. </script>
  56. </head>
  57. <body onload="draw()">
  58. <div id="mygraph"></div>
  59. <div id="info"></div>
  60. </body>
  61. </html>