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.

71 lines
2.1 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Basic usage</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: 400px;
  11. border: 1px solid lightgray;
  12. }
  13. p {
  14. max-width:800px;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <p>
  20. There are a lot of options with colors. You can manually define a color or inherit the color from the nodes. You can set the opacity
  21. to override any opacity given by a color. <b>IN ORDER TO USE THE OPACITY, BOTH THE NODES AND THE EDGES NEED COLORS IN HEX OR RGB</b>!
  22. </p>
  23. <div id="mynetwork"></div>
  24. <script type="text/javascript">
  25. // create an array with nodes
  26. var nodes = new vis.DataSet([
  27. {id: 1, label: 'node\none', shape: 'box', color:'#97C2FC'},
  28. {id: 2, label: 'node\ntwo', shape: 'circle', color:'#FFFF00'},
  29. {id: 3, label: 'node\nthree', shape: 'diamond', color:'#FB7E81'},
  30. {id: 4, label: 'node\nfour', shape: 'dot', size: 10, color:'#7BE141'},
  31. {id: 5, label: 'node\nfive', shape: 'ellipse', color:'#6E6EFD'},
  32. {id: 6, label: 'node\nsix', shape: 'star', color:'#C2FABC'},
  33. {id: 7, label: 'node\nseven', shape: 'triangle', color:'#FFA807'},
  34. {id: 8, label: 'node\neight', shape: 'triangleDown', color:'#6E6EFD'}
  35. ]);
  36. // create an array with edges
  37. var edges = new vis.DataSet([
  38. {from: 1, to: 8, color:{color:'red'}},
  39. {from: 1, to: 3, color:'rgb(20,24,200)'},
  40. {from: 1, to: 2, color:{color:'rgba(30,30,30,0.2)', highlight:'blue'}},
  41. {from: 2, to: 4, color:{inherit:'to'}},
  42. {from: 2, to: 5, color:{inherit:'from'}},
  43. {from: 5, to: 6, color:{inherit:'both'}},
  44. {from: 6, to: 7, color:{color:'#ff0000', opacity:0.3}},
  45. {from: 6, to: 8, color:{opacity:0.3}},
  46. ]);
  47. // create a network
  48. var container = document.getElementById('mynetwork');
  49. var data = {
  50. nodes: nodes,
  51. edges: edges
  52. };
  53. var options = {
  54. nodes: {
  55. shape: 'circle'
  56. }
  57. };
  58. var network = new vis.Network(container, data, options);
  59. </script>
  60. </body>
  61. </html>