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.5 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-network.min.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. </head>
  18. <body>
  19. <p>Labels can have any color background.</p>
  20. <div id="mynetwork"></div>
  21. <script type="text/javascript">
  22. // create an array with nodes
  23. var nodes = [
  24. {id: 1, label: 'Node 1', font: {background: 'red'}},
  25. {id: 2, label: 'Node 2', font: {background: 'white'}},
  26. {id: 3, label: 'Node 3', font: {background: 'cyan'}},
  27. {id: 4, label: 'Node 4', font: {background: 'lime'}},
  28. {id: 5, label: 'Node 5', font: {background: 'pink'}}
  29. ];
  30. // create an array with edges
  31. var edges = [
  32. {from: 1, to: 2, label: 'label1', font: {background: '#ff0000'}},
  33. {from: 1, to: 3, label: 'label2', font: {background: 'yellow'}},
  34. {from: 2, to: 4, label: 'label3', font: {background: 'lime'}},
  35. {from: 2, to: 5, label: 'label3', font: {background: 'pink'}}
  36. ];
  37. // create a network
  38. var container = document.getElementById('mynetwork');
  39. var data = {
  40. nodes: nodes,
  41. edges: edges
  42. };
  43. var options = {nodes:{font:{strokeWidth:0}}, edges:{font:{strokeWidth:0}}};
  44. var network = new vis.Network(container, data, options);
  45. </script>
  46. </body>
  47. </html>