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.8 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Label margins</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. <script src="../../googleAnalytics.js"></script>
  18. </head>
  19. <body>
  20. <p>The labels of box, circle, database, icon and text nodes may have different margin values.
  21. Top, right, bottom and left margins may be different for each node.</p>
  22. <p>Setting the margin value in the network's nodes property sets it as the default.</p>
  23. <p>Setting a the value to a number uses that number for the margins. If the value is an object, a different value for each margin will be set.</p>
  24. <p>Note that negative values appropriately push labels outside the node.
  25. <div id="mynetwork"></div>
  26. <script type="text/javascript">
  27. // create an array with nodes
  28. var nodes = [
  29. { id: 1, label: 'Default Value\n(5)', x: -150, y: -150 },
  30. { id: 2, label: 'Single Value\n(25)', margin: 20, x: 0, y: 0 },
  31. { id: 3, label: 'Different Values\n(10, 20, 40, 30)', margin: { top: 10, right: 20, bottom: 40, left: 30 }, x: 120, y: 120},
  32. { id: 4, label: 'A Negative Value\n(10, 20, 40, -50)', margin: { top: 10, right: 20, bottom: 30, left: -20 }, x: 300, y: -300}
  33. ];
  34. // create an array with edges
  35. var edges = [
  36. {from: 1, to: 2},
  37. {from: 2, to: 3},
  38. {from: 3, to: 4}
  39. ];
  40. // create a network
  41. var container = document.getElementById('mynetwork');
  42. var data = {
  43. nodes: nodes,
  44. edges: edges
  45. };
  46. var options = {
  47. nodes: {
  48. shape: 'box'
  49. }
  50. };
  51. var network = new vis.Network(container, data, options);
  52. </script>
  53. </body>
  54. </html>