javascript - Sigma js graph doesn't render anything -


the following code doesn't render , , doesn't return error :

var sigma = require('sigma'); var i,     s,     n = 100,     e = 500,     g = {         nodes: [],         edges: []     };  // generate random graph: (i = 0; < n; i++)     g.nodes.push({         id: 'n' + i,         label: 'node ' + i,         x: math.random(),         y: math.random(),         size: math.random(),         color: '#666'     });  (i = 0; < e; i++)     g.edges.push({         id: 'e' + i,         source: 'n' + (math.random() * n | 0),         target: 'n' + (math.random() * n | 0),         size: math.random(),         color: '#ccc'     }); sigma.renderers.def = sigma.renderers.canvas; // instantiate sigma: s = new sigma({     graph: g,     container: document.getelementbyid('sigma-container') }); 

some notes: 1.i set max-width , height :

#sigma-container {   max-width: 400px;   height: 400px;   margin: auto; } 

2.i'm running on node , have separate js file , gets compiled , passed browser correctly.(at least can see code in chrome's developers tool)

3.i use following html :

<!doctype html> <html>   <head>       <link rel='stylesheet' href='/stylesheets/style.css' />   </head>   <body>     <div id="sigma-container"></div>       <script src="/javascripts/bundle.js"></script>   </body> </html> 

4.if instead of getelementbyid('sigma-container') put name of div, returns error : uncaught container not found.

any idea on why doesn't render ?

the container not found error fixed in pull request https://github.com/jacomyal/sigma.js/pull/653, not included in latest release of sigma (v1.1.0). manually built copy off master branch of github project included fix, , resolved issue.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -