You want your chart to be absolute . I think this is a problem with the canvas.
therefore html
<!DOCTYPE html> <html> <head> <script src="http://sigmajs.org/js/sigma.min.js"></script> <script src="/js/sigmatest.js"></script> <link rel="stylesheet" href="/css/sigma.css"> </head> <body> <div id="sigma-parent"> <div id="sigma-example"> </div> </div> </body> </html>
css
#sigma-parent { width: 500px; height: 500px; position: relative; } #sigma-example { position: absolute; width: 100%; height: 100%; }
js in sigmatest.js
function init() { var sigRoot = document.getElementById('sigma-example'); var sigInst = sigma.init(sigRoot); sigInst.addNode('hello',{ label: 'Hello', x: 10, y: 10, size: 5, color: '#ff0000' }).addNode('world',{ label: 'World !', x: 20, y: 20, size: 3, color: '#00ff00' }).addEdge('hello_world','hello','world').draw(); } if (document.addEventListener) { document.addEventListener('DOMContentLoaded', init, false); } else { window.onload = init; }
source share