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.

503 lines
20 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Les miserables</title>
  5. <style type="text/css">
  6. #mynetwork {
  7. width: 900px;
  8. height: 900px;
  9. border: 1px solid lightgray;
  10. }
  11. #loadingBar {
  12. position:absolute;
  13. top:0px;
  14. left:0px;
  15. width: 902px;
  16. height: 902px;
  17. background-color:rgba(200,200,200,0.8);
  18. -webkit-transition: all 0.5s ease;
  19. -moz-transition: all 0.5s ease;
  20. -ms-transition: all 0.5s ease;
  21. -o-transition: all 0.5s ease;
  22. transition: all 0.5s ease;
  23. opacity:1;
  24. }
  25. #wrapper {
  26. position:relative;
  27. width:900px;
  28. height:900px;
  29. }
  30. #text {
  31. position:absolute;
  32. top:8px;
  33. left:530px;
  34. width:30px;
  35. height:50px;
  36. margin:auto auto auto auto;
  37. font-size:22px;
  38. color: #000000;
  39. }
  40. div.outerBorder {
  41. position:relative;
  42. top:400px;
  43. width:600px;
  44. height:44px;
  45. margin:auto auto auto auto;
  46. background: rgb(252,252,252); /* Old browsers */
  47. background: -moz-linear-gradient(top, rgba(252,252,252,1) 0%, rgba(237,237,237,1) 100%); /* FF3.6+ */
  48. background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(252,252,252,1)), color-stop(100%,rgba(237,237,237,1))); /* Chrome,Safari4+ */
  49. background: -webkit-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* Chrome10+,Safari5.1+ */
  50. background: -o-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* Opera 11.10+ */
  51. background: -ms-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* IE10+ */
  52. background: linear-gradient(to bottom, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* W3C */
  53. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfcfc', endColorstr='#ededed',GradientType=0 ); /* IE6-9 */
  54. border-radius:22px;
  55. box-shadow: 0px 0px 10px rgba(0,0,0,0.2);
  56. }
  57. #border {
  58. position:absolute;
  59. top:10px;
  60. left:10px;
  61. width:500px;
  62. height:23px;
  63. margin:auto auto auto auto;
  64. box-shadow: 0px 0px 4px rgba(0,0,0,0.2);
  65. border-radius:10px;
  66. }
  67. #bar {
  68. position:absolute;
  69. top:0px;
  70. left:0px;
  71. width:20px;
  72. height:20px;
  73. margin:auto auto auto auto;
  74. border-radius:11px;
  75. border:2px solid rgba(30,30,30,0.05);
  76. background: rgb(0, 173, 246); /* Old browsers */
  77. box-shadow: 2px 0px 4px rgba(0,0,0,0.4);
  78. }
  79. </style>
  80. <script type="text/javascript" src="../../../../dist/vis.js"></script>
  81. <link href="../../../../dist/vis.css" rel="stylesheet" type="text/css"/>
  82. <script type="text/javascript">
  83. function draw() {
  84. // create some nodes
  85. var nodes = [
  86. {id: 0, "label": "Myriel", "group": 1},
  87. {id: 1, "label": "Napoleon", "group": 1},
  88. {id: 2, "label": "Mlle.Baptistine", "group": 1},
  89. {id: 3, "label": "Mme.Magloire", "group": 1},
  90. {id: 4, "label": "CountessdeLo", "group": 1},
  91. {id: 5, "label": "Geborand", "group": 1},
  92. {id: 6, "label": "Champtercier", "group": 1},
  93. {id: 7, "label": "Cravatte", "group": 1},
  94. {id: 8, "label": "Count", "group": 1},
  95. {id: 9, "label": "OldMan", "group": 1},
  96. {id: 10, "label": "Labarre", "group": 2},
  97. {id: 11, "label": "Valjean", "group": 2},
  98. {id: 12, "label": "Marguerite", "group": 3},
  99. {id: 13, "label": "Mme.deR", "group": 2},
  100. {id: 14, "label": "Isabeau", "group": 2},
  101. {id: 15, "label": "Gervais", "group": 2},
  102. {id: 16, "label": "Tholomyes", "group": 3},
  103. {id: 17, "label": "Listolier", "group": 3},
  104. {id: 18, "label": "Fameuil", "group": 3},
  105. {id: 19, "label": "Blacheville", "group": 3},
  106. {id: 20, "label": "Favourite", "group": 3},
  107. {id: 21, "label": "Dahlia", "group": 3},
  108. {id: 22, "label": "Zephine", "group": 3},
  109. {id: 23, "label": "Fantine", "group": 3},
  110. {id: 24, "label": "Mme.Thenardier", "group": 4},
  111. {id: 25, "label": "Thenardier", "group": 4},
  112. {id: 26, "label": "Cosette", "group": 5},
  113. {id: 27, "label": "Javert", "group": 4},
  114. {id: 28, "label": "Fauchelevent", "group": 0},
  115. {id: 29, "label": "Bamatabois", "group": 2},
  116. {id: 30, "label": "Perpetue", "group": 3},
  117. {id: 31, "label": "Simplice", "group": 2},
  118. {id: 32, "label": "Scaufflaire", "group": 2},
  119. {id: 33, "label": "Woman1", "group": 2},
  120. {id: 34, "label": "Judge", "group": 2},
  121. {id: 35, "label": "Champmathieu", "group": 2},
  122. {id: 36, "label": "Brevet", "group": 2},
  123. {id: 37, "label": "Chenildieu", "group": 2},
  124. {id: 38, "label": "Cochepaille", "group": 2},
  125. {id: 39, "label": "Pontmercy", "group": 4},
  126. {id: 40, "label": "Boulatruelle", "group": 6},
  127. {id: 41, "label": "Eponine", "group": 4},
  128. {id: 42, "label": "Anzelma", "group": 4},
  129. {id: 43, "label": "Woman2", "group": 5},
  130. {id: 44, "label": "MotherInnocent", "group": 0},
  131. {id: 45, "label": "Gribier", "group": 0},
  132. {id: 46, "label": "Jondrette", "group": 7},
  133. {id: 47, "label": "Mme.Burgon", "group": 7},
  134. {id: 48, "label": "Gavroche", "group": 8},
  135. {id: 49, "label": "Gillenormand", "group": 5},
  136. {id: 50, "label": "Magnon", "group": 5},
  137. {id: 51, "label": "Mlle.Gillenormand", "group": 5},
  138. {id: 52, "label": "Mme.Pontmercy", "group": 5},
  139. {id: 53, "label": "Mlle.Vaubois", "group": 5},
  140. {id: 54, "label": "Lt.Gillenormand", "group": 5},
  141. {id: 55, "label": "Marius", "group": 8},
  142. {id: 56, "label": "BaronessT", "group": 5},
  143. {id: 57, "label": "Mabeuf", "group": 8},
  144. {id: 58, "label": "Enjolras", "group": 8},
  145. {id: 59, "label": "Combeferre", "group": 8},
  146. {id: 60, "label": "Prouvaire", "group": 8},
  147. {id: 61, "label": "Feuilly", "group": 8},
  148. {id: 62, "label": "Courfeyrac", "group": 8},
  149. {id: 63, "label": "Bahorel", "group": 8},
  150. {id: 64, "label": "Bossuet", "group": 8},
  151. {id: 65, "label": "Joly", "group": 8},
  152. {id: 66, "label": "Grantaire", "group": 8},
  153. {id: 67, "label": "MotherPlutarch", "group": 9},
  154. {id: 68, "label": "Gueulemer", "group": 4},
  155. {id: 69, "label": "Babet", "group": 4},
  156. {id: 70, "label": "Claquesous", "group": 4},
  157. {id: 71, "label": "Montparnasse", "group": 4},
  158. {id: 72, "label": "Toussaint", "group": 5},
  159. {id: 73, "label": "Child1", "group": 10},
  160. {id: 74, "label": "Child2", "group": 10},
  161. {id: 75, "label": "Brujon", "group": 4},
  162. {id: 76, "label": "Mme.Hucheloup", "group": 8}
  163. ];
  164. // create some edges
  165. var edges = [
  166. {"from": 1, "to": 0},
  167. {"from": 2, "to": 0},
  168. {"from": 3, "to": 0},
  169. {"from": 3, "to": 2},
  170. {"from": 4, "to": 0},
  171. {"from": 5, "to": 0},
  172. {"from": 6, "to": 0},
  173. {"from": 7, "to": 0},
  174. {"from": 8, "to": 0},
  175. {"from": 9, "to": 0},
  176. {"from": 11, "to": 10},
  177. {"from": 11, "to": 3},
  178. {"from": 11, "to": 2},
  179. {"from": 11, "to": 0},
  180. {"from": 12, "to": 11},
  181. {"from": 13, "to": 11},
  182. {"from": 14, "to": 11},
  183. {"from": 15, "to": 11},
  184. {"from": 17, "to": 16},
  185. {"from": 18, "to": 16},
  186. {"from": 18, "to": 17},
  187. {"from": 19, "to": 16},
  188. {"from": 19, "to": 17},
  189. {"from": 19, "to": 18},
  190. {"from": 20, "to": 16},
  191. {"from": 20, "to": 17},
  192. {"from": 20, "to": 18},
  193. {"from": 20, "to": 19},
  194. {"from": 21, "to": 16},
  195. {"from": 21, "to": 17},
  196. {"from": 21, "to": 18},
  197. {"from": 21, "to": 19},
  198. {"from": 21, "to": 20},
  199. {"from": 22, "to": 16},
  200. {"from": 22, "to": 17},
  201. {"from": 22, "to": 18},
  202. {"from": 22, "to": 19},
  203. {"from": 22, "to": 20},
  204. {"from": 22, "to": 21},
  205. {"from": 23, "to": 16},
  206. {"from": 23, "to": 17},
  207. {"from": 23, "to": 18},
  208. {"from": 23, "to": 19},
  209. {"from": 23, "to": 20},
  210. {"from": 23, "to": 21},
  211. {"from": 23, "to": 22},
  212. {"from": 23, "to": 12},
  213. {"from": 23, "to": 11},
  214. {"from": 24, "to": 23},
  215. {"from": 24, "to": 11},
  216. {"from": 25, "to": 24},
  217. {"from": 25, "to": 23},
  218. {"from": 25, "to": 11},
  219. {"from": 26, "to": 24},
  220. {"from": 26, "to": 11},
  221. {"from": 26, "to": 16},
  222. {"from": 26, "to": 25},
  223. {"from": 27, "to": 11},
  224. {"from": 27, "to": 23},
  225. {"from": 27, "to": 25},
  226. {"from": 27, "to": 24},
  227. {"from": 27, "to": 26},
  228. {"from": 28, "to": 11},
  229. {"from": 28, "to": 27},
  230. {"from": 29, "to": 23},
  231. {"from": 29, "to": 27},
  232. {"from": 29, "to": 11},
  233. {"from": 30, "to": 23},
  234. {"from": 31, "to": 30},
  235. {"from": 31, "to": 11},
  236. {"from": 31, "to": 23},
  237. {"from": 31, "to": 27},
  238. {"from": 32, "to": 11},
  239. {"from": 33, "to": 11},
  240. {"from": 33, "to": 27},
  241. {"from": 34, "to": 11},
  242. {"from": 34, "to": 29},
  243. {"from": 35, "to": 11},
  244. {"from": 35, "to": 34},
  245. {"from": 35, "to": 29},
  246. {"from": 36, "to": 34},
  247. {"from": 36, "to": 35},
  248. {"from": 36, "to": 11},
  249. {"from": 36, "to": 29},
  250. {"from": 37, "to": 34},
  251. {"from": 37, "to": 35},
  252. {"from": 37, "to": 36},
  253. {"from": 37, "to": 11},
  254. {"from": 37, "to": 29},
  255. {"from": 38, "to": 34},
  256. {"from": 38, "to": 35},
  257. {"from": 38, "to": 36},
  258. {"from": 38, "to": 37},
  259. {"from": 38, "to": 11},
  260. {"from": 38, "to": 29},
  261. {"from": 39, "to": 25},
  262. {"from": 40, "to": 25},
  263. {"from": 41, "to": 24},
  264. {"from": 41, "to": 25},
  265. {"from": 42, "to": 41},
  266. {"from": 42, "to": 25},
  267. {"from": 42, "to": 24},
  268. {"from": 43, "to": 11},
  269. {"from": 43, "to": 26},
  270. {"from": 43, "to": 27},
  271. {"from": 44, "to": 28},
  272. {"from": 44, "to": 11},
  273. {"from": 45, "to": 28},
  274. {"from": 47, "to": 46},
  275. {"from": 48, "to": 47},
  276. {"from": 48, "to": 25},
  277. {"from": 48, "to": 27},
  278. {"from": 48, "to": 11},
  279. {"from": 49, "to": 26},
  280. {"from": 49, "to": 11},
  281. {"from": 50, "to": 49},
  282. {"from": 50, "to": 24},
  283. {"from": 51, "to": 49},
  284. {"from": 51, "to": 26},
  285. {"from": 51, "to": 11},
  286. {"from": 52, "to": 51},
  287. {"from": 52, "to": 39},
  288. {"from": 53, "to": 51},
  289. {"from": 54, "to": 51},
  290. {"from": 54, "to": 49},
  291. {"from": 54, "to": 26},
  292. {"from": 55, "to": 51},
  293. {"from": 55, "to": 49},
  294. {"from": 55, "to": 39},
  295. {"from": 55, "to": 54},
  296. {"from": 55, "to": 26},
  297. {"from": 55, "to": 11},
  298. {"from": 55, "to": 16},
  299. {"from": 55, "to": 25},
  300. {"from": 55, "to": 41},
  301. {"from": 55, "to": 48},
  302. {"from": 56, "to": 49},
  303. {"from": 56, "to": 55},
  304. {"from": 57, "to": 55},
  305. {"from": 57, "to": 41},
  306. {"from": 57, "to": 48},
  307. {"from": 58, "to": 55},
  308. {"from": 58, "to": 48},
  309. {"from": 58, "to": 27},
  310. {"from": 58, "to": 57},
  311. {"from": 58, "to": 11},
  312. {"from": 59, "to": 58},
  313. {"from": 59, "to": 55},
  314. {"from": 59, "to": 48},
  315. {"from": 59, "to": 57},
  316. {"from": 60, "to": 48},
  317. {"from": 60, "to": 58},
  318. {"from": 60, "to": 59},
  319. {"from": 61, "to": 48},
  320. {"from": 61, "to": 58},
  321. {"from": 61, "to": 60},
  322. {"from": 61, "to": 59},
  323. {"from": 61, "to": 57},
  324. {"from": 61, "to": 55},
  325. {"from": 62, "to": 55},
  326. {"from": 62, "to": 58},
  327. {"from": 62, "to": 59},
  328. {"from": 62, "to": 48},
  329. {"from": 62, "to": 57},
  330. {"from": 62, "to": 41},
  331. {"from": 62, "to": 61},
  332. {"from": 62, "to": 60},
  333. {"from": 63, "to": 59},
  334. {"from": 63, "to": 48},
  335. {"from": 63, "to": 62},
  336. {"from": 63, "to": 57},
  337. {"from": 63, "to": 58},
  338. {"from": 63, "to": 61},
  339. {"from": 63, "to": 60},
  340. {"from": 63, "to": 55},
  341. {"from": 64, "to": 55},
  342. {"from": 64, "to": 62},
  343. {"from": 64, "to": 48},
  344. {"from": 64, "to": 63},
  345. {"from": 64, "to": 58},
  346. {"from": 64, "to": 61},
  347. {"from": 64, "to": 60},
  348. {"from": 64, "to": 59},
  349. {"from": 64, "to": 57},
  350. {"from": 64, "to": 11},
  351. {"from": 65, "to": 63},
  352. {"from": 65, "to": 64},
  353. {"from": 65, "to": 48},
  354. {"from": 65, "to": 62},
  355. {"from": 65, "to": 58},
  356. {"from": 65, "to": 61},
  357. {"from": 65, "to": 60},
  358. {"from": 65, "to": 59},
  359. {"from": 65, "to": 57},
  360. {"from": 65, "to": 55},
  361. {"from": 66, "to": 64},
  362. {"from": 66, "to": 58},
  363. {"from": 66, "to": 59},
  364. {"from": 66, "to": 62},
  365. {"from": 66, "to": 65},
  366. {"from": 66, "to": 48},
  367. {"from": 66, "to": 63},
  368. {"from": 66, "to": 61},
  369. {"from": 66, "to": 60},
  370. {"from": 67, "to": 57},
  371. {"from": 68, "to": 25},
  372. {"from": 68, "to": 11},
  373. {"from": 68, "to": 24},
  374. {"from": 68, "to": 27},
  375. {"from": 68, "to": 48},
  376. {"from": 68, "to": 41},
  377. {"from": 69, "to": 25},
  378. {"from": 69, "to": 68},
  379. {"from": 69, "to": 11},
  380. {"from": 69, "to": 24},
  381. {"from": 69, "to": 27},
  382. {"from": 69, "to": 48},
  383. {"from": 69, "to": 41},
  384. {"from": 70, "to": 25},
  385. {"from": 70, "to": 69},
  386. {"from": 70, "to": 68},
  387. {"from": 70, "to": 11},
  388. {"from": 70, "to": 24},
  389. {"from": 70, "to": 27},
  390. {"from": 70, "to": 41},
  391. {"from": 70, "to": 58},
  392. {"from": 71, "to": 27},
  393. {"from": 71, "to": 69},
  394. {"from": 71, "to": 68},
  395. {"from": 71, "to": 70},
  396. {"from": 71, "to": 11},
  397. {"from": 71, "to": 48},
  398. {"from": 71, "to": 41},
  399. {"from": 71, "to": 25},
  400. {"from": 72, "to": 26},
  401. {"from": 72, "to": 27},
  402. {"from": 72, "to": 11},
  403. {"from": 73, "to": 48},
  404. {"from": 74, "to": 48},
  405. {"from": 74, "to": 73},
  406. {"from": 75, "to": 69},
  407. {"from": 75, "to": 68},
  408. {"from": 75, "to": 25},
  409. {"from": 75, "to": 48},
  410. {"from": 75, "to": 41},
  411. {"from": 75, "to": 70},
  412. {"from": 75, "to": 71},
  413. {"from": 76, "to": 64},
  414. {"from": 76, "to": 65},
  415. {"from": 76, "to": 66},
  416. {"from": 76, "to": 63},
  417. {"from": 76, "to": 62},
  418. {"from": 76, "to": 48},
  419. {"from": 76, "to": 58}
  420. ];
  421. // create a network
  422. var container = document.getElementById('mynetwork');
  423. var data = {
  424. nodes: nodes,
  425. edges: edges
  426. };
  427. var options = {
  428. nodes: {
  429. shape: 'dot',
  430. size: 16
  431. },
  432. layout:{
  433. randomSeed:34
  434. },
  435. physics: {
  436. forceAtlas2Based: {
  437. gravitationalConstant: -26,
  438. centralGravity: 0.005,
  439. springLength: 230,
  440. springConstant: 0.18
  441. },
  442. maxVelocity: 146,
  443. solver: 'forceAtlas2Based',
  444. timestep: 0.35,
  445. stabilization: {
  446. enabled:true,
  447. iterations:2000,
  448. updateInterval:25
  449. }
  450. }
  451. };
  452. var network = new vis.Network(container, data, options);
  453. network.on("stabilizationProgress", function(params) {
  454. var maxWidth = 496;
  455. var minWidth = 20;
  456. var widthFactor = params.iterations/params.total;
  457. var width = Math.max(minWidth,maxWidth * widthFactor);
  458. document.getElementById('bar').style.width = width + 'px';
  459. document.getElementById('text').innerHTML = Math.round(widthFactor*100) + '%';
  460. });
  461. network.once("stabilizationIterationsDone", function() {
  462. document.getElementById('text').innerHTML = '100%';
  463. document.getElementById('bar').style.width = '496px';
  464. document.getElementById('loadingBar').style.opacity = 0;
  465. // really clean the dom element
  466. setTimeout(function () {document.getElementById('loadingBar').style.display = 'none';}, 500);
  467. });
  468. }
  469. </script>
  470. <script src="../../../googleAnalytics.js"></script>
  471. </head>
  472. <body onload="draw()">
  473. <p>
  474. With the new stabilization events you can implement your own custom loading bar for all those long loading times!
  475. </p>
  476. <div id="wrapper">
  477. <div id="mynetwork"></div>
  478. <div id="loadingBar">
  479. <div class="outerBorder">
  480. <div id="text">0%</div>
  481. <div id="border">
  482. <div id="bar"></div>
  483. </div>
  484. </div>
  485. </div>
  486. </div>
  487. </body>
  488. </html>