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.

132 lines
3.8 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>Network | Custom style</title>
  5. <style type="text/css">
  6. body {
  7. font: 10pt arial;
  8. }
  9. #mynetwork {
  10. width: 600px;
  11. height: 600px;
  12. border: 1px solid lightgray;
  13. }
  14. </style>
  15. <script type="text/javascript" src="../../dist/vis.js"></script>
  16. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  17. <script type="text/javascript">
  18. var nodes = null;
  19. var edges = null;
  20. var options = null;
  21. var network = null;
  22. // Called when the Visualization API is loaded.
  23. function draw() {
  24. // create nodes
  25. nodes = [
  26. {id: 1, label: 'black node', group: 'black'},
  27. {id: 2, label: 'black node', group: 'black'},
  28. {id: 3, label: 'black node', group: 'black'},
  29. {id: 4, label: 'red node', group: 'black', color: 'red'},
  30. {id: 5, label: 'gray node', group: 'gray'},
  31. {id: 6, label: 'gray node', group: 'gray'},
  32. {id: 7, label: 'gray node', group: 'gray'},
  33. {id: 8, label: 'gray node', group: 'gray'},
  34. {id: 9, label: 'image node', group: 'white'},
  35. {id: 10, label: 'image node', group: 'white'},
  36. {id: 11, label: 'default node'},
  37. {id: 12, label: 'default node'}
  38. ];
  39. // create edges
  40. edges = [
  41. {from: 1, to: 2},
  42. {from: 1, to: 3},
  43. {from: 1, to: 4},
  44. {from: 5, to: 6},
  45. {from: 5, to: 7},
  46. {from: 5, to: 8},
  47. {from: 9, to: 10},
  48. {from: 9, to: 11},
  49. {from: 9, to: 12},
  50. {from: 1, to: 5},
  51. {from: 5, to: 9},
  52. {from: 9, to: 1}
  53. ];
  54. // specify options
  55. options = {
  56. stabilize: false,
  57. edges: {
  58. width: 2,
  59. style: 'arrow',
  60. color: 'gray'
  61. },
  62. nodes: {
  63. // default for all nodes
  64. fontFace: 'times',
  65. shape: 'circle',
  66. color: {
  67. border: 'orange',
  68. background: 'yellow',
  69. highlight: {
  70. border: 'darkorange',
  71. background: 'gold'
  72. }
  73. }
  74. },
  75. physics: {barnesHut:{springLength:200}}, // this is the correct way to set the length of the springs
  76. groups: {
  77. black: {
  78. // defaults for nodes in this group
  79. radius: 15,
  80. color: 'black',
  81. fontColor: 'white',
  82. fontSize: 18,
  83. fontFace: 'courier',
  84. shape: 'rect'
  85. },
  86. gray: {
  87. color: {
  88. border: 'black',
  89. background: 'gray',
  90. highlight: {
  91. border: 'black',
  92. background: 'lightgray'
  93. }
  94. },
  95. fontSize: 18,
  96. fontFace: 'arial',
  97. shape: 'circle'
  98. },
  99. white: {
  100. color: {
  101. border: 'black',
  102. background: 'white'
  103. },
  104. fontColor: 'red',
  105. shape: 'image',
  106. image: 'img/soft-scraps-icons/User-Coat-Blue-icon.png'
  107. }
  108. }
  109. };
  110. // create the network
  111. var container = document.getElementById('mynetwork');
  112. var data = {
  113. nodes: nodes,
  114. edges: edges
  115. };
  116. network = new vis.Network(container, data, options);
  117. }
  118. </script>
  119. <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script></head>
  120. <body onload="draw()">
  121. <div id="mynetwork"></div>
  122. </body>
  123. </html>