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.

184 lines
3.8 KiB

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Network | node as icon</title>
  6. <script type="text/javascript" src="../../dist/vis.js"></script>
  7. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  8. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  9. <link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  10. <style>
  11. #mynetworkFA,
  12. #mynetworkIO {
  13. height: 300px;
  14. }
  15. </style>
  16. <script language="JavaScript">
  17. function draw() {
  18. /*
  19. * Example for FontAwesome
  20. */
  21. var optionsFA = {
  22. groups: {
  23. usergroups: {
  24. shape: 'icon',
  25. icon: {
  26. face: 'FontAwesome',
  27. code: '\uf0c0',
  28. size: 50,
  29. color: '#57169a'
  30. }
  31. },
  32. users: {
  33. shape: 'icon',
  34. icon: {
  35. face: 'FontAwesome',
  36. code: '\uf007',
  37. size: 50,
  38. color: '#aa00ff'
  39. }
  40. }
  41. }
  42. };
  43. // create an array with nodes
  44. var nodesFA = [{
  45. id: 1,
  46. label: 'User 1',
  47. group: 'users'
  48. }, {
  49. id: 2,
  50. label: 'User 2',
  51. group: 'users'
  52. }, {
  53. id: 3,
  54. label: 'Usergroup 1',
  55. group: 'usergroups'
  56. }, {
  57. id: 4,
  58. label: 'Usergroup 2',
  59. group: 'usergroups'
  60. }, {
  61. id: 5,
  62. label: 'Organisation 1',
  63. shape: 'icon',
  64. icon: {
  65. face: 'FontAwesome',
  66. code: '\uf1ad',
  67. size: 50,
  68. color: '#f0a30a'
  69. }
  70. }];
  71. // create an array with edges
  72. var edges = [{
  73. from: 1,
  74. to: 3
  75. }, {
  76. from: 1,
  77. to: 4
  78. }, {
  79. from: 2,
  80. to: 4
  81. }, {
  82. from: 3,
  83. to: 5
  84. }, {
  85. from: 4,
  86. to: 5
  87. }];
  88. // create a network
  89. var containerFA = document.getElementById('mynetworkFA');
  90. var dataFA = {
  91. nodes: nodesFA,
  92. edges: edges
  93. };
  94. var networkFA = new vis.Network(containerFA, dataFA, optionsFA);
  95. /*
  96. * Example for Ionicons
  97. */
  98. var optionsIO = {
  99. groups: {
  100. usergroups: {
  101. shape: 'icon',
  102. icon: {
  103. face: 'Ionicons',
  104. code: '\uf47c',
  105. size: 50,
  106. color: '#57169a'
  107. }
  108. },
  109. users: {
  110. shape: 'icon',
  111. icon: {
  112. face: 'Ionicons',
  113. code: '\uf47e',
  114. size: 50,
  115. color: '#aa00ff'
  116. }
  117. }
  118. }
  119. };
  120. // create an array with nodes
  121. var nodesIO = [{
  122. id: 1,
  123. label: 'User 1',
  124. group: 'users'
  125. }, {
  126. id: 2,
  127. label: 'User 2',
  128. group: 'users'
  129. }, {
  130. id: 3,
  131. label: 'Usergroup 1',
  132. group: 'usergroups'
  133. }, {
  134. id: 4,
  135. label: 'Usergroup 2',
  136. group: 'usergroups'
  137. }, {
  138. id: 5,
  139. label: 'Organisation 1',
  140. shape: 'icon',
  141. icon: {
  142. face: 'Ionicons',
  143. code: '\uf276',
  144. size: 50,
  145. color: '#f0a30a'
  146. }
  147. }];
  148. // create a network
  149. var containerIO = document.getElementById('mynetworkIO');
  150. var dataIO = {
  151. nodes: nodesIO,
  152. edges: edges
  153. };
  154. var networkIO = new vis.Network(containerIO, dataIO, optionsIO);
  155. }
  156. </script>
  157. <script src="../googleAnalytics.js"></script>
  158. </head>
  159. <body onload="draw()">
  160. <h2>
  161. <i class="fa fa-flag"></i> Use FontAwesome-icons for node</h2>
  162. <div id="mynetworkFA"></div>
  163. <h2>
  164. <i class="ion ion-ionic"></i> Use Ionicons-icons for node</h2>
  165. <div id="mynetworkIO"></div>
  166. </body>
  167. </html>