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.

78 lines
3.1 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Shapes</title>
  5. <style type="text/css">
  6. #mynetwork {
  7. width: 1000px;
  8. height: 800px;
  9. border: 1px solid lightgray;
  10. }
  11. </style>
  12. <script type="text/javascript" src="../../../dist/vis.js"></script>
  13. <link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" />
  14. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  15. <script type="text/javascript">
  16. var nodes = null;
  17. var edges = null;
  18. var network = null;
  19. function draw() {
  20. nodes = [
  21. {id: 1, label: 'circle', shape: 'circle' },
  22. {id: 2, label: 'ellipse', shape: 'ellipse'},
  23. {id: 3, label: 'database',shape: 'database'},
  24. {id: 4, label: 'box', shape: 'box' },
  25. {id: 5, label: 'diamond', shape: 'diamond'},
  26. {id: 6, label: 'dot', shape: 'dot'},
  27. {id: 7, label: 'square', shape: 'square'},
  28. {id: 8, label: 'triangle',shape: 'triangle'},
  29. {id: 9, label: 'triangleDown', shape: 'triangleDown'},
  30. {id: 10, label: 'text', shape: 'text'},
  31. {id: 11, label: 'star', shape: 'star'},
  32. {id: 12, label: 'hexagon', shape: 'hexagon'},
  33. {id: 21, font:{size:30}, label: 'big circle', shape: 'circle' },
  34. {id: 22, font:{size:30}, label: 'big ellipse', shape: 'ellipse'},
  35. {id: 23, font:{size:30}, label: 'ellipse with a long label text', shape: 'ellipse'},
  36. {id: 24, font:{size:30}, label: 'big database',shape: 'database'},
  37. {id: 25, font:{size:30}, label: 'big box', shape: 'box' },
  38. {id: 26, font:{size:30}, size:40, label: 'big diamond', shape: 'diamond'},
  39. {id: 27, font:{size:30}, size:40, label: 'big dot', shape: 'dot'},
  40. {id: 28, font:{size:30}, size:40, label: 'big square', shape: 'square'},
  41. {id: 29, font:{size:30}, size:40, label: 'big triangle',shape: 'triangle'},
  42. {id: 30, font:{size:30}, size:40, label: 'big triangleDown', shape: 'triangleDown'},
  43. {id: 31, font:{size:30}, label: 'big text', shape: 'text'},
  44. {id: 32, font:{size:30}, size:40, label: 'big star', shape: 'star'},
  45. {id: 33, font:{size:30}, size:40, label: 'big hexagon', shape: 'hexagon'},
  46. {id: 34, font:{size:30}, label: 'icon square', shape: 'square', icon: {code:'\uf164'} },
  47. {id: 35, font:{size:30}, label: 'icon dot', shape: 'dot', icon: {code:'\uf165'} },
  48. ];
  49. edges = [
  50. ];
  51. // create a network
  52. var container = document.getElementById('mynetwork');
  53. var data = {
  54. nodes: nodes,
  55. edges: edges
  56. };
  57. var options = {physics:{barnesHut:{gravitationalConstant:-4000}}};
  58. network = new vis.Network(container, data, options);
  59. }
  60. </script>
  61. <body onload="draw()">
  62. <p>
  63. Nodes can have all sorts of shapes. Note the exception where the nodes with text inside and the text type's size are determined by the font size, not the node size.
  64. </p>
  65. <div id="mynetwork"></div>
  66. <div id="info"></div>
  67. </body>
  68. </html>