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.

57 lines
1.4 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Label alignment</title>
  5. <script type="text/javascript" src="../../../dist/vis.js"></script>
  6. <link href="../../../dist/vis.css" rel="stylesheet" type="text/css" />
  7. <style type="text/css">
  8. #mynetwork {
  9. width: 600px;
  10. height: 600px;
  11. border: 1px solid lightgray;
  12. }
  13. p {
  14. max-width:600px;
  15. }
  16. </style>
  17. <script src="../../googleAnalytics.js"></script>
  18. </head>
  19. <body>
  20. <p>Labels of edges can be aligned to edges in various ways. <br>Label alignment for nodes (top, bottom, left, right, inside) is planned but not in vis yet.</p>
  21. <div id="mynetwork"></div>
  22. <script type="text/javascript">
  23. // create an array with nodes
  24. var nodes = [
  25. {id: 1, label: 'Node 1'},
  26. {id: 2, label: 'Node 2'},
  27. {id: 3, label: 'Node 3'},
  28. {id: 4, label: 'Node 4'},
  29. {id: 5, label: 'Node 5'}
  30. ];
  31. // create an array with edges
  32. var edges = [
  33. {from: 1, to: 2, label: 'middle', font: {align: 'middle'}},
  34. {from: 1, to: 3, label: 'top', font: {align: 'top'}},
  35. {from: 2, to: 4, label: 'horizontal', font: {align: 'horizontal'}},
  36. {from: 2, to: 5, label: 'bottom', font: {align: 'bottom'}}
  37. ];
  38. // create a network
  39. var container = document.getElementById('mynetwork');
  40. var data = {
  41. nodes: nodes,
  42. edges: edges
  43. };
  44. var options = {};
  45. var network = new vis.Network(container, data, options);
  46. </script>
  47. </body>
  48. </html>