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.

112 lines
3.2 KiB

  1. <!doctype html>
  2. <html lang="en">
  3. <header>
  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. </header>
  12. <body>
  13. <h2><i class="fa fa-flag"></i> Use FontAwesome-icons for node</h1>
  14. <div id="mynetworkFA"></div>
  15. <h2><i class="ion ion-ionic"></i> Use Ionicons-icons for node</h1>
  16. <div id="mynetworkIO"></div>
  17. <script type="text/javascript">
  18. $(function(){
  19. var optionsFA = {
  20. height: '300px',
  21. groups: {
  22. usergroups: {
  23. shape: 'icon',
  24. iconFontFace: 'FontAwesome',
  25. icon: '\uf0c0',
  26. iconSize: 50,
  27. iconColor: '#57169a'
  28. },
  29. users: {
  30. shape: 'icon',
  31. iconFontFace: 'FontAwesome',
  32. icon: '\uf007',
  33. iconSize: 50,
  34. iconColor: '#aa00ff'
  35. },
  36. },
  37. };
  38. // create an array with nodes
  39. var nodesFA = [
  40. {id: 1, label: 'User 1', group: 'users' },
  41. {id: 2, label: 'User 2', group: 'users' },
  42. {id: 3, label: 'Usergroup 1', group: 'usergroups' },
  43. {id: 4, label: 'Usergroup 2', group: 'usergroups' },
  44. {id: 5, label: 'Organisation 1', shape: 'icon', iconFontFace: 'FontAwesome', icon: '\uf1ad', iconSize: 50, iconColor: '#f0a30a' }
  45. ];
  46. // create an array with edges
  47. var edges = [
  48. {from: 1, to: 3 },
  49. {from: 1, to: 4 },
  50. {from: 2, to: 4 },
  51. {from: 3, to: 5 },
  52. {from: 4, to: 5 }
  53. ];
  54. // create a network
  55. var containerFA = document.getElementById('mynetworkFA');
  56. var dataFA = {
  57. nodes: nodesFA,
  58. edges: edges
  59. };
  60. var networkFA = new vis.Network(containerFA, dataFA, optionsFA);
  61. var optionsIO = {
  62. height: '300px',
  63. groups: {
  64. usergroups: {
  65. shape: 'icon',
  66. iconFontFace: 'Ionicons',
  67. icon: '\uf47c',
  68. iconSize: 50,
  69. iconColor: '#57169a'
  70. },
  71. users: {
  72. shape: 'icon',
  73. iconFontFace: 'Ionicons',
  74. icon: '\uf47e',
  75. iconSize: 50,
  76. iconColor: '#aa00ff'
  77. },
  78. },
  79. };
  80. // create an array with nodes
  81. var nodesIO = [
  82. {id: 1, label: 'User 1', group: 'users' },
  83. {id: 2, label: 'User 2', group: 'users' },
  84. {id: 3, label: 'Usergroup 1', group: 'usergroups' },
  85. {id: 4, label: 'Usergroup 2', group: 'usergroups' },
  86. {id: 5, label: 'Organisation 1', shape: 'icon', iconFontFace: 'Ionicons', icon: '\uf276', iconSize: 50, iconColor: '#f0a30a' }
  87. ];
  88. // create a network
  89. var containerIO = document.getElementById('mynetworkIO');
  90. var dataIO = {
  91. nodes: nodesIO,
  92. edges: edges
  93. };
  94. var networkIO = new vis.Network(containerIO, dataIO, optionsIO);
  95. })
  96. </script>
  97. </body>
  98. </html>