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.

119 lines
4.0 KiB

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title>Graph | Custom style</title>
  5. <style type="text/css">
  6. body {
  7. font: 10pt arial;
  8. }
  9. </style>
  10. <script type="text/javascript" src="../../vis.js"></script>
  11. <script type="text/javascript">
  12. var nodes = null;
  13. var edges = null;
  14. var options = null;
  15. var graph = null;
  16. // Called when the Visualization API is loaded.
  17. function draw() {
  18. // create nodes
  19. nodes = [
  20. {id: 1, label: 'black node', group: 'black'},
  21. {id: 2, label: 'black node', group: 'black'},
  22. {id: 3, label: 'black node', group: 'black'},
  23. {id: 4, label: 'red node', group: 'black', backgroundColor: 'red'},
  24. {id: 5, label: 'gray node', group: 'gray'},
  25. {id: 6, label: 'gray node', group: 'gray'},
  26. {id: 7, label: 'gray node', group: 'gray'},
  27. {id: 8, label: 'gray node', group: 'gray'},
  28. {id: 9, label: 'image node', group: 'white'},
  29. {id: 10, label: 'image node', group: 'white'},
  30. {id: 11, label: 'default node'},
  31. {id: 12, label: 'default node'}
  32. ];
  33. // create edges
  34. edges = [
  35. {from: 1, to: 2},
  36. {from: 1, to: 3},
  37. {from: 1, to: 4},
  38. {from: 5, to: 6},
  39. {from: 5, to: 7},
  40. {from: 5, to: 8},
  41. {from: 9, to: 10},
  42. {from: 9, to: 11},
  43. {from: 9, to: 12},
  44. {from: 1, to: 5},
  45. {from: 5, to: 9},
  46. {from: 9, to: 1}
  47. ];
  48. // specify options
  49. options = {
  50. 'width': '600px',
  51. 'height': '600px',
  52. 'stabilize': false,
  53. 'edges': {
  54. 'length': 120,
  55. 'width': 2,
  56. 'style': 'arrow',
  57. 'color': 'gray'
  58. },
  59. 'nodes': {
  60. // default for all nodes
  61. 'fontFace': 'times',
  62. 'shape': 'circle',
  63. 'borderColor': 'orange',
  64. 'backgroundColor': 'yellow',
  65. 'highlightColor': 'gold'
  66. },
  67. 'groups': {
  68. 'black': {
  69. // defaults for nodes in this group
  70. 'radius': 15,
  71. 'borderColor': 'black',
  72. 'backgroundColor': 'black',
  73. 'highlightColor': 'black',
  74. 'fontColor': 'white',
  75. 'fontSize': 18,
  76. 'fontFace': 'courier',
  77. 'shape': 'rect'
  78. },
  79. 'gray': {
  80. 'borderColor': 'black',
  81. 'backgroundColor': 'gray',
  82. 'highlightColor': 'gray',
  83. 'fontSize': 18,
  84. 'fontFace': 'arial',
  85. 'shape': 'circle'
  86. },
  87. 'white': {
  88. 'borderColor': 'black',
  89. 'backgroundColor': 'white',
  90. 'highlightColor': 'white',
  91. 'fontColor': 'red',
  92. 'shape': 'image',
  93. 'image': 'img/soft-scraps-icons/User-Coat-Blue-icon.png'
  94. }
  95. }
  96. };
  97. // create the graph
  98. var container = document.getElementById('mygraph');
  99. var data = {
  100. nodes: nodes,
  101. edges: edges
  102. };
  103. graph = new vis.Graph(container, data, options);
  104. }
  105. </script>
  106. </head>
  107. <body onload="draw()">
  108. <div id="mygraph"></div>
  109. </body>
  110. </html>