Advertisement
Guest User

creating nodes and edges with sigma and html

a guest
Jan 29th, 2015
695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1.  
  2. <html>
  3. <head>
  4. <style type="text/css">
  5. body {
  6. margin: 0;
  7. }
  8. #container {
  9. position: absolute;
  10. width: 100%;
  11. height: 100%;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16. <div id="container"></div>
  17. <script src="./sigma.min.js"></script>
  18. <script>
  19. // Let's first initialize sigma:
  20. var s = new sigma('container');
  21.  
  22. // Then, let's add some data to display:
  23. s.graph.addNode({
  24. // Main attributes:
  25. id: 'n0',
  26. label: 'This is an example of node',
  27. // Display attributes:
  28. x: 0,
  29. y: 0,
  30. size: 20,
  31.  
  32. }).addNode({
  33. // Main attributes:
  34. id: 'n1',
  35. label: 'and this is another node',
  36. // Display attributes:
  37. x: 0.1,
  38. y: 0.1,
  39. size: 10,
  40.  
  41. }).addEdge({
  42. id: 'e0',
  43. // Reference extremities:
  44. source: 'n0',
  45. target: 'n1'
  46. });
  47.  
  48. // Finally, let's ask our sigma instance to refresh:
  49. s.refresh();
  50. </script>
  51.  
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement