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.

168 lines
4.2 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  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="https://code.jquery.com/jquery-2.1.3.min.js"></script>
  7. <script type="text/javascript" src="../../dist/vis.js"></script>
  8. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  9. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  10. <link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  11. </head>
  12. <body>
  13. <h2>
  14. <i class="fa fa-flag"></i> Use FontAwesome-icons for node</h2>
  15. <div id="mynetworkFA"></div>
  16. <h2>
  17. <i class="ion ion-ionic"></i> Use Ionicons-icons for node</h2>
  18. <div id="mynetworkIO"></div>
  19. <script type="text/javascript">
  20. $(function() {
  21. /*
  22. * Example for FontAwesome
  23. */
  24. var optionsFA = {
  25. height: '300px',
  26. groups: {
  27. usergroups: {
  28. shape: 'icon',
  29. iconFontFace: 'FontAwesome',
  30. icon: '\uf0c0',
  31. iconSize: 50,
  32. iconColor: '#57169a'
  33. },
  34. users: {
  35. shape: 'icon',
  36. iconFontFace: 'FontAwesome',
  37. icon: '\uf007',
  38. iconSize: 50,
  39. iconColor: '#aa00ff'
  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. iconFontFace: 'FontAwesome',
  65. icon: '\uf1ad',
  66. iconSize: 50,
  67. iconColor: '#f0a30a'
  68. }];
  69. // create an array with edges
  70. var edges = [{
  71. from: 1,
  72. to: 3
  73. }, {
  74. from: 1,
  75. to: 4
  76. }, {
  77. from: 2,
  78. to: 4
  79. }, {
  80. from: 3,
  81. to: 5
  82. }, {
  83. from: 4,
  84. to: 5
  85. }];
  86. // create a network
  87. var containerFA = document.getElementById('mynetworkFA');
  88. var dataFA = {
  89. nodes: nodesFA,
  90. edges: edges
  91. };
  92. var networkFA = new vis.Network(containerFA, dataFA, optionsFA);
  93. /*
  94. * Example for Ionicons
  95. */
  96. var optionsIO = {
  97. height: '300px',
  98. groups: {
  99. usergroups: {
  100. shape: 'icon',
  101. iconFontFace: 'Ionicons',
  102. icon: '\uf47c',
  103. iconSize: 50,
  104. iconColor: '#57169a'
  105. },
  106. users: {
  107. shape: 'icon',
  108. iconFontFace: 'Ionicons',
  109. icon: '\uf47e',
  110. iconSize: 50,
  111. iconColor: '#aa00ff'
  112. },
  113. },
  114. };
  115. // create an array with nodes
  116. var nodesIO = [{
  117. id: 1,
  118. label: 'User 1',
  119. group: 'users'
  120. }, {
  121. id: 2,
  122. label: 'User 2',
  123. group: 'users'
  124. }, {
  125. id: 3,
  126. label: 'Usergroup 1',
  127. group: 'usergroups'
  128. }, {
  129. id: 4,
  130. label: 'Usergroup 2',
  131. group: 'usergroups'
  132. }, {
  133. id: 5,
  134. label: 'Organisation 1',
  135. shape: 'icon',
  136. iconFontFace: 'Ionicons',
  137. icon: '\uf276',
  138. iconSize: 50,
  139. iconColor: '#f0a30a'
  140. }];
  141. // create a network
  142. var containerIO = document.getElementById('mynetworkIO');
  143. var dataIO = {
  144. nodes: nodesIO,
  145. edges: edges
  146. };
  147. var networkIO = new vis.Network(containerIO, dataIO, optionsIO);
  148. })
  149. </script>
  150. </body>
  151. </html>