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.

61 lines
1.4 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Label stroke</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. background:#d1d1d1;
  13. }
  14. p {
  15. max-width:600px;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <p>The stroke of labels is fully can have a width and color. Edgelabels by default have a white stroke for clarity.</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', font: {strokeWidth: 3, strokeColor: 'white'}},
  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: 'edgeLabel', font: {strokeWidth: 2, strokeColor : '#00ff00'}},
  34. {from: 1, to: 3, label: 'edgeLabel'},
  35. {from: 2, to: 4},
  36. {from: 2, to: 5}
  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. nodes : {
  46. shape: 'dot',
  47. size: 10
  48. }
  49. };
  50. var network = new vis.Network(container, data, options);
  51. </script>
  52. </body>
  53. </html>