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.

185 lines
6.2 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JS Bin</title>
  6. <script type="text/javascript" src="../dist/vis.js"></script> <!-- network handling framework -->
  7. <link href="../dist/vis.css" rel="stylesheet" type="text/css"/>
  8. <style type="text/css">
  9. #network{
  10. width: 1200px;
  11. height: 800px;
  12. border: 1px solid lightgray;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <h1>Network Test</h1>
  18. <div id="network"></div>
  19. <script type="text/javascript">
  20. // create a network
  21. var container = document.getElementById('network');
  22. var data = {
  23. nodes: [{
  24. "id": "59acc308-fc78-11e3-a451-005056967662_1",
  25. "level": 1,
  26. "shape": "box",
  27. "label": "737464 (HALB)\nLenks\u00e4ule\n0 | M1182 - TK-PF\n0 | M2676 - TK-PF",
  28. }, {
  29. "id": "bc5ada61-e297-11e3-a03f-005056967662_2",
  30. "level": 2,
  31. "shape": "box",
  32. "label": "578647 C (HALB)\nF\u00fchrungskasten komplett\n0000 | M2731 - TK-PF",
  33. }, {
  34. "id": "6f8a780a-e28e-11e3-a03f-005056967662_2",
  35. "level": 2,
  36. "shape": "box",
  37. "label": "615430 C (HALB)\nF\u00fchrungskasten komplett\n0000 | M2781 - TK-PF\n0000 | M2788 - TK-PF",
  38. }, {
  39. "id": "49bb72b1-e2b2-11e3-a03f-005056967662_2",
  40. "level": 2,
  41. "shape": "box",
  42. "label": "678478 D (HALB)\nF\u00fchrungskasten montiert\n0 | M1085 - TK-PFC",
  43. }, {
  44. "id": "e7bf7c7e-e28e-11e3-a03f-005056967662_2",
  45. "level": 2,
  46. "shape": "box",
  47. "label": "727672 B (HALB)\nF\u00fchrungskasten komplett\n0 | M9999 - TK-PTH\n0000 | M1155 - TK-PTH",
  48. }, {
  49. "id": "623e8501-e2e2-11e3-a03f-005056967662_2",
  50. "level": 2,
  51. "shape": "box",
  52. "label": "760550 A (HALB)\nF\u00fchrungskasten komplett\n0000 | M1556 - TK-PHS",
  53. }, {
  54. "id": "e7c6dcdf-e28e-11e3-a03f-005056967662_2",
  55. "level": 2,
  56. "shape": "box",
  57. "label": "793641 A (HALB)\nF\u00fchrungskasten komplett\n0000 | M1155 - TK-PTH",
  58. }, {
  59. "id": "623edd04-e2e2-11e3-a03f-005056967662_2",
  60. "level": 2,
  61. "shape": "box",
  62. "label": "802797 A (HALB)\nF\u00fchrungskasten komplett\n0 | M1556 - TK-PHS",
  63. }, {
  64. "id": "a986a9ab-fc82-11e3-a451-005056967662_2",
  65. "level": 2,
  66. "shape": "box",
  67. "label": "821943 (HALB)\nF\u00fchrungskasten komplett\n0 | M2781 - TK-PF",
  68. }, {
  69. "id": "c22dda1e-fc84-11e3-a451-005056967662_2",
  70. "level": 2,
  71. "shape": "box",
  72. "label": "821944 (HALB)\nF\u00fchrungskasten komplett\n0 | M2781 - TK-PF",
  73. }, {
  74. "id": "a05fcb83-29c6-11e4-9203-005056967662_2",
  75. "level": 2,
  76. "shape": "box",
  77. "label": "828431 (HALB)\nF\u00fchrungskasten komplett",
  78. }, {
  79. "id": "eb9b67b7-6e3f-11e4-9203-005056967662_2",
  80. "level": 2,
  81. "shape": "box",
  82. "label": "829382 A (HALB)\nF\u00fchrungskasten komplett\n0 | M1556 - TK-PHS",
  83. }, {
  84. "id": "084ec1e3-e447-11e3-a03f-005056967662_3",
  85. "level": 3,
  86. "shape": "box",
  87. "color": "#00ff00",
  88. "label": "310759 C (ROH)\nSchr\u00e4gkugellager",
  89. }],
  90. edges: [{
  91. "from": "59acc308-fc78-11e3-a451-005056967662_1",
  92. "to": "a986a9ab-fc82-11e3-a451-005056967662_2"
  93. }, {
  94. "from": "bc5ada61-e297-11e3-a03f-005056967662_2",
  95. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  96. }, {
  97. "from": "6f8a780a-e28e-11e3-a03f-005056967662_2",
  98. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  99. }, {
  100. "from": "49bb72b1-e2b2-11e3-a03f-005056967662_2",
  101. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  102. }, {
  103. "from": "e7bf7c7e-e28e-11e3-a03f-005056967662_2",
  104. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  105. }, {
  106. "from": "623e8501-e2e2-11e3-a03f-005056967662_2",
  107. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  108. }, {
  109. "from": "e7c6dcdf-e28e-11e3-a03f-005056967662_2",
  110. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  111. }, {
  112. "from": "623edd04-e2e2-11e3-a03f-005056967662_2",
  113. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  114. }, {
  115. "from": "a986a9ab-fc82-11e3-a451-005056967662_2",
  116. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  117. }, {
  118. "from": "c22dda1e-fc84-11e3-a451-005056967662_2",
  119. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  120. }, {
  121. "from": "a05fcb83-29c6-11e4-9203-005056967662_2",
  122. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  123. }, {
  124. "from": "eb9b67b7-6e3f-11e4-9203-005056967662_2",
  125. "to": "084ec1e3-e447-11e3-a03f-005056967662_3"
  126. }]
  127. };
  128. var ids = {};
  129. for ( var i = 0; i < data.nodes.length; i++) {
  130. ids[data.nodes[i].id] = i;
  131. data.nodes[i].id = i
  132. data.nodes[i].label = i
  133. }
  134. for ( var i = 0; i < data.edges.length; i++) {
  135. data.edges[i].from = ids[data.edges[i].from]
  136. data.edges[i].to = ids[data.edges[i].to]
  137. }
  138. var options = {
  139. layout: {
  140. hierarchical: {
  141. //enabled: true,
  142. nodeSpacing: 100,
  143. //blockShifting: false,
  144. //edgeMinimization: false,
  145. direction: 'UD',
  146. sortMethod: 'directed'
  147. },
  148. },
  149. interaction: {
  150. dragNodes: true,
  151. hover: true
  152. },
  153. physics: {
  154. enabled: false
  155. }
  156. };
  157. var network = new vis.Network(container, data, options);
  158. network.on('click', function(params) {
  159. if (params.nodes !== undefined) {
  160. var firstNode = params.nodes[0];
  161. if (firstNode !== undefined) {
  162. var splitted = firstNode.split('_');
  163. Lisp.request.get('/dataStore/article/detail/id/' + splitted[0]);
  164. }
  165. }
  166. });
  167. </script>
  168. </body>
  169. </html>