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.

88 lines
2.2 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. <style type="text/css">
  7. #mynetwork {
  8. width: 600px;
  9. height: 400px;
  10. border: 1px solid lightgray;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <p>
  16. Create a simple network with some nodes and edges.
  17. </p>
  18. <input type="button" value="asdasa" onclick="b()">
  19. <div id="mynetwork"></div>
  20. <script type="text/javascript">
  21. var nodes = [
  22. {"id":"28","label":"SPD","shape":"image","image":"http://commons.wikimedia.org/wiki/Special:FilePath/SPD_logo.svg?width=300","x":7146,"y":1903},
  23. {"id":"148","label":"Wladimir Putin","shape":"image","image":"http://commons.wikimedia.org/wiki/Special:FilePath/Vladimir_Putin_-_2006.jpg?width=300","x":7677,"y":1885}
  24. ];
  25. var edges = []
  26. var nodesDataset = new vis.DataSet(nodes);
  27. var edgesDataset = new vis.DataSet(edges);
  28. var options = {
  29. nodes: {
  30. shape: 'dot',
  31. scaling: {
  32. min: 10,
  33. max: 200,
  34. label: {
  35. min: 50,
  36. max: 100,
  37. drawThreshold: 10,
  38. maxVisible: 60
  39. }
  40. },
  41. font: {
  42. size: 100,
  43. face: 'Tahoma'
  44. }
  45. },
  46. edges: {
  47. width: 0.2,
  48. color: {inherit: 'from'},
  49. smooth: {
  50. type: 'continuous'
  51. }
  52. },
  53. physics: false,
  54. interaction: {
  55. tooltipDelay: 200,
  56. hideEdgesOnDrag: true,
  57. navigationButtons: true,
  58. keyboard: true
  59. }
  60. };
  61. var container = document.getElementById('mynetwork');
  62. network = new vis.Network(container, {nodes: nodesDataset, edges: edgesDataset}, options);
  63. function b() {
  64. var nodesToAdd = new vis.DataSet(nodes).get();
  65. console.log(nodesToAdd);
  66. nodesDataset.update(nodesToAdd);
  67. }
  68. </script>
  69. </body>
  70. </html>