Monday, September 4, 2017

I am trying to figure out how to Load Sigma.js Plugins with Require.js

The Grunt file [1] that I modified does not create a sigma.require.js file that loads the ForceAtlas2 Plugin. (maybe the file does not include the Plugin)

I can get this:


But I cannot get this:



I think I need to include the plugin in the require statement and assign it to the global sigma object:

require([ "sigma", "js/node_modules/sigma/plugins/sigma.layout.forceAtlas2/supervisor" 
,"js/node_modules/sigma/plugins/sigma.layout.forceAtlas2/worker"], function( sigma ) {
// Your code goes here.
});

like in https://learn.jquery.com/jquery-ui/environments/amd/
require([ "jquery", "jquery-ui/autocomplete" ], function( $ ) {
$( "<input>" )
.autocomplete({ source: [ "One", "Two", "Three" ]})
.appendTo( "body" );
});
Also, sigma comes from the config file: requirejs.config({ baseUrl : 'js', paths : { d3 : 'libraries/d3', jquery: 'libraries/jquery-3.1.1.min', sigma: 'node_modules/sigma/build/sigma.require' }, shim: { 'sigma' : { exports: 'sigma' } } });

[1] https://github.com/bshambaugh/sigma.js/blob/master/Gruntfile.js

No comments:

Post a Comment