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.

64 lines
1.8 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. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  17. <script type="text/javascript">
  18. // Called on page load
  19. function draw() {
  20. var nodes = [
  21. {id: 1, label: 'dashed\nline\nexamples'},
  22. {id: 2, label: 'default'},
  23. {id: 3, label: 'dash.length: 20\ndash.gap: 20'},
  24. {id: 4, label: 'dash.length: 20\ndash.gap: 5'},
  25. {id: 5, label: 'dash.length: 5\ndash.gap: 20'},
  26. {id: 6, label: 'dash.length: 20\ndash.gap: 5\ndash.altLength: 5'}
  27. ];
  28. var edges = [
  29. {from: 1, to: 2, style: 'dash-line'},
  30. {from: 1, to: 3, style: 'dash-line', dash: {length: 20, gap: 20}},
  31. {from: 1, to: 4, style: 'dash-line', dash: {length: 20, gap: 5}},
  32. {from: 1, to: 5, style: 'dash-line', dash: {length: 5, gap: 20}},
  33. {from: 1, to: 6, style: 'dash-line', dash: {length: 20, gap: 5, altLength: 5}}
  34. ];
  35. // create the network
  36. var container = document.getElementById('mynetwork');
  37. var data = {
  38. nodes: nodes,
  39. edges: edges
  40. };
  41. var options = {
  42. nodes: {
  43. shape: 'box'
  44. },
  45. physics: {barnesHut:{springLength:150}}, // this is the correct way to set the length of the springs
  46. stabilize: false
  47. };
  48. var network = new vis.Network(container, data, options);
  49. }
  50. </script>
  51. </head>
  52. <body onload="draw();">
  53. <p>
  54. This example shows the different options for dashed lines.
  55. </p>
  56. <div id="mynetwork"></div>
  57. </body>
  58. </html>