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.

166 lines
4.7 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. <script language="JavaScript">
  11. function draw() {
  12. /*
  13. * Example for FontAwesome
  14. */
  15. var optionsFA = {
  16. height: '300px',
  17. groups: {
  18. usergroups: {
  19. shape: 'icon',
  20. iconFontFace: 'FontAwesome',
  21. icon: '\uf0c0',
  22. iconSize: 50,
  23. iconColor: '#57169a'
  24. },
  25. users: {
  26. shape: 'icon',
  27. iconFontFace: 'FontAwesome',
  28. icon: '\uf007',
  29. iconSize: 50,
  30. iconColor: '#aa00ff'
  31. }
  32. }
  33. };
  34. // create an array with nodes
  35. var nodesFA = [{
  36. id: 1,
  37. label: 'User 1',
  38. group: 'users'
  39. }, {
  40. id: 2,
  41. label: 'User 2',
  42. group: 'users'
  43. }, {
  44. id: 3,
  45. label: 'Usergroup 1',
  46. group: 'usergroups'
  47. }, {
  48. id: 4,
  49. label: 'Usergroup 2',
  50. group: 'usergroups'
  51. }, {
  52. id: 5,
  53. label: 'Organisation 1',
  54. shape: 'icon',
  55. iconFontFace: 'FontAwesome',
  56. icon: '\uf1ad',
  57. iconSize: 50,
  58. iconColor: '#f0a30a'
  59. }];
  60. // create an array with edges
  61. var edges = [{
  62. from: 1,
  63. to: 3
  64. }, {
  65. from: 1,
  66. to: 4
  67. }, {
  68. from: 2,
  69. to: 4
  70. }, {
  71. from: 3,
  72. to: 5
  73. }, {
  74. from: 4,
  75. to: 5
  76. }];
  77. // create a network
  78. var containerFA = document.getElementById('mynetworkFA');
  79. var dataFA = {
  80. nodes: nodesFA,
  81. edges: edges
  82. };
  83. var networkFA = new vis.Network(containerFA, dataFA, optionsFA);
  84. /*
  85. * Example for Ionicons
  86. */
  87. var optionsIO = {
  88. height: '300px',
  89. groups: {
  90. usergroups: {
  91. shape: 'icon',
  92. iconFontFace: 'Ionicons',
  93. icon: '\uf47c',
  94. iconSize: 50,
  95. iconColor: '#57169a'
  96. },
  97. users: {
  98. shape: 'icon',
  99. iconFontFace: 'Ionicons',
  100. icon: '\uf47e',
  101. iconSize: 50,
  102. iconColor: '#aa00ff'
  103. }
  104. }
  105. };
  106. // create an array with nodes
  107. var nodesIO = [{
  108. id: 1,
  109. label: 'User 1',
  110. group: 'users'
  111. }, {
  112. id: 2,
  113. label: 'User 2',
  114. group: 'users'
  115. }, {
  116. id: 3,
  117. label: 'Usergroup 1',
  118. group: 'usergroups'
  119. }, {
  120. id: 4,
  121. label: 'Usergroup 2',
  122. group: 'usergroups'
  123. }, {
  124. id: 5,
  125. label: 'Organisation 1',
  126. shape: 'icon',
  127. iconFontFace: 'Ionicons',
  128. icon: '\uf276',
  129. iconSize: 50,
  130. iconColor: '#f0a30a'
  131. }];
  132. // create a network
  133. var containerIO = document.getElementById('mynetworkIO');
  134. var dataIO = {
  135. nodes: nodesIO,
  136. edges: edges
  137. };
  138. var networkIO = new vis.Network(containerIO, dataIO, optionsIO);
  139. }
  140. </script>
  141. </head>
  142. <body onload="draw()">
  143. <h2>
  144. <i class="fa fa-flag"></i> Use FontAwesome-icons for node</h2>
  145. <div id="mynetworkFA"></div>
  146. <h2>
  147. <i class="ion ion-ionic"></i> Use Ionicons-icons for node</h2>
  148. <div id="mynetworkIO"></div>
  149. </body>
  150. </html>