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.

66 lines
1.4 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Maximum Width Edge Case Test</title>
  5. <script src="../../dist/vis-network.min.js" type="text/javascript"></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: 400px;
  11. border: 1px solid lightgray;
  12. }
  13. </style>
  14. <script src="../../googleAnalytics.js"></script>
  15. </head>
  16. <body>
  17. <p>A word in a label that's wider than the maximum width will be forced onto a line. We can't do better without breaking the word into pieces, and even then the pieces could still be too wide.</p>
  18. <p>Avoid the problem. Don't set ridiculously small maximum widths.</p>
  19. <div id="mynetwork"></div>
  20. <script type="text/javascript">
  21. var nodes = new vis.DataSet([
  22. { id: 1, label: 'Node 1', widthConstraint : { maximum : 30 } }
  23. ]);
  24. var edges = [];
  25. var container = document.getElementById('mynetwork');
  26. var data = {
  27. nodes: nodes,
  28. edges: edges
  29. };
  30. var options = {
  31. edges: {
  32. font: {
  33. size: 12
  34. },
  35. widthConstraint: {
  36. maximum: 90
  37. }
  38. },
  39. nodes: {
  40. shape: 'box',
  41. margin: 10,
  42. font: {
  43. multi: true
  44. },
  45. widthConstraint: {
  46. maximum: 200
  47. }
  48. },
  49. physics: {
  50. enabled: false
  51. }
  52. };
  53. var network = new vis.Network(container, data, options);
  54. </script>
  55. </body>
  56. </html>