GUIDE
- Left-click and drag the background to move the graph
- Left-click and drag the nodes to reorganize
- Left-click a node to view first level connections
- Double left-click a node to navigate to its page
- Double left-click the background to zoom in
- Right-click the background to zoom out
sigma.utils.pkg('sigma.canvas.nodes');
sigma.canvas.nodes.image = (function() {
var _cache = {},
_loading = {},
_callbacks = {};
// Return the renderer itself:
var renderer = function(node, context, settings) {
var args = arguments,
prefix = settings('prefix') || '',
size = node[prefix + 'size'],
color = node.color || settings('defaultNodeColor'),
url = node.url;
if (_cache[url]) {
context.save();
// Draw the clipping disc:
context.beginPath();
context.arc(
node[prefix + 'x'],
node[prefix + 'y'],
node[prefix + 'size'],
0,
Math.PI * 2,
true
);
context.closePath();
context.clip();
// Draw the image
context.drawImage(
_cache[url],
node[prefix + 'x'] - size,
node[prefix + 'y'] - size,
2 * size,
2 * size
);
// Quit the "clipping mode":
context.restore();
// Draw the border:
context.beginPath();
context.arc(
node[prefix + 'x'],
node[prefix + 'y'],
node[prefix + 'size'],
0,
Math.PI * 2,
true
);
context.lineWidth = 1;
context.strokeStyle = node.color || settings('defaultNodeColor');
context.stroke();
} else {
sigma.canvas.nodes.image.cache(url);
sigma.canvas.nodes.def.apply(
sigma.canvas.nodes,
args
);
}
};
// Let's add a public method to cache images, to make it possible to
// preload images before the initial rendering:
renderer.cache = function(url, callback) {
if (callback)
_callbacks[url] = callback;
if (_loading[url])
return;
var img = new Image();
img.onload = function() {
_loading[url] = false;
_cache[url] = img;
if (_callbacks[url]) {
_callbacks[url].call(this, img);
delete _callbacks[url];
}
};
_loading[url] = true;
img.src = url;
};
return renderer;
})();
var i,
s,
o,
offset_left = 0.5,
N = 1,
E = 40,
C = 5,
d = 0.5,
cs = [],
g = {
nodes: [],
edges: []
};
if (!sigma.classes.graph.hasMethod('neighbors')){
sigma.classes.graph.addMethod('neighbors', function(nodeId) {
var k,
neighbors = {},
index = this.allNeighborsIndex[nodeId] || {};
for (k in index)
neighbors[k] = this.nodesIndex[k];
return neighbors;
});
}
//adding the central node
g.nodes.push({
id: 164837,
label: 'Alexandre Blanc',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2021/08/research_pasteur-alexandre-blanc-me-150x150.jpg',
x: 0,
y: 0,
size: 30,
color: '#DDDDDD'
});
var biggest_node_size = 0;
N=4
// adding node
var x_node = Math.cos(2 * 0 * Math.PI / N) * 10;
var y_node = Math.sin(2 * 0 * Math.PI / N) * 10;
g.nodes.push({
id: 164978,
label: 'SOFTWARE: Themis, Nyx, Japet & Héméré',
x: x_node,
y: y_node,
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2021/08/research_pasteur-themis-nyx-japet-amp-hemere-screenshot-2021-08-21-at-22.25.33-150x150.png',
page_url: 'https://research.pasteur.fr/en/software/themis-nyx-japet-hemere/',
size: 35,
color: '#DDDDDD'
});
//link content to central post
g.edges.push({
id: 164837164978,
size: 0.5,
source: 164837,
target: 164978,
});
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 50133,
label: 'Jean-Baptiste Masson',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2018/06/research_pasteur-jbm_photo_serieux_low_res-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/jean-baptiste-masson/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 16497850133,
size: 0.5,
source: 164978,
target: 50133 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 85997,
label: 'Christian L. Vestergaard',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2017/04/research.pasteur.fr_photopasteur-1-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/fr-christian-vestergaard/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 16497885997,
size: 0.5,
source: 164978,
target: 85997 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 164837) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 164978164837,
size: 0.5,
source: 164978,
target: 164837 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 101190,
label: 'Chloé Barre',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2018/01/research_pasteur-chloe-barre-chloe-barre-copy-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/chloe-barre/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 164978101190,
size: 0.5,
source: 164978,
target: 101190 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 164842,
label: 'Alexis Bénichou',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2021/08/research_pasteur-alexis-benichou-photo-prairie-150x150.jpeg',
page_url: 'https://research.pasteur.fr/en/member/alexis-benichou/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 164978164842,
size: 0.5,
source: 164978,
target: 164842 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 146680,
label: 'Hippolyte Verdier',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2020/09/research_pasteur-photo-chic-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/hippolyte-verdier/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 164978146680,
size: 0.5,
source: 164978,
target: 146680 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 80014,
label: 'François Laurent',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2016/11/research_pasteur-francois-laurent-moi-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/francois-laurent/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 16497880014,
size: 0.5,
source: 164978,
target: 80014 });
// adding node
var x_node = Math.cos(2 * 1 * Math.PI / N) * 10;
var y_node = Math.sin(2 * 1 * Math.PI / N) * 10;
g.nodes.push({
id: 164946,
label: 'PROJECT: Topological and statistical properties of neural connectomes',
x: x_node,
y: y_node,
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2021/08/research_pasteur-entopological-and-statistical-properties-of-neural-connectomes-image-motifs-copy-4-150x150.jpeg',
page_url: 'https://research.pasteur.fr/en/project/topological-and-statistical-properties-of-neural-connectomes/',
size: 35,
color: '#DDDDDD'
});
//link content to central post
g.edges.push({
id: 164837164946,
size: 0.5,
source: 164837,
target: 164946,
});
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 50133) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 16494650133,
size: 0.5,
source: 164946,
target: 50133 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 164842) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 164946164842,
size: 0.5,
source: 164946,
target: 164842 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 164837) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 164946164837,
size: 0.5,
source: 164946,
target: 164837 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 101190) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 164946101190,
size: 0.5,
source: 164946,
target: 101190 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 85997) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 16494685997,
size: 0.5,
source: 164946,
target: 85997 });
// adding node
var x_node = Math.cos(2 * 2 * Math.PI / N) * 10;
var y_node = Math.sin(2 * 2 * Math.PI / N) * 10;
g.nodes.push({
id: 89487,
label: 'PROJECT: Deciding in Complex environments',
x: x_node,
y: y_node,
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2017/05/research_pasteur-plot_derivatives_start_screen_scale_t15-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/project/drosophila-larva-behavioural-dynamics/',
size: 35,
color: '#DDDDDD'
});
//link content to central post
g.edges.push({
id: 16483789487,
size: 0.5,
source: 164837,
target: 89487,
});
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 101190) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 89487101190,
size: 0.5,
source: 89487,
target: 101190 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 85994,
label: '',
type: 'image',
url: '',
page_url: '',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 8948785994,
size: 0.5,
source: 89487,
target: 85994 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 115697,
label: '',
type: 'image',
url: '',
page_url: '',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 89487115697,
size: 0.5,
source: 89487,
target: 115697 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 164837) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 89487164837,
size: 0.5,
source: 89487,
target: 164837 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 50133) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 8948750133,
size: 0.5,
source: 89487,
target: 50133 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 85997) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 8948785997,
size: 0.5,
source: 89487,
target: 85997 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 80014) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 8948780014,
size: 0.5,
source: 89487,
target: 80014 });
// adding node
var x_node = Math.cos(2 * 3 * Math.PI / N) * 10;
var y_node = Math.sin(2 * 3 * Math.PI / N) * 10;
g.nodes.push({
id: 70654,
label: 'TEAM: Decision and Bayesian Computation – Epiméthée',
x: x_node,
y: y_node,
type: 'image',
url: '',
page_url: 'https://research.pasteur.fr/en/team/decision-and-bayesian-computation/',
size: 35,
color: '#DDDDDD'
});
//link content to central post
g.edges.push({
id: 16483770654,
size: 0.5,
source: 164837,
target: 70654,
});
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 85997) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 7065485997,
size: 0.5,
source: 70654,
target: 85997 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 80014) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 7065480014,
size: 0.5,
source: 70654,
target: 80014 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 104637,
label: 'Frédérique Bouchot',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2018/03/research_pasteur-frederique-bouchot-2-150x150.png',
page_url: 'https://research.pasteur.fr/en/member/frederique-bouchot/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 70654104637,
size: 0.5,
source: 70654,
target: 104637 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 191233,
label: 'Alex Barbier–Chebbah',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2022/11/research_pasteur-alex-barbier-chebbah-research-pasteur-alex-barbier-chebbah-photo5-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/alex-barbier-chebbah/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 70654191233,
size: 0.5,
source: 70654,
target: 191233 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 229418,
label: 'Astrid Nilsson',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2024/08/research_pasteur-enastrid-nilssonfrastrid-nilson-photo-moi-ok-cropped-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/astrid-nilsson/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 70654229418,
size: 0.5,
source: 70654,
target: 229418 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 164842) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 70654164842,
size: 0.5,
source: 70654,
target: 164842 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 220035,
label: 'Zografoula Vagena',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2024/02/research_pasteur-enzografoula-vagenafrzografoula-vagena-screenshot-2024-08-12-at-22.37.58-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/zografoula-vagena/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 70654220035,
size: 0.5,
source: 70654,
target: 220035 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 164837) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 70654164837,
size: 0.5,
source: 70654,
target: 164837 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 155894,
label: 'Francesca Raimondi',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2021/03/research_pasteur-francesca-raimondi-img-1371-002-150x150.jpeg',
page_url: 'https://research.pasteur.fr/en/member/francesca-raimundi/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 70654155894,
size: 0.5,
source: 70654,
target: 155894 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 191231,
label: 'Robin Cremese',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2022/11/research_pasteur-robin-cremese-research-pasteur-robin-cremese-screenshot-2024-02-13-at-00.26.29-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/robin-cremese/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 70654191231,
size: 0.5,
source: 70654,
target: 191231 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 229422,
label: 'Eleonore Bouchereau',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2024/08/research_pasteur-eneleonore-bouchereaufreleonore-bouchereau-research-pasteur-eneleonore-bouchereaufreleonore-bouchereau-screenshot-2024-08-12-at-22.36.03-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/eleonore-bouchereau/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 70654229422,
size: 0.5,
source: 70654,
target: 229422 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 220019,
label: 'Iwan Quemada',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2024/02/research_pasteur-eniwan-quemadafriwan-quemada-inria-0474-185-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/iwan-quemada/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 70654220019,
size: 0.5,
source: 70654,
target: 220019 });
//check if content already exist
if (x_node<0){
x_site = x_node + ((Math.random() * 2)-1) - offset_left;
}else{
x_site = x_node + ((Math.random() * 2)-1) + offset_left;
}
if (y_node<0){
y_site = y_node + ((Math.random() * 2)-1) - offset_left;
}else{
y_site = y_node + ((Math.random() * 2)-1) + offset_left;
}
// adding site
g.nodes.push({
id: 2489,
label: 'David DiGregorio',
type: 'image',
url: 'https://research.pasteur.fr/wp-content/uploads/2015/03/david-protrait-2011-150x150.jpg',
page_url: 'https://research.pasteur.fr/en/member/david-digregorio/',
x: x_site,
y: y_site,
size: 10,
color: '#dddddd'
});
//link to content
g.edges.push({
id: 706542489,
size: 0.5,
source: 70654,
target: 2489 });
//check if content already exist
// update node size depending on the amount of edges
g.nodes.forEach(function(n) {
if (n.id == 50133) {
n.size = n.size + 8;
}
});
//link to content
g.edges.push({
id: 7065450133,
size: 0.5,
source: 70654,
target: 50133 });
var s = new sigma({
//container: document.getElementById('graph-main'),
graph: g,
renderer: {
// IMPORTANT:
// This works only with the canvas renderer, so the
// renderer type set as "canvas" is necessary here.
container: document.getElementById('graph-main'),
type: 'canvas'
},
settings: {
minNodeSize: 6,
maxNodeSize: 35,
mouseWheelEnabled: false,
font: 'Montserrat',
labelThreshold:25,
borderSize:1,
defaultNodeBorderColor: '#999',
sideMargin:25,
}
});
// We first need to save the original colors of our
// nodes and edges, like this:
s.graph.nodes().forEach(function(n) {
n.originalColor = n.color;
});
s.graph.edges().forEach(function(e) {
e.originalColor = e.color;
});
// When a node is clicked, we check for each node
// if it is a neighbor of the clicked one. If not,
// we set its color as grey, and else, it takes its
// original color.
// We do the same for the edges, and we only keep
// edges that have both extremities colored.
s.bind('clickNode', function(e) {
var nodeId = e.data.node.id,
toKeep = s.graph.neighbors(nodeId);
toKeep[nodeId] = e.data.node;
s.graph.nodes().forEach(function(n) {
if (toKeep[n.id])
n.color = '#35a9f5';
else
n.color = '#dddddd';
});
s.graph.edges().forEach(function(e) {
if (toKeep[e.source] && toKeep[e.target])
e.color = '#35a9f5';
else
e.color = '#dddddd';
});
// Since the data has been modified, we need to
// call the refresh method to make the colors
// update effective.
s.refresh();
});
// When the stage is clicked, we just color each
// node and edge with its original color.
s.bind('clickStage', function(e) {
s.graph.nodes().forEach(function(n) {
n.color = n.originalColor;
});
s.graph.edges().forEach(function(e) {
e.color = e.originalColor;
});
// Same as in the previous event:
s.refresh();
});
s.bind("doubleClickNode", function (e) {
$("#canvas-wrap, .sigma-scene, .sigma-mouse").val();
ajax_load_page( e.data.node.page_url );
});
var c = s.camera;
s.bind("rightClickStage", function (e) {
sigma.misc.animation.camera(c, {
ratio: c.ratio * c.settings('zoomingRatio')
}, {
duration: 200
});
});
// Configure the noverlap layout:
var noverlapListener = s.configNoverlap({
nodeMargin: 10,
scaleNodes: 0.3,
gridSize: 1,
easing: 'quadraticInOut', // animation transition function
duration: 4000 // animation duration. Long here for the purposes of this example only
});
// Bind the events:
noverlapListener.bind('start stop interpolate', function(e) {
//console.log(e.type);
if(e.type === 'start') {
//console.time('noverlap');
}
if(e.type === 'interpolate') {
//console.timeEnd('noverlap');
}
});
// Start the layout:
s.startNoverlap();
//s.refresh();
// Initialize the dragNodes plugin:
var dragListener = sigma.plugins.dragNodes(s, s.renderers[0]);
dragListener.bind('startdrag', function(event) {
});
dragListener.bind('drag', function(event) {
});
dragListener.bind('drop', function(event) {
});
dragListener.bind('dragend', function(event) {
});