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.

287 lines
14 KiB

9 years ago
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head><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>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <title>Network Examples</title>
  8. <link rel="icon" HREF="favicon.ico">
  9. <!-- Bootstrap -->
  10. <link href="./css/bootstrap.css" rel="stylesheet">
  11. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  12. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  13. <!--[if lt IE 9]>
  14. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  15. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  16. <![endif]-->
  17. <link href="./css/prettify.css" rel="stylesheet" type="text/css" />
  18. <script type="text/javascript" src="./js/prettify/prettify.js"></script>
  19. <script src="./dist/vis.js"></script>
  20. <link href="./dist/vis.css" rel="stylesheet" type="text/css" />
  21. <link href="./css/examples.css" rel="stylesheet" type="text/css" />
  22. <style>
  23. #networkContainer {
  24. margin:0px;
  25. padding:0px;
  26. position:relative;
  27. height: 3083px;
  28. width: 100%;
  29. z-index:0;
  30. }
  31. #contentContainer {
  32. margin:0px;
  33. padding:0px;
  34. position:relative;
  35. margin-top:-3083px;
  36. width: 100%;
  37. z-index:2;
  38. }
  39. </style>
  40. <script>
  41. var network;
  42. var connectedNodes = [];
  43. var largeNode = undefined;
  44. var NORMAL_SIZE = 60;
  45. var LARGE_SIZE = 80;
  46. function loadVis() {
  47. var linksContainer = document.getElementById('contentContainer');
  48. var links = linksContainer.getElementsByTagName('a');
  49. var nodesArray = [];
  50. var edgesArray = [];
  51. var idCounter = 0;
  52. var firstLink = undefined;
  53. for (var i = 0; i < links.length; i++) {
  54. var link = links[i];
  55. if (link.className === 'exampleLink') {
  56. var linkRect = link.getBoundingClientRect();
  57. var linkWidth = linkRect.right - linkRect.left;
  58. if (firstLink === undefined) {
  59. firstLink = link;
  60. }
  61. nodesArray.push({id:idCounter,
  62. x:link.offsetLeft + linkWidth,
  63. y:link.offsetTop,
  64. color:{
  65. background:'rgba(0,0,0,0.0)',
  66. border:'rgba(70,158,255,0)'
  67. },
  68. shape:'dot',
  69. size:2,
  70. fixed:true
  71. });
  72. nodesArray.push({id:idCounter + "image",
  73. // label:link.innerHTML,
  74. x:link.offsetLeft + 400 + 100 + (idCounter % 3) * 150,
  75. y:link.offsetTop,
  76. color:{
  77. border:'rgba(70,158,255,1)'
  78. },
  79. shadow:{
  80. size:2,
  81. x:0,
  82. y:0
  83. },
  84. shape:'image',
  85. image:'./images/exampleScreenshots/network/'+(idCounter+1)+'.png',
  86. size:NORMAL_SIZE
  87. });
  88. edgesArray.push({from: idCounter, to: idCounter+"image", arrows:'from'});
  89. idCounter += 1;
  90. }
  91. }
  92. var nodes = new vis.DataSet(nodesArray);
  93. var edges = new vis.DataSet(edgesArray);
  94. var networkContainer = document.getElementById('networkContainer');
  95. var data = {
  96. nodes: nodes,
  97. edges: edges
  98. };
  99. var options = {
  100. edges:{
  101. color:{inherit:'both'},
  102. smooth:{enabled:false,type:'continuous'}
  103. },
  104. physics: false,
  105. interaction:{
  106. zoomView:false,
  107. dragView: false
  108. }
  109. };
  110. network = new vis.Network(networkContainer, data, options);
  111. // get the offset
  112. var firstLinkPos = {x:firstLink.offsetLeft, y:firstLink.offsetTop};
  113. var firstLinkRect = firstLink.getBoundingClientRect();
  114. var firstLinkWidth = firstLinkRect.right - firstLinkRect.left;
  115. var firstLinkHeight = firstLinkRect.bottom - firstLinkRect.top;
  116. var rect = networkContainer.getBoundingClientRect();
  117. var width = rect.right - rect.left;
  118. var height = rect.bottom - rect.top;
  119. var ydiff = linksContainer.offsetTop - networkContainer.offsetTop;
  120. network.moveTo({
  121. scale: 1,
  122. position: network.getPositions([0])[0],
  123. offset: {
  124. x: -0.5 * width + firstLinkPos.x + firstLinkWidth,
  125. y: -0.5 * height + firstLinkPos.y + ydiff + 0.5 * firstLinkHeight
  126. },
  127. animation: false
  128. });
  129. linksContainer.onclick = function (event) {
  130. var nodeUnderCursor = network.getNodeAt({x:event.layerX, y:event.layerY+ydiff});
  131. if (connectedNodes.length > 0) {
  132. nodes.update([{id: connectedNodes[0], color: {border: 'rgba(70,158,255,0)'}}])
  133. connectedNodes = []
  134. }
  135. if (largeNode !== undefined) {
  136. nodes.update([{id: largeNode, size:NORMAL_SIZE}]);
  137. largeNode = undefined;
  138. }
  139. if (nodeUnderCursor !== undefined) {
  140. connectedNodes = network.getConnectedNodes(nodeUnderCursor);
  141. largeNode = nodeUnderCursor;
  142. nodes.update([{id:connectedNodes[0], color:{border:'rgba(70,158,255,1)'}}]);
  143. nodes.update([{id:largeNode, size:LARGE_SIZE}]);
  144. largeNode = nodeUnderCursor;
  145. network.selectNodes([nodeUnderCursor]);
  146. }
  147. else {
  148. network.unselectAll();
  149. }
  150. }
  151. }
  152. </script>
  153. </head>
  154. <body onload="loadVis();">
  155. <div class="navbar-wrapper">
  156. <div class="container">
  157. <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
  158. <div class="container">
  159. <div class="navbar-header">
  160. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
  161. <span class="sr-only">Toggle navigation</span>
  162. <span class="icon-bar"></span>
  163. <span class="icon-bar"></span>
  164. <span class="icon-bar"></span>
  165. </button>
  166. <a class="navbar-brand hidden-sm" href="./index.html">vis.js</a>
  167. </div>
  168. <div id="navbar" class="navbar-collapse collapse">
  169. <ul class="nav navbar-nav">
  170. <li class="active"><a href="./index.html#modules">Modules</a></li>
  171. <li><a href="./blog.html">Blog</a></li>
  172. <li><a href="./index.html#download_install">Download</a></li>
  173. <li><a href="./showcase/index.html">Showcase</a></li>
  174. <li><a href="./index.html#contribute">Contribute</a></li>
  175. <li><a href="./featureRequests.html">Feature requests</a></li>
  176. <li><a href="./index.html#licenses">License</a></li>
  177. </ul>
  178. </div>
  179. </div>
  180. </nav>
  181. </div>
  182. </div>
  183. <div class="contentWrapper">
  184. <div id="networkContainer"></div>
  185. <div id="contentContainer">
  186. <h1>Network Examples</h1>
  187. This page contains examples which show how to use Network. For the documentation, please click the button below: <br><br>
  188. <a class="btn btn-primary" href="./docs/network" role="button">View docs »</a>
  189. <h3>basic usage</h3>
  190. <a class='exampleLink' href="examples/network/basic_usage.html">basic usage</a><br />
  191. <h3>node styles</h3>
  192. <a class='exampleLink' href="examples/network/nodeStyles/colors.html">colors</a><br />
  193. <a class='exampleLink' href="examples/network/nodeStyles/groups.html">groups</a><br />
  194. <a class='exampleLink' href="examples/network/nodeStyles/customGroups.html">custom groups</a><br />
  195. <a class='exampleLink' href="examples/network/nodeStyles/HTML_in_Nodes.html">HTML in nodes</a><br />
  196. <a class='exampleLink' href="examples/network/nodeStyles/icons.html">icons (Fontawesome and Ionicons)</a><br />
  197. <a class='exampleLink' href="examples/network/nodeStyles/images.html">images</a><br />
  198. <a class='exampleLink' href="examples/network/nodeStyles/circular_images.html">circular images</a><br />
  199. <a class='exampleLink' href="examples/network/nodeStyles/shadows.html">node shadows</a><br />
  200. <a class='exampleLink' href="examples/network/nodeStyles/shapes.html">node shapes</a><br />
  201. <h3>edge styles</h3>
  202. <a class='exampleLink' href="examples/network/edgeStyles/arrows.html">arrows (also combined with dashes)</a><br />
  203. <a class='exampleLink' href="examples/network/edgeStyles/colors.html">different colors</a><br />
  204. <a class='exampleLink' href="examples/network/edgeStyles/dashes.html">dashes</a><br />
  205. <a class='exampleLink' href="examples/network/edgeStyles/smooth.html">smooth curves</a><br />
  206. <a class='exampleLink' href="examples/network/edgeStyles/smoothWorldCup.html">smooth curves in action</a><br />
  207. <h3>labels</h3>
  208. <a class='exampleLink' href="examples/network/labels/label_alignment.html">label alignment (for edges only)</a><br />
  209. <a class='exampleLink' href="examples/network/labels/label_background.html">label background</a><br />
  210. <a class='exampleLink' href="examples/network/labels/label_color_and_size.html">colors and sizes</a><br />
  211. <a class='exampleLink' href="examples/network/labels/label_stroke.html">label stroke</a><br />
  212. <a class='exampleLink' href="examples/network/labels/multiline_text.html">multiline text</a><br />
  213. <h3>layout</h3>
  214. <a class='exampleLink' href="examples/network/layout/hierarchical_layout.html">hierarchical layout</a><br />
  215. <a class='exampleLink' href="examples/network/layout/hierarchical_layout_methods.html">hierarchical layout - different methods</a><br />
  216. <a class='exampleLink' href="examples/network/layout/hierarchical_layout_userdefined.html">hierarchical layout - user defined</a><br />
  217. <a class='exampleLink' href="examples/network/layout/randomSeed.html">set the random seed so every network will be the same</a><br />
  218. <h3>events</h3>
  219. <a class='exampleLink' href="examples/network/events/interactionEvents.html">interaction events, click, rightclick, drag etc.</a><br />
  220. <a class='exampleLink' href="examples/network/events/physicsEvents.html">physics events, stabilization etc.</a><br />
  221. <a class='exampleLink' href="examples/network/events/renderEvents.html">rendering events, use to draw custom items on the canvas.</a><br />
  222. <h3>dynamic data</h3>
  223. <a class='exampleLink' href="examples/network/data/datasets.html">dataset for dynamic data</a><br />
  224. <a class='exampleLink' href="examples/network/data/dynamic_data.html">dynamic data, playground</a><br />
  225. <a class='exampleLink' href="examples/network/data/importing_from_gephi.html">importing data from gephi</a><br />
  226. <a class='exampleLink' href="examples/network/data/scaling_custom.html">scaling the nodes with the value.</a><br />
  227. <a class='exampleLink' href="examples/network/data/scaling_nodes_edges.html">scaling the nodes and edges with the value.</a><br />
  228. <a class='exampleLink' href="examples/network/data/scaling_nodes_edges_labels.html">scaling the nodes, edges and labels with the value.</a><br />
  229. <h3>physics</h3>
  230. <a class='exampleLink' href="examples/network/physics/physicsConfiguration.html">physics configuration</a><br />
  231. <h3>example applications</h3>
  232. <a class='exampleLink' href="examples/network/exampleApplications/les_miserables.html">les miserables cast</a><br />
  233. <a class='exampleLink' href="examples/network/exampleApplications/loadingBar.html">loading bar during stabilization</a><br />
  234. <a class='exampleLink' href="examples/network/exampleApplications/neighbourhood_highlight.html">neighbourhood heighlight</a><br />
  235. <a class='exampleLink' href="examples/network/exampleApplications/nodeLegend.html">using nodes as a legend</a><br />
  236. <a class='exampleLink' href="examples/network/exampleApplications/worldCupPerformance.html">performance test with the worldcup data</a><br />
  237. <h3>other</h3>
  238. <a class='exampleLink' href="examples/network/other/animationShowcase.html">animation showcase</a><br />
  239. <a class='exampleLink' href="examples/network/other/clustering.html">clustering possibilities</a><br />
  240. <a class='exampleLink' href="examples/network/other/clusteringByZoom.html">clustering by zoom</a><br />
  241. <a class='exampleLink' href="examples/network/other/configuration.html">dynamic configuration</a><br />
  242. <a class='exampleLink' href="examples/network/other/manipulation.html">manipulation interface and localization</a><br />
  243. <a class='exampleLink' href="examples/network/other/navigation.html">navigation buttons and keyboard shortcuts</a><br />
  244. <a class='exampleLink' href="examples/network/other/performance.html">performance test with scale free network, customize the amount of nodes</a><br />
  245. </div>
  246. <br />
  247. <br />
  248. <br />
  249. <br />
  250. </div>
  251. <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  252. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  253. <!-- Include all compiled plugins (below), or include individual files as needed -->
  254. <script src="js/bootstrap.min.js"></script>
  255. </body>
  256. </html>