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.

132 lines
3.7 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Custom Groups</title>
  5. <style>
  6. body {
  7. color: #d3d3d3;
  8. font: 12pt arial;
  9. background-color: #222222;
  10. }
  11. #mynetwork {
  12. width: 800px;
  13. height: 800px;
  14. border: 1px solid #444444;
  15. background-color: #222222;
  16. }
  17. </style>
  18. <script type="text/javascript" src="../../../dist/vis.js"></script>
  19. <link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css"/>
  20. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  21. </head>
  22. <body>
  23. <i class="fa fa-flag"></i> We use an icon once in the DOM so the CSS for fontAwesome is loaded.</h2>
  24. <div id="mynetwork"></div>
  25. <script type="text/javascript">
  26. var nodes = [
  27. {id: 0, label: "0", group: 'source'},
  28. {id: 1, label: "1", group: 'icons'},
  29. {id: 2, label: "2", group: 'icons'},
  30. {id: 3, label: "3", group: 'icons'},
  31. {id: 4, label: "4", group: 'icons'},
  32. {id: 5, label: "5", group: 'icons'},
  33. {id: 6, label: "6", group: 'icons'},
  34. {id: 7, label: "7", group: 'icons'},
  35. {id: 8, label: "8", group: 'icons'},
  36. {id: 9, label: "9", group: 'icons'},
  37. {id: 10, label: "10", group: 'mints'},
  38. {id: 11, label: "11", group: 'mints'},
  39. {id: 12, label: "12", group: 'mints'},
  40. {id: 13, label: "13", group: 'mints'},
  41. {id: 14, label: "14", group: 'mints'},
  42. {id: 15, group: 'dotsWithLabel'},
  43. {id: 16, group: 'dotsWithLabel'},
  44. {id: 17, group: 'dotsWithLabel'},
  45. {id: 18, group: 'dotsWithLabel'},
  46. {id: 19, group: 'dotsWithLabel'},
  47. {id: 20, label: "diamonds", group: 'diamonds'},
  48. {id: 21, label: "diamonds", group: 'diamonds'},
  49. {id: 22, label: "diamonds", group: 'diamonds'},
  50. {id: 23, label: "diamonds", group: 'diamonds'},
  51. ];
  52. var edges = [
  53. {from: 1, to: 0},
  54. {from: 2, to: 0},
  55. {from: 4, to: 3},
  56. {from: 5, to: 4},
  57. {from: 4, to: 0},
  58. {from: 7, to: 6},
  59. {from: 8, to: 7},
  60. {from: 7, to: 0},
  61. {from: 10, to: 9},
  62. {from: 11, to: 10},
  63. {from: 10, to: 4},
  64. {from: 13, to: 12},
  65. {from: 14, to: 13},
  66. {from: 13, to: 0},
  67. {from: 16, to: 15},
  68. {from: 17, to: 15},
  69. {from: 15, to: 10},
  70. {from: 19, to: 18},
  71. {from: 20, to: 19},
  72. {from: 19, to: 4},
  73. {from: 22, to: 21},
  74. {from: 23, to: 22},
  75. {from: 23, to: 0},
  76. ]
  77. // create a network
  78. var container = document.getElementById('mynetwork');
  79. var data = {
  80. nodes: nodes,
  81. edges: edges
  82. };
  83. var options = {
  84. nodes: {
  85. shape: 'dot',
  86. size: 20,
  87. font: {
  88. size: 15,
  89. color: '#ffffff'
  90. },
  91. borderWidth: 2
  92. },
  93. edges: {
  94. width: 2
  95. },
  96. groups: {
  97. diamonds: {
  98. color: {background:'red',border:'white'},
  99. shape: 'diamond'
  100. },
  101. dotsWithLabel: {
  102. label: "I'm a dot!",
  103. shape: 'dot',
  104. color: 'cyan'
  105. },
  106. mints: {color:'rgb(0,255,140)'},
  107. icons: {
  108. shape: 'icon',
  109. icon: {
  110. face: 'FontAwesome',
  111. code: '\uf0c0',
  112. size: 50,
  113. color: 'orange'
  114. }
  115. },
  116. source: {
  117. color:{border:'white'}
  118. }
  119. }
  120. };
  121. var network = new vis.Network(container, data, options);
  122. </script>
  123. </body>
  124. </html>