main.js 1.34 KB
Newer Older
1 2 3
// Adjust nodes overlapping
sigma.settings.nodesPowRatio = 0.3;
sigma.settings.edgesPowRatio = 0.3;
4 5 6 7 8 9 10 11 12 13 14 15 16
// Add a method to the graph model that returns an
// object with every neighbors of a node inside:
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;
});

17
// We store all the img urls in an array to load them before displaying avatars
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
18
var tab_urls = [],
19 20 21
	renderer = {
			container: 'graph-container',
			type: 'canvas',
22
			camera: 'cam1'
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
23 24
  },
  settings = {
25 26
		minNodeSize: 5,
		maxNodeSize: 30,
27 28
		enableEdgeHovering: true,
		edgeHoverSizeRatio: 5,
29 30 31 32
		edgeColor: "default",
		defaultEdgeColor: "rgba(20,25,28,1)",
		hideEdgesOnMove:true,
		drawLabels: false,
33
		drawEdges: false,
34 35 36 37 38
		minArrowSize: 8,
		labelThreshold: 20,
		labelSize: "proportional",
		labelSizeRatio: 0.6,
		defaultLabelColor: "rgba(255,255,255,1)",
39
		animationsTime: 3500,
40
		zoomingRatio: 1.5
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
41
  },
42
  json_url = 'data/wot.json';
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
43

44
loadJSON(json_url, function(response) {
45
	var actual_JSON = JSON.parse(response);
46

47 48 49
	actual_JSON.nodes.forEach(function(n){
		if (!isInArray(tab_urls,n.url)){
			tab_urls.push(n.url);
50
		}
51
	});
52 53 54 55 56 57 58 59 60 61
	
	// Instantiate sigma:
	sigma.parsers.json(
		json_url, 
		{
			renderer: renderer,
			settings: settings
		},
		displayGraph
	);
62
});