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.

231 lines
5.0 KiB

Add arrow types for EndPoints.js (#3839) * Add arrowhead support As described in TODO, dotparser.js does not support 'arrowhead' attribubte of edge. This update is for adding 'dot' and 'tee'(bar) styles. * Add example for arrow styles * Add box arrowhead To support box arrowhead of graphviz, add Box endpoint class in EndPoints.js and box attribute in dotparser.js. * Add diamond arrowhead To support diamond arrowhead of graphviz, add Diamond endpoint class in EndPoints.js and diamond attribute in dotparser.js. * Add crow arrowhead To support crow arrowhead of graphviz, add Crow endpoint class in EndPoints.js and crow attribute in dotparser.js. * Add normal arrowhead To support normal arrowhead of graphviz, add Triangle endpoint class in EndPoints.js and normal attribute in dotparser.js. * Add curve arrowhead To support curve arrowhead of graphviz, add Curve endpoint class in EndPoints.js and curve attribute in dotparser.js. * Add inverted curve arrowhead To support inverted curve arrowhead of graphviz, add InvertedCurve endpoint class in EndPoints.js and icurve attribute in dotparser.js. * Add vee arrowhead To support vee arrowhead of graphviz, add Vee endpoint class in EndPoints.js and vee attribute in dotparser.js. * Add arrowhead examples * Fix bug for accessing null attribute In createEdge(), accessing 'attr' causes an error if the edge has no attribute and the value is null. This update fixes bug for accessing null 'attr'. * Update description for arrows.to.type option Add followingn options for 'arrows.to.type'. * box * crow * curve * diamond * inv_curve * triangle * inv_triangle * vee * Update edgeStyle example for arrow types Add arrow types for the example. 'box', 'crow', 'curve', 'inv_curve', 'diamond', 'triangle', 'inv_triangle', 'vee'
6 years ago
Add arrow types for EndPoints.js (#3839) * Add arrowhead support As described in TODO, dotparser.js does not support 'arrowhead' attribubte of edge. This update is for adding 'dot' and 'tee'(bar) styles. * Add example for arrow styles * Add box arrowhead To support box arrowhead of graphviz, add Box endpoint class in EndPoints.js and box attribute in dotparser.js. * Add diamond arrowhead To support diamond arrowhead of graphviz, add Diamond endpoint class in EndPoints.js and diamond attribute in dotparser.js. * Add crow arrowhead To support crow arrowhead of graphviz, add Crow endpoint class in EndPoints.js and crow attribute in dotparser.js. * Add normal arrowhead To support normal arrowhead of graphviz, add Triangle endpoint class in EndPoints.js and normal attribute in dotparser.js. * Add curve arrowhead To support curve arrowhead of graphviz, add Curve endpoint class in EndPoints.js and curve attribute in dotparser.js. * Add inverted curve arrowhead To support inverted curve arrowhead of graphviz, add InvertedCurve endpoint class in EndPoints.js and icurve attribute in dotparser.js. * Add vee arrowhead To support vee arrowhead of graphviz, add Vee endpoint class in EndPoints.js and vee attribute in dotparser.js. * Add arrowhead examples * Fix bug for accessing null attribute In createEdge(), accessing 'attr' causes an error if the edge has no attribute and the value is null. This update fixes bug for accessing null 'attr'. * Update description for arrows.to.type option Add followingn options for 'arrows.to.type'. * box * crow * curve * diamond * inv_curve * triangle * inv_triangle * vee * Update edgeStyle example for arrow types Add arrow types for the example. 'box', 'crow', 'curve', 'inv_curve', 'diamond', 'triangle', 'inv_triangle', 'vee'
6 years ago
Add arrow types for EndPoints.js (#3839) * Add arrowhead support As described in TODO, dotparser.js does not support 'arrowhead' attribubte of edge. This update is for adding 'dot' and 'tee'(bar) styles. * Add example for arrow styles * Add box arrowhead To support box arrowhead of graphviz, add Box endpoint class in EndPoints.js and box attribute in dotparser.js. * Add diamond arrowhead To support diamond arrowhead of graphviz, add Diamond endpoint class in EndPoints.js and diamond attribute in dotparser.js. * Add crow arrowhead To support crow arrowhead of graphviz, add Crow endpoint class in EndPoints.js and crow attribute in dotparser.js. * Add normal arrowhead To support normal arrowhead of graphviz, add Triangle endpoint class in EndPoints.js and normal attribute in dotparser.js. * Add curve arrowhead To support curve arrowhead of graphviz, add Curve endpoint class in EndPoints.js and curve attribute in dotparser.js. * Add inverted curve arrowhead To support inverted curve arrowhead of graphviz, add InvertedCurve endpoint class in EndPoints.js and icurve attribute in dotparser.js. * Add vee arrowhead To support vee arrowhead of graphviz, add Vee endpoint class in EndPoints.js and vee attribute in dotparser.js. * Add arrowhead examples * Fix bug for accessing null attribute In createEdge(), accessing 'attr' causes an error if the edge has no attribute and the value is null. This update fixes bug for accessing null 'attr'. * Update description for arrows.to.type option Add followingn options for 'arrows.to.type'. * box * crow * curve * diamond * inv_curve * triangle * inv_triangle * vee * Update edgeStyle example for arrow types Add arrow types for the example. 'box', 'crow', 'curve', 'inv_curve', 'diamond', 'triangle', 'inv_triangle', 'vee'
6 years ago
Add arrow types for EndPoints.js (#3839) * Add arrowhead support As described in TODO, dotparser.js does not support 'arrowhead' attribubte of edge. This update is for adding 'dot' and 'tee'(bar) styles. * Add example for arrow styles * Add box arrowhead To support box arrowhead of graphviz, add Box endpoint class in EndPoints.js and box attribute in dotparser.js. * Add diamond arrowhead To support diamond arrowhead of graphviz, add Diamond endpoint class in EndPoints.js and diamond attribute in dotparser.js. * Add crow arrowhead To support crow arrowhead of graphviz, add Crow endpoint class in EndPoints.js and crow attribute in dotparser.js. * Add normal arrowhead To support normal arrowhead of graphviz, add Triangle endpoint class in EndPoints.js and normal attribute in dotparser.js. * Add curve arrowhead To support curve arrowhead of graphviz, add Curve endpoint class in EndPoints.js and curve attribute in dotparser.js. * Add inverted curve arrowhead To support inverted curve arrowhead of graphviz, add InvertedCurve endpoint class in EndPoints.js and icurve attribute in dotparser.js. * Add vee arrowhead To support vee arrowhead of graphviz, add Vee endpoint class in EndPoints.js and vee attribute in dotparser.js. * Add arrowhead examples * Fix bug for accessing null attribute In createEdge(), accessing 'attr' causes an error if the edge has no attribute and the value is null. This update fixes bug for accessing null 'attr'. * Update description for arrows.to.type option Add followingn options for 'arrows.to.type'. * box * crow * curve * diamond * inv_curve * triangle * inv_triangle * vee * Update edgeStyle example for arrow types Add arrow types for the example. 'box', 'crow', 'curve', 'inv_curve', 'diamond', 'triangle', 'inv_triangle', 'vee'
6 years ago
Add arrow types for EndPoints.js (#3839) * Add arrowhead support As described in TODO, dotparser.js does not support 'arrowhead' attribubte of edge. This update is for adding 'dot' and 'tee'(bar) styles. * Add example for arrow styles * Add box arrowhead To support box arrowhead of graphviz, add Box endpoint class in EndPoints.js and box attribute in dotparser.js. * Add diamond arrowhead To support diamond arrowhead of graphviz, add Diamond endpoint class in EndPoints.js and diamond attribute in dotparser.js. * Add crow arrowhead To support crow arrowhead of graphviz, add Crow endpoint class in EndPoints.js and crow attribute in dotparser.js. * Add normal arrowhead To support normal arrowhead of graphviz, add Triangle endpoint class in EndPoints.js and normal attribute in dotparser.js. * Add curve arrowhead To support curve arrowhead of graphviz, add Curve endpoint class in EndPoints.js and curve attribute in dotparser.js. * Add inverted curve arrowhead To support inverted curve arrowhead of graphviz, add InvertedCurve endpoint class in EndPoints.js and icurve attribute in dotparser.js. * Add vee arrowhead To support vee arrowhead of graphviz, add Vee endpoint class in EndPoints.js and vee attribute in dotparser.js. * Add arrowhead examples * Fix bug for accessing null attribute In createEdge(), accessing 'attr' causes an error if the edge has no attribute and the value is null. This update fixes bug for accessing null 'attr'. * Update description for arrows.to.type option Add followingn options for 'arrows.to.type'. * box * crow * curve * diamond * inv_curve * triangle * inv_triangle * vee * Update edgeStyle example for arrow types Add arrow types for the example. 'box', 'crow', 'curve', 'inv_curve', 'diamond', 'triangle', 'inv_triangle', 'vee'
6 years ago
Add arrow types for EndPoints.js (#3839) * Add arrowhead support As described in TODO, dotparser.js does not support 'arrowhead' attribubte of edge. This update is for adding 'dot' and 'tee'(bar) styles. * Add example for arrow styles * Add box arrowhead To support box arrowhead of graphviz, add Box endpoint class in EndPoints.js and box attribute in dotparser.js. * Add diamond arrowhead To support diamond arrowhead of graphviz, add Diamond endpoint class in EndPoints.js and diamond attribute in dotparser.js. * Add crow arrowhead To support crow arrowhead of graphviz, add Crow endpoint class in EndPoints.js and crow attribute in dotparser.js. * Add normal arrowhead To support normal arrowhead of graphviz, add Triangle endpoint class in EndPoints.js and normal attribute in dotparser.js. * Add curve arrowhead To support curve arrowhead of graphviz, add Curve endpoint class in EndPoints.js and curve attribute in dotparser.js. * Add inverted curve arrowhead To support inverted curve arrowhead of graphviz, add InvertedCurve endpoint class in EndPoints.js and icurve attribute in dotparser.js. * Add vee arrowhead To support vee arrowhead of graphviz, add Vee endpoint class in EndPoints.js and vee attribute in dotparser.js. * Add arrowhead examples * Fix bug for accessing null attribute In createEdge(), accessing 'attr' causes an error if the edge has no attribute and the value is null. This update fixes bug for accessing null 'attr'. * Update description for arrows.to.type option Add followingn options for 'arrows.to.type'. * box * crow * curve * diamond * inv_curve * triangle * inv_triangle * vee * Update edgeStyle example for arrow types Add arrow types for the example. 'box', 'crow', 'curve', 'inv_curve', 'diamond', 'triangle', 'inv_triangle', 'vee'
6 years ago
Add arrow types for EndPoints.js (#3839) * Add arrowhead support As described in TODO, dotparser.js does not support 'arrowhead' attribubte of edge. This update is for adding 'dot' and 'tee'(bar) styles. * Add example for arrow styles * Add box arrowhead To support box arrowhead of graphviz, add Box endpoint class in EndPoints.js and box attribute in dotparser.js. * Add diamond arrowhead To support diamond arrowhead of graphviz, add Diamond endpoint class in EndPoints.js and diamond attribute in dotparser.js. * Add crow arrowhead To support crow arrowhead of graphviz, add Crow endpoint class in EndPoints.js and crow attribute in dotparser.js. * Add normal arrowhead To support normal arrowhead of graphviz, add Triangle endpoint class in EndPoints.js and normal attribute in dotparser.js. * Add curve arrowhead To support curve arrowhead of graphviz, add Curve endpoint class in EndPoints.js and curve attribute in dotparser.js. * Add inverted curve arrowhead To support inverted curve arrowhead of graphviz, add InvertedCurve endpoint class in EndPoints.js and icurve attribute in dotparser.js. * Add vee arrowhead To support vee arrowhead of graphviz, add Vee endpoint class in EndPoints.js and vee attribute in dotparser.js. * Add arrowhead examples * Fix bug for accessing null attribute In createEdge(), accessing 'attr' causes an error if the edge has no attribute and the value is null. This update fixes bug for accessing null 'attr'. * Update description for arrows.to.type option Add followingn options for 'arrows.to.type'. * box * crow * curve * diamond * inv_curve * triangle * inv_triangle * vee * Update edgeStyle example for arrow types Add arrow types for the example. 'box', 'crow', 'curve', 'inv_curve', 'diamond', 'triangle', 'inv_triangle', 'vee'
6 years ago
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | DOT edge styles</title>
  5. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
  6. <script src="../../../../dist/vis.js"></script>
  7. <link href="../../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" />
  8. <style type="text/css">
  9. body, html {
  10. font: 10pt sans;
  11. line-height: 1.5em;;
  12. width: 100%;
  13. height: 100%;
  14. padding: 0;
  15. margin: 0;
  16. color: #4d4d4d;
  17. box-sizing: border-box;
  18. overflow: hidden;
  19. }
  20. #header {
  21. margin: 0;
  22. padding: 10px;
  23. box-sizing: border-box;
  24. }
  25. #contents {
  26. height: 100%;
  27. margin: 0;
  28. padding: 0;
  29. box-sizing: border-box;
  30. position: relative;
  31. }
  32. #left, #right {
  33. position: absolute;
  34. margin: 0;
  35. padding: 10px;
  36. box-sizing: border-box;
  37. display: inline-block;
  38. }
  39. #left {
  40. width: 40%;
  41. height: 80%;
  42. top: 0;
  43. left: 0;
  44. }
  45. #right {
  46. width: 60%;
  47. height: 100%;
  48. top: 0;
  49. right: 0;
  50. }
  51. #error {
  52. color: red;
  53. }
  54. #data {
  55. width: 100%;
  56. height: 100%;
  57. border: 1px solid #d3d3d3;
  58. box-sizing: border-box;
  59. resize: none;
  60. }
  61. #draw, #reset {
  62. padding: 5px 15px;
  63. }
  64. #mynetwork {
  65. width: 100%;
  66. height: 100%;
  67. border: 1px solid #d3d3d3;
  68. box-sizing: border-box;
  69. }
  70. a:hover {
  71. color: red;
  72. }
  73. </style>
  74. </head>
  75. <body>
  76. <div id="header">
  77. <h1>DOT edge styles</h1>
  78. <div>
  79. <p>
  80. Example of edge styles support.
  81. </p>
  82. <table border=1>
  83. <tr>
  84. <th>Attributes</th><th>Desriptions</th>
  85. </tr>
  86. <tr>
  87. <td align="center">label</td><td>Text displayed on the edge</td>
  88. </tr>
  89. <tr>
  90. <td align="center">color</td><td>Edge color</td>
  91. </tr>
  92. <tr>
  93. <td align="center">style</td>
  94. <td>Edge style (solid, dashed, dotted)</td>
  95. </tr>
  96. <tr>
  97. <td align="center">arrowhead</td>
  98. <td>Arrow style (dot, box, crow, curve, icurve, normal, inv, diamond, tee, vee)</td>
  99. </tr>
  100. </table>
  101. </div>
  102. </div>
  103. <div id="contents">
  104. <div id="left">
  105. <textarea id="data">
  106. </textarea>
  107. <div>
  108. <button id="draw" title="Draw the DOT graph (Ctrl+Enter)">Draw</button>
  109. <button id="reset" title="Reset the DOT graph">Reset</button>
  110. </div>
  111. <div>
  112. <span id="error"></span>
  113. </div>
  114. </div>
  115. <div id="right">
  116. <div id="mynetwork"></div>
  117. </div>
  118. </div>
  119. <script type="text/javascript">
  120. var dotDefault = 'digraph {\n' +
  121. ' // Parent nodes\n' +
  122. ' lines[label="LINES"]; \n' +
  123. ' ahs[label="ARROW HEADS"]; \n' +
  124. '\n' +
  125. ' // Line styles\n' +
  126. ' lines -- solid[label="solid pink", color="pink"]; \n' +
  127. ' lines -- dashed[label="dashed green", style="dashed", color="green"]; \n' +
  128. ' lines -- dotted[label="dotted purple", style="dotted", color="purple"]; \n' +
  129. '\n' +
  130. ' // Arrowhead styles\n' +
  131. ' ahs -> dot[label="dot", arrowhead=dot]; \n' +
  132. ' ahs -> box[label="box", arrowhead=box]; \n' +
  133. ' ahs -> crow[label="crow", arrowhead=crow]; \n' +
  134. ' ahs -> curve[label="curve", arrowhead=curve]; \n' +
  135. ' ahs -> icurve[label="icurve", arrowhead=icurve]; \n' +
  136. ' ahs -> normal[label="normal", arrowhead=normal]; \n' +
  137. ' ahs -> inv[label="inv", arrowhead=inv]; \n' +
  138. ' ahs -> diamond[label="diamond", arrowhead=diamond]; \n' +
  139. ' ahs -> tee[label="tee", arrowhead=tee]; \n' +
  140. ' ahs -> vee[label="vee", arrowhead=vee]; \n' +
  141. '}';
  142. // create a network
  143. var container = document.getElementById('mynetwork');
  144. var options = {
  145. physics: {
  146. stabilization: false,
  147. barnesHut: {
  148. springLength: 200
  149. }
  150. }
  151. };
  152. var data = {};
  153. var network = new vis.Network(container, data, options);
  154. $('#draw').click(draw);
  155. $('#reset').click(reset);
  156. $(window).resize(resize);
  157. $(window).load(draw);
  158. $('#data').keydown(function (event) {
  159. if (event.ctrlKey && event.keyCode === 13) { // Ctrl+Enter
  160. draw();
  161. event.stopPropagation();
  162. event.preventDefault();
  163. }
  164. });
  165. function resize() {
  166. $('#contents').height($('body').height() - $('#header').height() - 30);
  167. }
  168. function draw () {
  169. try {
  170. resize();
  171. $('#error').html('');
  172. // Provide a string with data in DOT language
  173. data = vis.network.convertDot($('#data').val());
  174. network.setData(data);
  175. }
  176. catch (err) {
  177. // set the cursor at the position where the error occurred
  178. var match = /\(char (.*)\)/.exec(err);
  179. if (match) {
  180. var pos = Number(match[1]);
  181. var textarea = $('#data')[0];
  182. if(textarea.setSelectionRange) {
  183. textarea.focus();
  184. textarea.setSelectionRange(pos, pos);
  185. }
  186. }
  187. // show an error message
  188. $('#error').html(err.toString());
  189. }
  190. }
  191. function reset() {
  192. $('#data').val(dotDefault);
  193. draw();
  194. }
  195. window.onload = function() {
  196. reset();
  197. }
  198. </script>
  199. </body>
  200. </html>