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.

63 lines
1.7 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Dashed lines</title>
  5. <style type="text/css">
  6. body {
  7. font: 10pt sans;
  8. }
  9. #mynetwork {
  10. width: 600px;
  11. height: 600px;
  12. border: 1px solid lightgray;
  13. }
  14. </style>
  15. <script type="text/javascript" src="../../dist/vis.js"></script>
  16. <script type="text/javascript">
  17. // Called on page load
  18. function draw() {
  19. var nodes = [
  20. {id: 1, label: 'dashed\nline\nexamples'},
  21. {id: 2, label: 'default'},
  22. {id: 3, label: 'dash.length: 20\ndash.gap: 20'},
  23. {id: 4, label: 'dash.length: 20\ndash.gap: 5'},
  24. {id: 5, label: 'dash.length: 5\ndash.gap: 20'},
  25. {id: 6, label: 'dash.length: 20\ndash.gap: 5\ndash.altLength: 5'}
  26. ];
  27. var edges = [
  28. {from: 1, to: 2, style: 'dash-line'},
  29. {from: 1, to: 3, style: 'dash-line', dash: {length: 20, gap: 20}},
  30. {from: 1, to: 4, style: 'dash-line', dash: {length: 20, gap: 5}},
  31. {from: 1, to: 5, style: 'dash-line', dash: {length: 5, gap: 20}},
  32. {from: 1, to: 6, style: 'dash-line', dash: {length: 20, gap: 5, altLength: 5}}
  33. ];
  34. // create the network
  35. var container = document.getElementById('mynetwork');
  36. var data = {
  37. nodes: nodes,
  38. edges: edges
  39. };
  40. var options = {
  41. nodes: {
  42. shape: 'box'
  43. },
  44. physics: {barnesHut:{springLength:150}}, // this is the correct way to set the length of the springs
  45. stabilize: false
  46. };
  47. var network = new vis.Network(container, data, options);
  48. }
  49. </script>
  50. </head>
  51. <body onload="draw();">
  52. <p>
  53. This example shows the different options for dashed lines.
  54. </p>
  55. <div id="mynetwork"></div>
  56. </body>
  57. </html>