sigma.js index.html example file

Graphs inside the browser
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
User avatar
WeezyF
Posts:48
Joined:03 May 2012 02:29
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
sigma.js index.html example file

Post by WeezyF » 24 May 2012 20:05

Hi Guys; hope everyone is doing well.

Im trying to use that awesome sigma.js exporter thing to put a gephi graph on a web page. http://sigmajs.org/. But I cant really figure it out. Before i used the gexf-js by raphv and eduramiba (thanks guys). And on their github page they put an easy to follow index.html file that was, well... easy to follow and told me how to put this javascript thing in the body of a web page. https://github.com/raphv/gexf-js/blob/master/index.html.

So i was just wondering if a similar index.html file exists for the simga.js exporter? I know it's probably very easy for most of you, but I my skills in coding and syntax and stuff are rather n00bish. Any help would be most appreciated. Thanks again!
Weezy F Baybay

User avatar
seinecle
Gephi Community Support
Posts:546
Joined:08 Feb 2010 16:55
Location:Lyon, France
Contact:

Re: sigma.js index.html example file

Post by seinecle » 24 May 2012 21:28

Hey again!

I was just like you since I don't practice javascript so I was not very sure how to make it work.

But that's quite simple, and with some help from the creator of sigmajs that worked fine. See the result here:
http://www.clementlevallois.net/datavizmap/index.php

To do the same, you need to have your own server, I assume you have one?

If so, you simply
- unzip the file attached to this post on your server
- upload your gexf file to the data folder
- in the file "index.html", replace the name of the existing gexf file by yours.
=>that is the line that says: sigInst.parseGexf('data/datavizmap.gexf');
=> replace "datavizmap.gexf" by the name of your file.
- that's it!

Good luck!

Best,

Clement
[EDIT: of course, change the rest of the index.html file where I wrote my own stuff, and put any text you like instead!]
Attachments
example sigmaJS.zip
(197.89KiB)Downloaded 1239 times

User avatar
WeezyF
Posts:48
Joined:03 May 2012 02:29
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: sigma.js index.html example file

Post by WeezyF » 25 May 2012 17:00

Last edited by WeezyF on 10 Jul 2013 03:36, edited 1 time in total.

User avatar
WeezyF
Posts:48
Joined:03 May 2012 02:29
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: sigma.js index.html example file

Post by WeezyF » 25 May 2012 21:50

Now to build upon that... Would it be possible to use the sigma.js.ForcedAtlas2 script on a .gexf file (or another type of data file). I looked in the code found hurr (http://sigmajs.org/examples/random_clusters.html ) and he seems to have the ForceAtlas algo running on randomly generated nodes. So, would we be able to use this same algo, but have it run on nodes in a data file we upload?

All suggestions welcome;
zzz

raphytaffy
Posts:2
Joined:18 Jun 2012 22:59
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: sigma.js index.html example file

Post by raphytaffy » 18 Jun 2012 23:06

seinecle wrote:Hey again!

I was just like you since I don't practice javascript so I was not very sure how to make it work.

But that's quite simple, and with some help from the creator of sigmajs that worked fine. See the result here:
http://www.clementlevallois.net/datavizmap/index.php

To do the same, you need to have your own server, I assume you have one?

If so, you simply
- unzip the file attached to this post on your server
- upload your gexf file to the data folder
- in the file "index.html", replace the name of the existing gexf file by yours.
=>that is the line that says: sigInst.parseGexf('data/datavizmap.gexf');
=> replace "datavizmap.gexf" by the name of your file.
- that's it!

Good luck!

Best,

Clement
[EDIT: of course, change the rest of the index.html file where I wrote my own stuff, and put any text you like instead!]
Hi, I am trying to do this locally, but am having issues with the graph showing up. I downloaded your example zip and kept everything as is, so are nodes supposed to show up as you have defined in your datavizmap.gexf? Because I am seeing an empty screen like so: Image

User avatar
seinecle
Gephi Community Support
Posts:546
Joined:08 Feb 2010 16:55
Location:Lyon, France
Contact:

Re: sigma.js index.html example file

Post by seinecle » 19 Jun 2012 09:38

The problem might be with the fact that you run it locally. Try on the server side and see what happens!

raphytaffy
Posts:2
Joined:18 Jun 2012 22:59
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: sigma.js index.html example file

Post by raphytaffy » 19 Jun 2012 18:44

Thanks for the reply. I actually don't have a server of my own, but I am curious as to why it would run on the server side and not locally. Would you mind elaborating?

shriman Nijagun
Posts:1
Joined:21 Jun 2012 07:04
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: sigma.js index.html example file

Post by shriman Nijagun » 21 Jun 2012 07:10

I too have the same issue as 'raphytaffy' has.
why we need the server when we want to run it in locally
(if its mandatory which server we required?)

i am on the train track i must get out of this things done
thanks in advance if any solutions

User avatar
WeezyF
Posts:48
Joined:03 May 2012 02:29
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: sigma.js index.html example file

Post by WeezyF » 25 Jun 2012 03:22

Has anyone figured out how to use the sigma.js forceAtlas2 plugin with data that is not randomly generated... (ie; a gexf file...); http://sigmajs.org/examples/random_clusters.html

in the first few lines of the plugin code is where they randomly generate the nodes..
instead of randomly generated, can we just pass in data from our own graph..?
// Generate a random graph with :
// . N nodes
// . E edges
// . C clusters
// . d the proportion of edges that connect two nodes
// from the same cluster
var i, N = 500, E = 3000, C = 5, d = 0.5, clusters = [];
for(i = 0; i < C; i++){
clusters.push({
'id': i,
'nodes': [],
'color': 'rgb('+Math.round(Math.random()*256)+','+
Math.round(Math.random()*256)+','+
Math.round(Math.random()*256)+')'
});
}

for(i = 0; i < N; i++){
var cluster = clusters[(Math.random()*C)|0];
sigInst.addNode('n'+i,{
'x': Math.random(),
'y': Math.random(),
'size': 0.5+4.5*Math.random(),
'color': cluster['color'],
'cluster': cluster['id']
});
cluster.nodes.push('n'+i);
}

for(i = 0; i < E; i++){
if(Math.random() < 1-d){
sigInst.addEdge(i,'n'+(Math.random()*N|0),'n'+(Math.random()*N|0));
}else{
var cluster = clusters[(Math.random()*C)|0], n = cluster.nodes.length;
sigInst.addEdge(i,cluster.nodes[Math.random()*n|0],cluster.nodes[Math.random()*n|0]);
}
}

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable