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.

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