#14; Intégration des graphiques dans le site 'charts/phone'

This commit is contained in:
xdrm-brackets 2016-05-23 11:10:24 +02:00
parent 94d91d479e
commit 3b4a0565a1
32 changed files with 123 additions and 25090 deletions

View File

@ -92,6 +92,10 @@
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
var_dump( array_keys($db->index()));
$db->close();
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
var_dump( array_keys($db->index()));
$db->close();
$req = new ModuleRequest('chart/direction', array( 'subject' => 273 ));
$res = $req->dispatch();

View File

@ -1,39 +0,0 @@
{
"root": "/var/www/socioview",
"permissions": {
"public": { "chown": "xdrm:www-data", "chmod": 750 },
"private": { "chown": "xdrm:xdrm", "chmod": 700, ".htaccess": "Order deny,allow\nDeny from all" },
"phponly": { "chown": "xdrm:www-data", "chmod": 770, ".htaccess": "Order deny,allow\nDeny from all" },
"php": { "chown": "xdrm:www-data", "chmod": 770 }
},
"files": {
"permissions": "public",
".git": { "permissions": "private" },
"config": { "permissions": "private" },
"manager": { "permissions": "private" },
"src": {
"permissions": "phponly",
"static": "public"
},
"tmp": {
"permissions": "php"
},
".htaccess": { "permissions": "private" }
}
}

View File

@ -1,10 +0,0 @@
function sociogramClass(a){this.container=a;this.log("sociogram created")}
sociogramClass.prototype={container:this.container,sigma:null,request:{path:"chart/network_data"},response:null,nodes:[],edges:[],rad:500,nodeDistance:100,overloadGraph:function(){},load:function(){},nodeAt:function(a,b){},arrange:function(a,b,d){},extractNodesFromResponse:function(){},extractEdgesFromResponse:function(){},renderNodes:function(){},renderEdges:function(){},overload:{nodeNeighbors:function(a){},nodeDirectNeighbors:function(a){}},bindings:{clickNode:function(a,b){},clickStage:function(a,
b){}},log:function(a){console.log("--[SOCIOGRAM]--");console.warn(a);console.log("--[/SOCIOGRAM]--")}};sociogramClass.prototype.overloadGraph=function(){sigma.classes.graph.addMethod("nodeNeighbors",this.overload.nodeNeighbors);sigma.classes.graph.addMethod("nodeDirectNeighbors",this.overload.nodeDirectNeighbors);this.log("graph overloaded")};
sociogramClass.prototype.load=function(){this.sigma=new sigma({renderer:{container:this.container,type:"canvas"}});var a=this;api.send(this.request,function(b){a.log(b);0==b.ModuleError&&(a.response=b,a.sigma.settings({defaultNodeColor:"#348ed8",defaultLabelSize:14,defaultLabelBGColor:"#ddd",defaultHoverLabelBGColor:"#002147",defaultLabelHoverColor:"#fff",labelThreshold:10,defaultEdgeType:"line"}),a.extractNodesFromResponse(),a.extractEdgesFromResponse(),a.addNodes(),a.addEdges(),a.sigma.bind("clickNode",
function(b){a.bindings.clickNode(a,b)}),a.sigma.bind("clickStage",function(b){a.bindings.clickStage(a,b)}),a.sigma.graph.nodes().forEach(function(b){a.arrange(b.id,null,!0)}),a.sigma.camera.ratio=1.2,a.sigma.refresh())})};sociogramClass.prototype.nodeAt=function(a,b){var d=this.sigma.graph.nodes(),c=null,e;for(e in d){var f=Math.sqrt(Math.pow(a-d[e].x,2)+Math.pow(b-d[e].y,2));if(null==c||f<c)c=f}return c};
sociogramClass.prototype.arrange=function(a,b,d){var c=this.sigma.graph.nodes(a);if(0==c.x&&0==c.y){b=null==b?{x:c.x,y:c.y}:b;if(d)for(;this.nodeAt(b.x,b.y)<2*this.nodeDistance;)b={x:b.x+2*this.nodeDistance*Math.cos(2*Math.random()*Math.PI),y:b.y+2*this.nodeDistance*Math.sin(2*Math.random()*Math.PI)};d=this.sigma.graph.nodeDirectNeighbors(a);a={};var e=0,f;for(f in d)a[f]=this.sigma.graph.nodes(f),e++;c.x=b.x;c.y=b.y;c=[];for(f in a)if(a=this.sigma.graph.nodes(f),0==a.x&&0==a.y){e=!1;do{d=2*Math.random()*
Math.PI;for(var g=0;g<c.length;g++)if(Math.abs(d-c[g])>Math.PI/10){e=!0;break}}while(e);a.x=b.x+this.nodeDistance*Math.cos(d);a.y=b.y+this.nodeDistance*Math.sin(d);this.arrange(a.id)}this.sigma.refresh()}};sociogramClass.prototype.overload.nodeNeighbors=function(a){a=this.allNeighborsIndex[a];var b=[],d;for(d in a)b.push(d);for(;0<b.length;){d=this.allNeighborsIndex[b[0]];for(var c in d)null==a[c]&&(b.push(c),a[c]=d[c]);b.shift()}return a};sociogramClass.prototype.overload.nodeDirectNeighbors=function(a){return this.allNeighborsIndex[a]};
sociogramClass.prototype.extractNodesFromResponse=function(){this.nodes=[];for(var a=0;a<this.response.data.alter.length;a++)this.nodes.push({id:"n-"+this.response.data.alter[a][0],label:this.response.data.alter[a][1],x:0,y:0,size:this.response.data.alter[a][2]})};
sociogramClass.prototype.extractEdgesFromResponse=function(){this.edges=[];for(var a=0;a<this.response.data.inter.length;a++)this.edges.push({id:"e-"+this.response.data.inter[a][0]+"-"+this.response.data.inter[a][1],source:"n-"+this.response.data.inter[a][0],target:"n-"+this.response.data.inter[a][1]})};sociogramClass.prototype.addNodes=function(){for(var a=0;a<this.nodes.length;a++)this.sigma.graph.addNode(this.nodes[a])};sociogramClass.prototype.addEdges=function(){for(var a=0;a<this.edges.length;a++)this.sigma.graph.addEdge(this.edges[a])};
sociogramClass.prototype.bindings.clickNode=function(a,b){console.log(a);var d=b.data.node.id,c=a.sigma.graph.nodeNeighbors(d);c[d]=b.data.node;a.sigma.graph.nodes().forEach(function(a){a.color=null!=c[a.id]?a.originalColor:"#888"});a.sigma.refresh()};sociogramClass.prototype.bindings.clickStage=function(a,b){a.sigma.graph.nodes().forEach(function(a){a.color=a.originalColor});a.sigma.refresh()};

View File

@ -1,558 +0,0 @@
/* Gestion du SOCIOGRAMME SPATIAL
*
* [1] - Récupération du conteneur (élément du DOM/HTML)
* [2] - Construction de la classe (objet type)
* [3] - Construction de l'objet SIGMA
* [4] - Récupération des données
* [5] - Paramétrage de SIGMA
* [6] - On extrait les noeuds/liens des données reçues
* [7] - On ajoute les noeuds/liens à SIGMA
* [8] - On positionne le tout dans l'espace
* [9] - On bind() les évènements
* [10]- On affiche le rendu
*
*/
/* [1] Récupération du conteneur
======================================*/
function sociogramClass(container){
this.container = container;
this.log('sociogram created');
}
/* [2] Construction de la classe
======================================*/
sociogramClass.prototype = {
container: this.container,
sigma: null,
request: { path: 'chart/network_data' },
response: null,
nodes: [],
edges: [],
rad: 500,
nodeDistance: 100,
/* (0) Ajout de méthodes à @this.sigma.graph */
overloadGraph: function(){},
/* (1) Point d'amorçage */
load: function(){},
/* (2) Retourne la distance avec le noeud le plus près de la position (@x, @y) */
nodeAt: function(x, y){},
/* (3) Positionnement spatial d'un noeud d'id @nodeId à une position @pos(x,y) */
arrange: function(nodeId, pos, alone){},
/* (4) Extraction de des @this.nodes depuis @this.response */
extractNodesFromResponse: function(){},
/* (5) Extraction de des @this.edges depuis @this.response */
extractEdgesFromResponse: function(){},
/* (6) Ajout des noeuds @this.nodes au rendu */
renderNodes: function(){},
/* (7) Ajout des liens @this.edges au rendu */
renderEdges: function(){},
/* (8) Ajout des fonctions dans @this.sigma.graph */
overload: {
// {1} Renvoie la liste des voisins directs et indirects du noeud d'id @nodeId //
nodeNeighbors: function(nodeId){},
// {2} Renvoie la liste des voisins directs du noeud d'id @nodeId //
nodeDirectNeighbors: function(nodeId){}
},
/* (9) Fonctions de callback pour les évènements */
bindings: {
// {1} Action quand on clique sur un noeud //
clickNode: function(thisPtr, e){},
// {2} Action quand on clique dans le vide //
clickStage: function(thisPtr, e){}
},
log: function(message){
console.log('--[SOCIOGRAM]--');
console.warn(message);
console.log('--[/SOCIOGRAM]--');
}
};
/* SURCHARGE DU GRAPH (@this.sigma.graph) -> Ajout de méthodes
*
*/
sociogramClass.prototype.overloadGraph = function(){
sigma.classes.graph.addMethod('nodeNeighbors', this.overload.nodeNeighbors);
sigma.classes.graph.addMethod('nodeDirectNeighbors', this.overload.nodeDirectNeighbors);
this.log('graph overloaded');
};
/* (1) Point d'amorçage */
sociogramClass.prototype.load = function(){
// {1} On instancie SIGMA //
this.sigma = new sigma({ renderer: { container: this.container, 'type': 'canvas' } });
var thisPtr = this;
// {2} On récupère les données via l'API //
api.send(this.request, function(response){
thisPtr.log(response);
// Si erreur, on quitte
if( response.ModuleError != 0 ) return;
// On enregistre la réponse
thisPtr.response = response;
// {3} On paramètre SIGMA //
thisPtr.sigma.settings({
defaultNodeColor: '#348ed8',
defaultLabelSize: 14,
defaultLabelBGColor: "#ddd",
defaultHoverLabelBGColor: "#002147",
defaultLabelHoverColor: "#fff",
labelThreshold: 10,
defaultEdgeType: "line"
});
// {4} On recupere les noeuds et les liens //
thisPtr.extractNodesFromResponse();
thisPtr.extractEdgesFromResponse();
// {5} On ajoute les noeuds et les liens au rendu //
thisPtr.addNodes();
thisPtr.addEdges();
// {6} On définit les évènements //
// On affiche que les voisins d'un noeud quand on clique sur lui
thisPtr.sigma.bind('clickNode', function(e){
thisPtr.bindings.clickNode(thisPtr, e);
});
// On affiche tous les noeuds quand on clique dans le vide
thisPtr.sigma.bind('clickStage', function(e){
thisPtr.bindings.clickStage(thisPtr, e);
});
// {7} On positionne spatialement les noeuds //
thisPtr.sigma.graph.nodes().forEach(function(n){ thisPtr.arrange(n.id, null, true); });
// {8} On affiche le rendu //
thisPtr.sigma.camera.ratio = 1.2;
thisPtr.sigma.refresh();
});
};
/* RETOURNE LA DISTANCE AVEC LE NOEUD LE PLUS PRES
*
* @x<float> Abscisse du point
* @y<float> Ordonnees du point
*
* @return distance<float> Retourne la distance du noeud le plus proche
*
*/
sociogramClass.prototype.nodeAt = function(x, y){
var nodes = this.sigma.graph.nodes();
var minDistance = null;
for( var nodeId in nodes ){
var distance = Math.sqrt( Math.pow(x-nodes[nodeId].x, 2) + Math.pow(y-nodes[nodeId].y, 2) );
if( minDistance == null || distance < minDistance )
minDistance = distance;
}
return minDistance;
};
/* POSITIONNE LES VOISINS AUTOUR DU NOEUD COURANT
*
* @nodeId<String> Id du noeud courant
* @pos<Object> Contient {x, y} position initiale, sinon la position actuelle du noeud
*
*/
sociogramClass.prototype.arrange = function(nodeId, pos, alone){
var node = this.sigma.graph.nodes(nodeId);
// Si le noeud est deja place, on ne fais rien
if( node.x != 0 || node.y != 0 ) return;
pos = (pos==null) ? {x: node.x, y: node.y} : pos; // On recupere la position
// Tant que le noeud est trop proche d'un autre, on l'eloigne
// UNIQUEMENT si alone n'est pas NULL
if( alone ){
while( this.nodeAt(pos.x, pos.y) < 2*this.nodeDistance ){
pos = {
x: pos.x + 2*this.nodeDistance*Math.cos(Math.random()*2*Math.PI),
y: pos.y + 2*this.nodeDistance*Math.sin(Math.random()*2*Math.PI)
};
}
}
// On recupere les voisins directs
var neighborsId = this.sigma.graph.nodeDirectNeighbors(nodeId);
var neighbors = {};
var neighborsCount = 0;
for( var neighborId in neighborsId ){
neighbors[neighborId] = this.sigma.graph.nodes(neighborId);
neighborsCount++;
}
// On positionne le noeud
node.x = pos.x;
node.y = pos.y;
var angles = [];
// On positionne chaque voisin si c'est pas deja fait
for( neighborId in neighbors ){
var current = this.sigma.graph.nodes(neighborId);
// Si n'est pas deja positionne
if( current.x == 0 && current.y == 0 ){
// On cherche un angle tant qu'il est pas trop pres d'un deja pris
var angle, alreadyUsed = false;
do{
angle = Math.random()*2*Math.PI;
for( var i = 0 ; i < angles.length ; i++ )
if( Math.abs(angle-angles[i]) > Math.PI/10 ){
alreadyUsed = true;
break;
}
}while( alreadyUsed );
current.x = pos.x + this.nodeDistance*Math.cos(angle);
current.y = pos.y + this.nodeDistance*Math.sin(angle);
this.arrange(current.id);
}
}
this.sigma.refresh();
};
/* RENVOIE LA LISTE DES VOISINS (DIRECTS & INDIRECTS) D'UN NOEUD DONNÉ
*
* @nodeId<String> Id du noeud en question
*
* @return neighbors<array> Liste des voisins directs+indirects
*
*/
sociogramClass.prototype.overload.nodeNeighbors = function(nodeId){
var neighbors = this.allNeighborsIndex[nodeId];
// Pile des voisins pour lesquels il faut chercher leurs voisins
var stack = [];
for( var neighborId in neighbors ) stack.push(neighborId);
// Tant qu'il reste des voisins a trouver
while( stack.length > 0 ){
var subneighbors = this.allNeighborsIndex[stack[0]];
for( var subId in subneighbors )
// Si le voisin est pas deja dans la liste/pile, on l'ajoute a la liste des voisins
if( neighbors[subId] == null ){
stack.push(subId); // On ajoute a la pile
neighbors[subId] = subneighbors[subId]; // On ajoute a la liste complete
}
stack.shift();
}
// On retourne le resultat
return neighbors;
};
/* RENVOIE LA LISTE DES VOISINS DIRECTS D'UN NOEUD DONNÉ
*
* @nodeId<String> Id du noeud en question
*
* @return neighbors<array> Liste des voisins directs
*
*/
sociogramClass.prototype.overload.nodeDirectNeighbors = function(nodeId){
return this.allNeighborsIndex[nodeId];
};
/* EXTRAIT LES NOEUDS DE LA RÉPONSE DE L'API
*
*/
sociogramClass.prototype.extractNodesFromResponse = function(){
this.nodes = [];
// Pour chaque alter
for( var i = 0 ; i < this.response.data.alter.length ; i++ )
this.nodes.push({
'id': 'n-'+this.response.data.alter[i][0],
'label': this.response.data.alter[i][1],
'x': 0,
'y': 0,
'size': this.response.data.alter[i][2]
});
};
/* EXTRAIT LES NOEUDS DE LA RÉPONSE DE L'API
*
*/
sociogramClass.prototype.extractEdgesFromResponse = function(){
this.edges = [];
// Pour chaque inter
for( var i = 0 ; i < this.response.data.inter.length ; i++ )
this.edges.push({
'id': 'e-'+this.response.data.inter[i][0]+'-'+this.response.data.inter[i][1],
'source': 'n-'+this.response.data.inter[i][0],
'target': 'n-'+this.response.data.inter[i][1]
});
};
/* AJOUTE LES NOEUDS AU RENDU (SIGMA GRAPH)
*
*/
sociogramClass.prototype.addNodes = function(){
/* (5) On ajoute nos noeuds */
for( var i = 0 ; i < this.nodes.length ; i++)
this.sigma.graph.addNode(this.nodes[i]);
};
/* AJOUTE LES LIENS AU RENDU (SIGMA GRAPH)
*
*/
sociogramClass.prototype.addEdges = function(){
/* (6) On ajoute nos liens */
for( var i = 0 ; i < this.edges.length ; i++)
this.sigma.graph.addEdge(this.edges[i]);
};
/* FONCTION ACTIVÉE LORS DU CLIC SUR UN NOEUD
*
*/
sociogramClass.prototype.bindings.clickNode = function(thisPtr, e){
console.log( thisPtr );
var nodeId = e.data.node.id;
// On recupere les voisins
var neighborNodes = thisPtr.sigma.graph.nodeNeighbors(nodeId);
neighborNodes[nodeId] = e.data.node; // on ajoute le noeud clique
thisPtr.sigma.graph.nodes().forEach(function(n) {
if( neighborNodes[n.id] != null ) n.color = n.originalColor;
else n.color = '#888';
});
thisPtr.sigma.refresh();
};
/* FONCTION ACTIVÉE LORS DU CLIC DANS LE VIDE
*
*/
sociogramClass.prototype.bindings.clickStage = function(thisPtr, e){
thisPtr.sigma.graph.nodes().forEach(function(n){ n.color = n.originalColor; });
thisPtr.sigma.refresh();
};
// var i,
// s,
// o,
// L = 10,
// N = 100,
// E = 500,
// g = {
// nodes: [],
// edges: []
// },
// step = 0;
// // Generate a random graph:
// for (i = 0; i < N; i++) {
// o = {
// id: 'n' + i,
// label: 'Node ' + i,
// circular_x: L * Math.cos(Math.PI * 2 * i / N - Math.PI / 2),
// circular_y: L * Math.sin(Math.PI * 2 * i / N - Math.PI / 2),
// circular_size: Math.random(),
// circular_color: '#' + (
// Math.floor(Math.random() * 16777215).toString(16) + '000000'
// ).substr(0, 6),
// grid_x: i % L,
// grid_y: Math.floor(i / L),
// grid_size: 1,
// grid_color: '#ccc'
// };
// ['x', 'y', 'size', 'color'].forEach(function(val) {
// o[val] = o['grid_' + val];
// });
// g.nodes.push(o);
// }
// for (i = 0; i < E; i++)
// g.edges.push({
// id: 'e' + i,
// source: 'n' + (Math.random() * N | 0),
// target: 'n' + (Math.random() * N | 0),
// });
// // Instantiate sigma:
// s = new sigma({
// graph: g,
// renderer: { container: document.getElementById('graph-container'), 'type': 'canvas' },
// settings: {
// animationsTime: 1000
// }
// });
// setInterval(function(){
// var prefix = ['grid_', 'circular_'][step = +!step];
// sigma.plugins.animate(
// s,
// {
// x: prefix + 'x',
// y: prefix + 'y',
// size: prefix + 'size',
// color: prefix + 'color'
// }
// );
// }, 10000);

View File

@ -1,35 +0,0 @@
[![Build Status](https://travis-ci.org/jacomyal/sigma.js.svg)](https://travis-ci.org/jacomyal/sigma.js)
sigma.js - v1.1.0
=================
Sigma is a JavaScript library dedicated to graph drawing, mainly developed by [@jacomyal](https://github.com/jacomyal) and [@Yomguithereal](https://github.com/Yomguithereal).
### Resources
[The website](http://sigmajs.org) provides a global overview of the project, and the documentation is available in the [Github Wiki](https://github.com/jacomyal/sigma.js/wiki).
Also, the `plugins` and `examples` directories contain various use-cases that might help you understand how to use sigma.
### How to use it
To use it, clone the repository:
```
git clone git@github.com:jacomyal/sigma.js.git
```
To build the code:
- Install [Node.js](http://nodejs.org/).
- Install [gjslint](https://developers.google.com/closure/utilities/docs/linter_howto?hl=en).
- Use `npm install` to install sigma development dependencies.
- Use `npm run build` to minify the code with [Uglify](https://github.com/mishoo/UglifyJS). The minified file `sigma.min.js` will then be accessible in the `build/` folder.
Also, you can customize the build by adding or removing files from the `coreJsFiles` array in `Gruntfile.js` before applying the grunt task.
### Contributing
You can contribute by submitting [issues tickets](http://github.com/jacomyal/sigma.js/issues) and proposing [pull requests](http://github.com/jacomyal/sigma.js/pulls). Make sure that tests and linting pass before submitting any pull request by running the command `grunt`.
The whole source code is validated by the [Google Closure Linter](https://developers.google.com/closure/utilities/) and [JSHint](http://www.jshint.com/), and the comments are written in [JSDoc](http://en.wikipedia.org/wiki/JSDoc) (tags description is available [here](https://developers.google.com/closure/compiler/docs/js-for-compiler)).

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.parsers"),sigma.utils.pkg("sigma.utils"),sigma.utils.xhr=function(){if(window.XMLHttpRequest)return new XMLHttpRequest;var a,b;if(window.ActiveXObject){a=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];for(b in a)try{return new ActiveXObject(a[b])}catch(c){}}return null},sigma.parsers.json=function(a,b,c){var d,e=sigma.utils.xhr();if(!e)throw"XMLHttpRequest not supported, cannot load the file.";e.open("GET",a,!0),e.onreadystatechange=function(){4===e.readyState&&(d=JSON.parse(e.responseText),b instanceof sigma?(b.graph.clear(),b.graph.read(d)):"object"==typeof b?(b.graph=d,b=new sigma(b)):"function"==typeof b&&(c=b,b=null),c&&c(b||d))},e.send()}}).call(this);

View File

@ -1 +0,0 @@
(function(){"use strict";function a(a){if(d[a])return d[a];var b=[0,0,0];return a.match(/^#/)?(a=(a||"").replace(/^#/,""),b=3===a.length?[parseInt(a.charAt(0)+a.charAt(0),16),parseInt(a.charAt(1)+a.charAt(1),16),parseInt(a.charAt(2)+a.charAt(2),16)]:[parseInt(a.charAt(0)+a.charAt(1),16),parseInt(a.charAt(2)+a.charAt(3),16),parseInt(a.charAt(4)+a.charAt(5),16)]):a.match(/^ *rgba? *\(/)&&(a=a.match(/^ *rgba? *\( *([0-9]*) *, *([0-9]*) *, *([0-9]*) *(,.*)?\) *$/),b=[+a[1],+a[2],+a[3]]),d[a]={r:b[0],g:b[1],b:b[2]},d[a]}function b(b,c,d){b=a(b),c=a(c);var e={r:b.r*(1-d)+c.r*d,g:b.g*(1-d)+c.g*d,b:b.b*(1-d)+c.b*d};return"rgb("+[0|e.r,0|e.g,0|e.b].join(",")+")"}if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.plugins");var c=0,d={};sigma.plugins.animate=function(a,d,e){function f(){var c=(sigma.utils.dateNow()-m)/k;if(c>=1){g.forEach(function(a){for(var b in d)b in d&&(a[b]=a[d[b]])});var e,n;for(e in a.cameras)n=a.cameras[e],n.edgequadtree._enabled=!0;a.refresh(),"function"==typeof i.onComplete&&i.onComplete()}else c=l(c),g.forEach(function(a){for(var e in d)e in d&&(a[e]=e.match(/color$/)?b(h[a.id][e],a[d[e]],c):a[d[e]]*c+h[a.id][e]*(1-c))}),a.refresh(),a.animations[j]=requestAnimationFrame(f)}var g,h,i=e||{},j=++c,k=i.duration||a.settings("animationsTime"),l="string"==typeof i.easing?sigma.utils.easings[i.easing]:"function"==typeof i.easing?i.easing:sigma.utils.easings.quadraticInOut,m=sigma.utils.dateNow();g=i.nodes&&i.nodes.length?"object"==typeof i.nodes[0]?i.nodes:a.graph.nodes(i.nodes):a.graph.nodes(),h=g.reduce(function(a,b){var c;a[b.id]={};for(c in d)c in b&&(a[b.id][c]=b[c]);return a},{}),a.animations=a.animations||Object.create({}),sigma.plugins.kill(a);var n,o;for(n in a.cameras)o=a.cameras[n],o.edgequadtree._enabled=!1;f()},sigma.plugins.kill=function(a){for(var b in a.animations||{})cancelAnimationFrame(a.animations[b]);var b,c;for(b in a.cameras)c=a.cameras[b],c.edgequadtree._enabled=!0}}).call(window);

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(function(){"use strict";function a(a){return new Blob([a],{type:"image/svg+xml;charset=utf-8"})}function b(b,c){var e=a(b),f={};f.anchor=document.createElement("a"),f.anchor.setAttribute("href",d.createObjectURL(e)),f.anchor.setAttribute("download",c);var g=document.createEvent("MouseEvent");g.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),d.revokeObjectURL(e),f.anchor.dispatchEvent(g),delete f.anchor}function c(a,b,c){var d,e,g,h,i,j={},k={},l=0,m="";c.classes&&(e=document.createElementNS(f,"style"),a.insertBefore(e,a.firstChild));var n=a.querySelectorAll('[id="'+b+'-group-nodes"] > [class="'+b+'-node"]');for(h=0,i=n.length,g=!0;i>h;h++)d=n[h].getAttribute("fill"),c.data||n[h].removeAttribute("data-node-id"),c.classes&&(d in j||(j[d]=g?b+"-node":"c-"+l++,m+="."+j[d]+"{fill: "+d+"}"),j[d]!==b+"-node"&&n[h].setAttribute("class",n[h].getAttribute("class")+" "+j[d]),n[h].removeAttribute("fill")),g=!1;var o=a.querySelectorAll('[id="'+b+'-group-edges"] > [class="'+b+'-edge"]');for(h=0,i=o.length,g=!0;i>h;h++)d=o[h].getAttribute("stroke"),c.data||o[h].removeAttribute("data-edge-id"),c.classes&&(d in k||(k[d]=g?b+"-edge":"c-"+l++,m+="."+k[d]+"{stroke: "+d+"}"),k[d]!==b+"-edge"&&o[h].setAttribute("class",o[h].getAttribute("class")+" "+k[d]),o[h].removeAttribute("stroke")),g=!1;c.classes&&e.appendChild(document.createTextNode(m))}if("undefined"==typeof sigma)throw"sigma.renderers.snapshot: sigma not in scope.";var d=this.URL||this.webkitURL||this,e={size:"1000",width:"1000",height:"1000",classes:!0,labels:!0,data:!1,download:!1,filename:"graph.svg"},f="http://www.w3.org/2000/svg";sigma.prototype.toSVG=function(a){a=a||{};var d=this.settings("classPrefix"),f=a.size||a.width||e.size,g=a.size||a.height||e.size,h=document.createElement("div");h.setAttribute("width",f),h.setAttribute("height",g),h.setAttribute("style","position:absolute; top: 0px; left:0px; width: "+f+"px; height: "+g+"px;");var i=this.addCamera(),j=this.addRenderer({camera:i,container:h,type:"svg",forceLabels:!!a.labels});j.resize(f,g),this.refresh(),this.killRenderer(j),this.killCamera(i);var k=h.querySelector("svg");if(k.removeAttribute("style"),k.setAttribute("width",f+"px"),k.setAttribute("height",g+"px"),k.setAttribute("x","0px"),k.setAttribute("y","0px"),!a.labels){var l=k.querySelector('[id="'+d+'-group-labels"]');k.removeChild(l)}var m=k.querySelector('[id="'+d+'-group-hovers"]');k.removeChild(m),a.classes=a.classes!==!1,(!a.data||a.classes)&&c(k,d,a);var n=k.outerHTML;h=null;var o='<?xml version="1.0" encoding="utf-8"?>\n';return o+='<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n',o+=n,a.download&&b(o,a.filename||e.filename),o}}).call(this);

View File

@ -1 +0,0 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.neo4j"),sigma.utils.pkg("sigma.utils"),sigma.neo4j.send=function(a,b,c,d,e){var f,g,h,i=sigma.utils.xhr();if(f=a,"object"==typeof a&&(f=a.url,g=a.user,h=a.password),!i)throw"XMLHttpRequest not supported, cannot load the file.";f+=b,i.open(c,f,!0),g&&h&&i.setRequestHeader("Authorization","Basic "+btoa(g+":"+h)),i.setRequestHeader("Accept","application/json"),i.setRequestHeader("Content-type","application/json; charset=utf-8"),i.onreadystatechange=function(){4===i.readyState&&e(JSON.parse(i.responseText))},i.send(d)},sigma.neo4j.cypher_parse=function(a){var b,c={nodes:[],edges:[]},d={},e={};a.results[0].data.forEach(function(a){a.graph.nodes.forEach(function(a){var b={id:a.id,label:a.id,x:Math.random(),y:Math.random(),size:1,color:"#000000",neo4j_labels:a.labels,neo4j_data:a.properties};b.id in d||(d[b.id]=b)}),a.graph.relationships.forEach(function(a){var b={id:a.id,label:a.type,source:a.startNode,target:a.endNode,color:"#7D7C8E",neo4j_type:a.type,neo4j_data:a.properties};b.id in e||(e[b.id]=b)})});for(b in d)c.nodes.push(d[b]);for(b in e)c.edges.push(e[b]);return c},sigma.neo4j.cypher=function(a,b,c,d){var e,f,g="/db/data/transaction/commit";e=JSON.stringify({statements:[{statement:b,resultDataContents:["graph"],includeStats:!1}]}),f=function(a){return function(b){var d={nodes:[],edges:[]};d=sigma.neo4j.cypher_parse(b),c instanceof sigma?(c.graph.clear(),c.graph.read(d)):"object"==typeof c?(c=new sigma(c),c.graph.read(d),c.refresh()):"function"==typeof c&&(a=c,c=null),a&&a(c||d)}},sigma.neo4j.send(a,g,"POST",e,f(d))},sigma.neo4j.getLabels=function(a,b){sigma.neo4j.send(a,"/db/data/labels","GET",null,b)},sigma.neo4j.getTypes=function(a,b){sigma.neo4j.send(a,"/db/data/relationship/types","GET",null,b)}}).call(this);

View File

@ -1 +0,0 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.neo4j"),sigma.utils.pkg("sigma.utils"),sigma.utils.pkg("sigma.parsers"),sigma.neo4j.send=function(a,b,c,d,e){var f,g,h,i=sigma.utils.xhr();if(f=a,"object"==typeof a&&(f=a.url,g=a.user,h=a.password),!i)throw"XMLHttpRequest not supported, cannot load the file.";f+=b,i.open(c,f,!0),g&&h&&i.setRequestHeader("Authorization","Basic "+btoa(g+":"+h)),i.setRequestHeader("Accept","application/json"),i.setRequestHeader("Content-type","application/json; charset=utf-8"),i.onreadystatechange=function(){4===i.readyState&&e(JSON.parse(i.responseText))},i.send(d)},sigma.neo4j.cypher_parse=function(a){var b,c={nodes:[],edges:[]},d={},e={};a.results[0].data.forEach(function(a){a.graph.nodes.forEach(function(a){var b={id:a.id,label:a.id,x:Math.random(),y:Math.random(),size:1,color:"#000000",neo4j_labels:a.labels,neo4j_data:a.properties};b.id in d||(d[b.id]=b)}),a.graph.relationships.forEach(function(a){var b={id:a.id,label:a.type,source:a.startNode,target:a.endNode,color:"#7D7C8E",neo4j_type:a.type,neo4j_data:a.properties};b.id in e||(e[b.id]=b)})});for(b in d)c.nodes.push(d[b]);for(b in e)c.edges.push(e[b]);return c},sigma.neo4j.cypher=function(a,b,c,d){var e,f,g="/db/data/transaction/commit";e=JSON.stringify({statements:[{statement:b,resultDataContents:["graph"],includeStats:!1}]}),f=function(a){return function(b){var d={nodes:[],edges:[]};d=sigma.neo4j.cypher_parse(b),c instanceof sigma?(c.graph.clear(),c.graph.read(d)):"object"==typeof c?(c=new sigma(c),c.graph.read(d),c.refresh()):"function"==typeof c&&(a=c,c=null),a&&a(c||d)}},sigma.neo4j.send(a,g,"POST",e,f(d))},sigma.neo4j.getLabels=function(a,b){sigma.neo4j.send(a,"/db/data/labels","GET",null,b)},sigma.neo4j.getTypes=function(a,b){sigma.neo4j.send(a,"/db/data/relationship/types","GET",null,b)}}).call(this);

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";var a=function(a,b,c){var d=void 0!=a&&void 0!=b&&void 0!=a.x&&void 0!=a.y&&void 0!=b.x&&void 0!=b.y;return d?(c||0)+Math.sqrt(Math.pow(b.y-a.y,2)+Math.pow(b.x-a.x,2)):void 0};sigma.classes.graph.addMethod("astar",function(b,c,d){var e=new sigma.classes.configurable({undirected:!1,pathLengthFunction:a,heuristicLengthFunction:void 0},d||{}),f=e("pathLengthFunction"),g=e("heuristicLengthFunction")||f,h=this.nodes(b),i=this.nodes(c),j={},k=[],l=function(a,b,c,d){var e=a.id,f={pathLength:c,heuristicLength:d,node:a,nodeId:e,previousNode:b};if(void 0==j[e]||j[e].pathLenth>c){j[e]=f;var g,h;for(h=0;h<k.length&&(g=k[h],!(g.heuristicLength>d));h++);k.splice(h,0,f)}};l(h,null,0,0);var m,n=!1;m=e("undirected")?this.allNeighborsIndex:this.outNeighborsIndex;for(var o,p,q,r,s,t;k.length>0;){if(o=k.shift(),o.nodeId==c){n=!0;break}for(p=Object.keys(m[o.nodeId]),t=0;t<p.length;t++)q=this.nodes(p[t]),r=f(o.node,q,o.pathLength),s=g(q,i),l(q,o.node,r,s)}if(n){for(var u=[],v=i;v;)u.unshift(v),v=j[v.id].previousNode;return u}return void 0})}).call(window);

View File

@ -1 +0,0 @@
(function(){"use strict";function a(a,b){function c(a){var b=window.getComputedStyle(a),c=function(a){return parseInt(b.getPropertyValue(a).replace("px",""))||0};return{left:a.getBoundingClientRect().left+c("padding-left"),top:a.getBoundingClientRect().top+c("padding-top")}}function d(){t=!1,l.removeEventListener("mousemove",i),l.removeEventListener("mouseup",h),r.length||(p=null)}function e(a){s[a.data.node.id]||(r.push(a.data.node),s[a.data.node.id]=!0,r.length&&!t&&(p=r[r.length-1],n.addEventListener("mousedown",g)))}function f(a){var b=r.map(function(a){return a}).indexOf(a.data.node);r.splice(b,1),delete s[a.data.node.id],r.length&&!t?p=r[r.length-1]:n.removeEventListener("mousedown",g)}function g(a){t=!0;var b=k.graph.nodes().length;if(p&&b>1){n.removeEventListener("mousedown",g),l.addEventListener("mousemove",i),l.addEventListener("mouseup",h);var c,d;for(c in k.cameras)d=k.cameras[c],void 0!==d.edgequadtree&&(d.edgequadtree._enabled=!1);m.settings({mouseEnabled:!1,enableHovering:!1}),k.refresh(),j.dispatchEvent("startdrag",{node:p,captor:a,renderer:m})}}function h(a){t=!1,n.addEventListener("mousedown",g),l.removeEventListener("mousemove",i),l.removeEventListener("mouseup",h);var b,c;for(b in k.cameras)c=k.cameras[b],void 0!==c.edgequadtree&&(c.edgequadtree._enabled=!0);m.settings({mouseEnabled:!0,enableHovering:!0}),k.refresh(),u&&j.dispatchEvent("drop",{node:p,captor:a,renderer:m}),j.dispatchEvent("dragend",{node:p,captor:a,renderer:m}),u=!1,p=null}function i(a){function b(){for(var b=c(m.container),d=a.clientX-b.left,e=a.clientY-b.top,f=Math.cos(o.angle),g=Math.sin(o.angle),h=k.graph.nodes(),i=[],l=0;2>l;l++){var n=h[l],r={x:n.x*f+n.y*g,y:n.y*f-n.x*g,renX:n[q+"x"],renY:n[q+"y"]};i.push(r)}if(i[0].x===i[1].x&&i[0].y===i[1].y){var s=0===i[0].renX?1:i[0].renX,t=0===i[0].renY?1:i[0].renY;d=i[0].x/s*(d-i[0].renX)+i[0].x,e=i[0].y/t*(e-i[0].renY)+i[0].y}else{var s=(i[1].renX-i[0].renX)/(i[1].x-i[0].x),t=(i[1].renY-i[0].renY)/(i[1].y-i[0].y);i[1].x===i[0].x&&(s=t),i[1].y===i[0].y&&(t=s),d=(d-i[0].renX)/s+i[0].x,e=(e-i[0].renY)/t+i[0].y}p.x=d*f-e*g,p.y=e*f+d*g,k.refresh(),u=!0,j.dispatchEvent("drag",{node:p,captor:a,renderer:m})}if(navigator.userAgent.toLowerCase().indexOf("firefox")>-1){clearTimeout(d);var d=setTimeout(b,0)}else b()}sigma.classes.dispatcher.extend(this);var j=this,k=a,l=document.body,m=b,n=b.container.lastChild,o=b.camera,p=null,q="",r=[],s={},t=!1,u=!1;b instanceof sigma.renderers.svg&&(n=b.container.firstChild),q=b instanceof sigma.renderers.webgl?b.options.prefix.substr(5):b.options.prefix,b.bind("overNode",e),b.bind("outNode",f),b.bind("click",d),k.bind("kill",function(){j.unbindAll()}),this.unbindAll=function(){n.removeEventListener("mousedown",g),l.removeEventListener("mousemove",i),l.removeEventListener("mouseup",h),m.unbind("overNode",e),m.unbind("outNode",f)}}if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.plugins");var b={};sigma.plugins.dragNodes=function(c,d){return b[c.id]||(b[c.id]=new a(c,d)),c.bind("kill",function(){sigma.plugins.killDragNodes(c)}),b[c.id]},sigma.plugins.killDragNodes=function(c){b[c.id]instanceof a&&(b[c.id].unbindAll(),delete b[c.id])}}).call(window);

View File

@ -1 +0,0 @@
(function(undefined){"use strict";function register(a,b,c){if(c!=undefined&&"string"!=typeof c)throw'The filter key "'+c.toString()+'" must be a string.';if(c!=undefined&&!c.length)throw"The filter key must be a non-empty string.";if("function"!=typeof a)throw'The predicate of key "'+c+'" must be a function.';if("undo"===c)throw'"undo" is a reserved key.';if(_keysIndex[c])throw'The filter "'+c+'" already exists.';c&&(_keysIndex[c]=!0),_chain.push({key:c,processor:a,predicate:b})}function unregister(a){_chain=_chain.filter(function(b){return!(b.key in a)});for(var b in a)delete _keysIndex[b]}function Filter(a){_s=a,_g=a.graph}function deepCopy(o){var copy=Object.create(null);for(var i in o)"object"==typeof o[i]&&null!==o[i]?copy[i]=deepCopy(o[i]):"function"==typeof o[i]&&null!==o[i]?eval(" copy[i] = "+o[i].toString()):copy[i]=o[i];return copy}function cloneChain(a){for(var b=a.slice(0),c=0,d=b.length;d>c;c++)b[c]=deepCopy(b[c]),"function"==typeof b[c].processor&&(b[c].processor="filter.processors."+b[c].processor.name);return b}if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.plugins"),sigma.classes.graph.hasMethod("adjacentNodes")||sigma.classes.graph.addMethod("adjacentNodes",function(a){if("string"!=typeof a)throw"adjacentNodes: the node id must be a string.";var b,c=[];for(b in this.allNeighborsIndex[a])c.push(this.nodesIndex[b]);return c}),sigma.classes.graph.hasMethod("adjacentEdges")||sigma.classes.graph.addMethod("adjacentEdges",function(a){if("string"!=typeof a)throw"adjacentEdges: the node id must be a string.";var b,c,d=this.allNeighborsIndex[a],e=[];for(c in d)for(b in d[c])e.push(d[c][b]);return e});var _g=undefined,_s=undefined,_chain=[],_keysIndex=Object.create(null),Processors={};Processors.nodes=function(a){for(var b=_g.nodes(),c=b.length,d=_g.edges(),e=d.length;c--;)b[c].hidden=!a.call(_g,b[c])||b[c].hidden;for(;e--;)(_g.nodes(d[e].source).hidden||_g.nodes(d[e].target).hidden)&&(d[e].hidden=!0)},Processors.edges=function(a){for(var b=_g.edges(),c=b.length;c--;)b[c].hidden=!a.call(_g,b[c])||b[c].hidden},Processors.neighbors=function a(b){for(var c=_g.nodes(),d=c.length,e=_g.edges(),f=e.length,a=_g.adjacentNodes(b),g=a.length,h={};g--;)h[a[g].id]=!0;for(;d--;)c[d].id===b||c[d].id in h||(c[d].hidden=!0);for(;f--;)(_g.nodes(e[f].source).hidden||_g.nodes(e[f].target).hidden)&&(e[f].hidden=!0)},Filter.prototype.nodesBy=function(a,b){return register(Processors.nodes,a,b),this},Filter.prototype.edgesBy=function(a,b){return register(Processors.edges,a,b),this},Filter.prototype.neighborsOf=function(a,b){if("string"!=typeof a)throw'The node id "'+a.toString()+'" must be a string.';if(!a.length)throw"The node id must be a non-empty string.";return register(Processors.neighbors,a,b),this},Filter.prototype.apply=function(){for(var a=0,b=_chain.length;b>a;++a)_chain[a].processor(_chain[a].predicate);return _chain[0]&&"undo"===_chain[0].key&&_chain.shift(),_s.refresh(),this},Filter.prototype.undo=function(a){function b(){for(var a=_g.nodes(),b=a.length,c=_g.edges(),d=c.length;b--;)a[b].hidden=!1;for(;d--;)c[d].hidden=!1}var c=Object.create(null),d=arguments.length;if(1===d)if("[object Array]"===Object.prototype.toString.call(a))for(var e=0,f=a.length;f>e;e++)c[a[e]]=!0;else c[a]=!0;else if(d>1)for(var e=0;d>e;e++)c[arguments[e]]=!0;else this.clear();return unregister(c),_chain.unshift({key:"undo",processor:b}),this},Filter.prototype.clear=function(){return _chain.length=0,_keysIndex=Object.create(null),this},Filter.prototype.export=function(){var a=cloneChain(_chain);return a},Filter.prototype.import=function(a){if(a===undefined)throw"Wrong arguments.";if("[object Array]"!==Object.prototype.toString.call(a))throw'The chain" must be an array.';for(var b=cloneChain(a),c=0,d=b.length;d>c;c++){if(b[c].predicate===undefined||b[c].processor===undefined)throw"Wrong arguments.";if(b[c].key!=undefined&&"string"!=typeof b[c].key)throw'The filter key "'+b[c].key.toString()+'" must be a string.';if("function"!=typeof b[c].predicate)throw'The predicate of key "'+b[c].key+'" must be a function.';if("string"!=typeof b[c].processor)throw'The processor of key "'+b[c].key+'" must be a string.';switch(b[c].processor){case"filter.processors.nodes":b[c].processor=Processors.nodes;break;case"filter.processors.edges":b[c].processor=Processors.edges;break;case"filter.processors.neighbors":b[c].processor=Processors.neighbors;break;default:throw"Unknown processor "+b[c].processor}}return _chain=b,this};var filter=null;sigma.plugins.filter=function(a){return filter||(filter=new Filter(a)),filter}}).call(this);

View File

@ -1 +0,0 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.classes.graph.addMethod("neighborhood",function(a){var b,c,d,e,f,g={},h={},i={nodes:[],edges:[]};if(!this.nodes(a))return i;e=this.nodes(a),f={},f.center=!0;for(b in e)f[b]=e[b];g[a]=!0,i.nodes.push(f);for(b in this.allNeighborsIndex[a]){g[b]||(g[b]=!0,i.nodes.push(this.nodesIndex[b]));for(c in this.allNeighborsIndex[a][b])h[c]||(h[c]=!0,i.edges.push(this.edgesIndex[c]))}for(b in g)if(b!==a)for(c in g)if(c!==a&&b!==c&&this.allNeighborsIndex[b][c])for(d in this.allNeighborsIndex[b][c])h[d]||(h[d]=!0,i.edges.push(this.edgesIndex[d]));return i}),sigma.utils.pkg("sigma.plugins"),sigma.plugins.neighborhoods=function(){var a=new sigma.classes.graph;this.neighborhood=function(b){return a.neighborhood(b)},this.load=function(b,c){var d=function(){if(window.XMLHttpRequest)return new XMLHttpRequest;var a,b;if(window.ActiveXObject){a=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];for(b in a)try{return new ActiveXObject(a[b])}catch(c){}}return null}();if(!d)throw"XMLHttpRequest not supported, cannot load the data.";return d.open("GET",b,!0),d.onreadystatechange=function(){4===d.readyState&&(a.clear().read(JSON.parse(d.responseText)),c&&c())},d.send(),this},this.read=function(b){a.clear().read(b)}}}).call(window);

View File

@ -1 +0,0 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.plugins");sigma.plugins.relativeSize=function(a,b){for(var c=a.graph.nodes(),d=0;d<c.length;d++){var e=a.graph.degree(c[d].id);c[d].size=b*Math.sqrt(e)}a.refresh()}}).call(window);

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.settings");var a={defaultEdgeLabelColor:"#000",defaultEdgeLabelActiveColor:"#000",defaultEdgeLabelSize:10,edgeLabelSize:"fixed",edgeLabelSizePowRatio:1,edgeLabelThreshold:1};sigma.settings=sigma.utils.extend(sigma.settings||{},a),sigma.settings.drawEdgeLabels=!0}).call(this),function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.canvas.edges.labels"),sigma.canvas.edges.labels.curve=function(a,b,c,d,e){if("string"==typeof a.label){var f=e("prefix")||"",g=a[f+"size"]||1;if(!(g<e("edgeLabelThreshold"))){var h,i,j,k=b[f+"size"],l=b[f+"x"],m=b[f+"y"],n=c[f+"x"],o=c[f+"y"],p=n-l,q=o-m,r=n>l?1:-1,s={},t=.5;b.id===c.id?(s=sigma.utils.getSelfLoopControlPoints(l,m,k),i=sigma.utils.getPointOnBezierCurve(t,l,m,n,o,s.x1,s.y1,s.x2,s.y2),j=Math.atan2(1,1)):(s=sigma.utils.getQuadraticControlPoint(l,m,n,o),i=sigma.utils.getPointOnQuadraticCurve(t,l,m,n,o,s.x,s.y),j=Math.atan2(q*r,p*r)),h="fixed"===e("edgeLabelSize")?e("defaultEdgeLabelSize"):e("defaultEdgeLabelSize")*g*Math.pow(g,-1/e("edgeLabelSizePowRatio")),d.save(),a.active?(d.font=[e("activeFontStyle"),h+"px",e("activeFont")||e("font")].join(" "),d.fillStyle="edge"===e("edgeActiveColor")?a.active_color||e("defaultEdgeActiveColor"):e("defaultEdgeLabelActiveColor")):(d.font=[e("fontStyle"),h+"px",e("font")].join(" "),d.fillStyle="edge"===e("edgeLabelColor")?a.color||e("defaultEdgeColor"):e("defaultEdgeLabelColor")),d.textAlign="center",d.textBaseline="alphabetic",d.translate(i.x,i.y),d.rotate(j),d.fillText(a.label,0,-g/2-3),d.restore()}}}}.call(this),function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.canvas.edges.labels"),sigma.canvas.edges.labels.curvedArrow=function(a,b,c,d,e){sigma.canvas.edges.labels.curve(a,b,c,d,e)}}.call(this),function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.canvas.edges.labels"),sigma.canvas.edges.labels.def=function(a,b,c,d,e){if("string"==typeof a.label&&b!=c){var f=e("prefix")||"",g=a[f+"size"]||1;if(!(g<e("edgeLabelThreshold"))){if(0===e("edgeLabelSizePowRatio"))throw'"edgeLabelSizePowRatio" must not be 0.';var h,i=(b[f+"x"]+c[f+"x"])/2,j=(b[f+"y"]+c[f+"y"])/2,k=c[f+"x"]-b[f+"x"],l=c[f+"y"]-b[f+"y"],m=b[f+"x"]<c[f+"x"]?1:-1,n=Math.atan2(l*m,k*m);h="fixed"===e("edgeLabelSize")?e("defaultEdgeLabelSize"):e("defaultEdgeLabelSize")*g*Math.pow(g,-1/e("edgeLabelSizePowRatio")),d.save(),a.active?(d.font=[e("activeFontStyle"),h+"px",e("activeFont")||e("font")].join(" "),d.fillStyle="edge"===e("edgeActiveColor")?a.active_color||e("defaultEdgeActiveColor"):e("defaultEdgeLabelActiveColor")):(d.font=[e("fontStyle"),h+"px",e("font")].join(" "),d.fillStyle="edge"===e("edgeLabelColor")?a.color||e("defaultEdgeColor"):e("defaultEdgeLabelColor")),d.textAlign="center",d.textBaseline="alphabetic",d.translate(i,j),d.rotate(n),d.fillText(a.label,0,-g/2-3),d.restore()}}}}.call(this);

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(function(){function a(a,b,c){var d=document.createElement("a");d.setAttribute("href",a),d.setAttribute("download",c||"graph."+b);var e=document.createEvent("MouseEvent");e.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),d.dispatchEvent(e),delete d}function b(b){if(b=b||{},b.format&&!(b.format in d))throw Error('sigma.renderers.snaphot: unsupported format "'+b.format+'".');var e=this,f=this instanceof sigma.renderers.webgl,g=[],h=document.createElement("canvas"),i=h.getContext("2d"),j=!1;c.forEach(function(a){if(e.contexts[a]&&(b.labels!==!1||"labels"!==a)){var c=e.domElements[a]||e.domElements.scene,d=e.contexts[a];~g.indexOf(d)||(j||(h.width=f&&d instanceof WebGLRenderingContext?c.width/2:c.width,h.height=f&&d instanceof WebGLRenderingContext?c.height/2:c.height,j=!0,b.background&&(i.rect(0,0,h.width,h.height),i.fillStyle=b.background,i.fill())),d instanceof WebGLRenderingContext?i.drawImage(c,0,0,c.width/2,c.height/2):i.drawImage(c,0,0),g.push(d))}});var k=h.toDataURL(d[b.format||"png"]);return b.download&&a(k,b.format||"png",b.filename),delete i,delete h,delete g,k}if("undefined"==typeof sigma)throw"sigma.renderers.snapshot: sigma not in scope.";var c=["scene","edges","nodes","labels"],d={png:"image/png",jpg:"image/jpeg",gif:"image/gif",tiff:"image/tiff"};sigma.renderers.canvas.prototype.snapshot=b,sigma.renderers.webgl.prototype.snapshot=b}).call(this);

View File

@ -1 +0,0 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.classes.graph.addMethod("HITS",function(a){var b={},c=1e-4,d=[],e=[],f=this.nodes(),g=(f.length,{});a||(a=!1);for(var h in f)a?(d.push(f[h]),e.push(f[h])):(this.degree(f[h].id,"out")>0&&d.push(f[h]),this.degree(f[h].id,"in")>0&&e.push(f[h])),b[f[h].id]={authority:1,hub:1};for(var i;;){i=!0;var j=0,k=0;for(var h in e){g[e[h].id]={authority:1,hub:0};var l=[];l=a?this.allNeighborsIndex[e[h].id]:this.inNeighborsIndex[e[h].id];for(var m in l)m!=e[h].id&&(g[e[h].id].authority+=b[m].hub);j+=g[e[h].id].authority}for(var h in d){g[d[h].id]?g[d[h].id].hub=1:g[d[h].id]={authority:0,hub:1};var l=[];l=a?this.allNeighborsIndex[d[h].id]:this.outNeighborsIndex[d[h].id];for(var m in l)m!=d[h].id&&(g[d[h].id].hub+=b[m].authority);k+=g[d[h].id].hub}for(var h in e)g[e[h].id].authority/=j,Math.abs((g[e[h].id].authority-b[e[h].id].authority)/b[e[h].id].authority)>=c&&(i=!1);for(var h in d)g[d[h].id].hub/=k,Math.abs((g[d[h].id].hub-b[d[h].id].hub)/b[d[h].id].hub)>=c&&(i=!1);if(b=g,g={},i)break}return b})}).call(window);

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -124,8 +124,11 @@
return array(
'ModuleError' => ManagerError::Success,
'labels' => $labels,
'colors' => $colors,
'data' => array($INCOMING, $OUTGOING, $MISSED)
'datasets' => array(array(
'data' => array($INCOMING, $OUTGOING, $MISSED),
'backgroundColor' => $colors['default'],
'hoverBackgroundColor' => $colors['hover']
))
);
}
@ -185,9 +188,12 @@
return array(
'ModuleError' => ManagerError::Success,
'colors' => $colors,
'labels' => array('APPELS', 'SMS'),
'data' => array($PHONE, $SMS)
'datasets' => array(array(
'data' => array($PHONE, $SMS),
'backgroundColor' => $colors['default'],
'hoverBackgroundColor' => $colors['hover']
))
);
}
@ -254,9 +260,12 @@
return array(
'ModuleError' => ManagerError::Success,
'colors' => $colors,
'labels' => array('HOMME', 'FEMME'),
'data' => array($H, $F)
'datasets' => array(array(
'data' => array($H, $F),
'backgroundColor' => $colors['default'],
'hoverBackgroundColor' => $colors['hover']
))
);
}
@ -346,9 +355,12 @@
return array(
'ModuleError' => ManagerError::Success,
'colors' => $colors,
'labels' => $labels,
'data' => $age_classes
'datasets' => array(array(
'data' => $age_classes,
'backgroundColor' => $colors['default'],
'hoverBackgroundColor' => $colors['hover']
))
);
}
@ -439,9 +451,14 @@
return array(
'ModuleError' => ManagerError::Success,
'colors' => $colors,
'labels' => $labels,
'data' => $relations
'datasets' => array(array(
'data' => $relations,
'backgroundColor' => $colors['default'],
'hoverBackgroundColor' => $colors['hover'],
'borderWidth' => 1,
'borderColor' => 'hsla(216,100%,80%,1)'
))
);
}

View File

@ -28,10 +28,27 @@
/* [0] Paramètres globaux
=========================================================*/
Chart.defaults.global.responsive = false;
Chart.defaults.global.onClick = function(e, c){
console.log(e); // MouseEvent
console.log(c[0]._datasetIndex, c[0]._index); // Chart data
// _datasetIndex, quel dataset (s'il y en a plusieurs)
// _index, indice de la valeur dans le dataset
}
subject = 273;
var charts = ['sexe', 'direction', 'type', 'ages', 'relation'];
/* [1] On crée les conteneurs
=========================================================*/
for( var c in charts ){
}
/* [1] On récupére les données SEXE
=========================================================*/
/* (1) On rédige la requête */
@ -50,11 +67,7 @@
=========================================================*/
var data = {
labels: response.labels,
datasets: [{
data: response.data,
backgroundColor: response.colors.default,
hoverBackgroundColor: response.colors.hover
}]
datasets: response.datasets
}
/* [3] On construit notre graphique
@ -86,11 +99,7 @@
=========================================================*/
var data = {
labels: response.labels,
datasets: [{
data: response.data,
backgroundColor: response.colors.default,
hoverBackgroundColor: response.colors.hover
}]
datasets: response.datasets
}
/* [3] On construit notre graphique
@ -122,11 +131,7 @@
=========================================================*/
var data = {
labels: response.labels,
datasets: [{
data: response.data,
backgroundColor: response.colors.default,
hoverBackgroundColor: response.colors.hover
}]
datasets: response.datasets
}
/* [3] On construit notre graphique
@ -160,11 +165,7 @@
=========================================================*/
var data = {
labels: response.labels,
datasets: [{
data: response.data,
backgroundColor: response.colors.default,
hoverBackgroundColor: response.colors.hover
}]
datasets: response.datasets
}
/* [3] On construit notre graphique
@ -196,17 +197,9 @@
/* [2] On construit les données
=========================================================*/
console.log(response.labels);
var data = {
labels: response.labels,
datasets: [{
label: "Types de relation",
data: response.data,
borderWidth: 1,
borderColor: 'hsla(216,100%,80%,1)',
backgroundColor: response.colors.default,
hoverBackgroundColor: response.colors.hover
}]
datasets: response.datasets
}
/* [3] On construit notre graphique

View File

@ -41,8 +41,8 @@
<script type='text/javascript' src='/f/js/input-html-facebook-data-min/js/includes' ></script> <!-- Gestion du constructeur HTML pour la page d'acquisition -->
<!-- Librairies Externes Javascript -->
<script type='text/javascript' src='/f/js/sigma-min/sigma' ></script> <!-- Gestion du graphique de type réseau -->
<!-- <script type='text/javascript' src='/f/js/sigma-plugins-animate-min/sigma/plugins' ></script> for animations -->
<script type='text/javascript' src='/f/js/_charts-min/js/lib' ></script> <!-- Librairie pour les graphiques -->
</head>
<body>

View File

@ -10,57 +10,11 @@
/* [1] Gestion du cercle des relations
=======================================*/
/* (1) On recupere les donnees */
$getData = new ModuleRequest('chart/network_data');
$answer = $getData->dispatch();
// Si pas d'erreur
if( $answer->error != ManagerError::Success )
var_dump( ManagerError::explicit($answer->error) );
// On enregistre les donnees
$data = $answer->get('data');
/* (2) On recupere le rendu */
$getRender = new ModuleRequest('chart/network_render', array('dataset' => $data));
$answer = $getRender->dispatch();
// Si pas d'erreur
if( $answer->error != ManagerError::Success )
var_dump( ManagerError::explicit($answer->error) );
// On enregistre les donnees
$render = $answer->get('render');
?>
<section data-sublink='phone' class='charts'>
<section data-sublink='phone'>
<!-- SECTION 1 - SOCIOGRAMME SPATIAL -->
<section>
<center><h6>SOCIOGRAMME SPATIAL</h6></center>
<div id='sociogram' style='border-radius:3px;border: 1px solid #ddd;margin: 2em;width:30em;height: 30em;'></div>
</section>
<!-- SECTION 1 BIS - SOCIOGRAMME SPATIAL -->
<section>
<center><h6>SOCIOGRAMME EGOCENTRE</h6></center>
<div id='graph-container' style='border-radius:3px;border: 1px solid #ddd;margin: 2em;width:30em;height: 30em;'></div>
</section>
<!-- SECTION 2 - SOCIOGRAMME EGOCENTRE -->
<section>
<center><h6>SOCIOGRAMME EGOCENTRE</h6></center>
<?php echo $render; ?>
</section>
</section>

View File

@ -1 +1,2 @@
var chartManagers={sociogram:{link:"/js/includes/charts-sociogram-min.js",loaded:!1}},sociogram;chartManagers.sociogram.loaded=include(chartManagers.sociogram.link,null,!0);include(chartManagers.sociogram.link,function(){chartManagers.sociogram.loaded||sociogramClass.prototype.overloadGraph();sociogram=new sociogramClass($("#sociogram"));sociogram.load()});
var subPhone=$('section[data-sublink="phone"]');Chart.defaults.global.responsive=!1;Chart.defaults.global.onClick=function(a,b){console.log(a);console.log(b[0]._datasetIndex,b[0]._index)};subject=273;var charts=["sexe","direction","type","ages","relation"],types=["doughnut","doughnut","doughnut","doughnut","bar"],canvas=[],instances=[],c;for(c in charts)canvas[c]=document.createElement("canvas"),canvas[c].id=charts[c],canvas[c].width=300,canvas[c].height=300,subPhone.appendChild(canvas[c]);
for(c=0;c<charts.length;c++){var request={path:"chart/"+charts[c],subject:subject};api.send(request,function(a,b){var d=b[0];console.log(b);if(0!=a.ModuleError)return!1;var e={labels:a.labels,datasets:a.datasets};console.log(canvas[d],types[d]);instances[d]=new Chart(canvas[d],{type:types[d],animation:{animateScale:!0},data:e})},null,c)};

View File

@ -1,25 +1,75 @@
/* [0] Chemins des fichiers de gestion des graphiques
var subPhone = $('section[data-sublink="phone"]');
/* [0] Paramètres globaux
=========================================================*/
var chartManagers = {
sociogram: { link: '/js/includes/charts-sociogram-min.js', loaded: false }
Chart.defaults.global.responsive = false;
Chart.defaults.global.onClick = function(e, c){
console.log(e); // MouseEvent
console.log(c[0]._datasetIndex, c[0]._index); // Chart data
// _datasetIndex, quel dataset (s'il y en a plusieurs)
// _index, indice de la valeur dans le dataset
};
subject = 273;
/* [1] Gestion du sociogramme
var charts = ['sexe', 'direction', 'type', 'ages', 'relation'];
var types = ['doughnut', 'doughnut', 'doughnut', 'doughnut', 'bar'];
var canvas = []; // Contiendra les canvas
var instances = []; // Contiendra les charts
/* [1] On crée les conteneurs
=========================================================*/
var sociogram;
for( var c in charts ){
canvas[c] = document.createElement('canvas');
canvas[c].id = charts[c];
canvas[c].width = 300;
canvas[c].height = 300;
subPhone.appendChild( canvas[c] );
}
/* (1) On essaie de charger la classe du sociogramme */
chartManagers.sociogram.loaded = include(chartManagers.sociogram.link, null, true);
/* (2) Si il est pas déja chargé, on initialise le sociogramme */
include(chartManagers.sociogram.link, function(){
// On ajoute les méthodes si c'est la première fois qu'on charge
if( !chartManagers.sociogram.loaded ) sociogramClass.prototype.overloadGraph();
/* [2] Pour chaque graphique, on récupère les données et on les affiche
=========================================================*/
for( var c = 0 ; c < charts.length ; c++ ){
// On charge le graphique
sociogram = new sociogramClass( $('#sociogram') );
sociogram.load();
});
/* (1) On rédige la requête */
var request = {
path: 'chart/'+charts[c],
subject: subject
};
/* (2) On lance la requête */
api.send(request, function(response, args){
// On récupère @c dans le scope du handler
var c = args[0];
console.log(args);
/* (3) Si erreur, on quitte */
if( response.ModuleError != 0 )
return false;
/* [2] On construit les données
=========================================================*/
var data = {
labels: response.labels,
datasets: response.datasets
};
/* [3] On construit notre graphique
=========================================================*/
console.log(canvas[c], types[c]);
instances[c] = new Chart(canvas[c], {
type: types[c],
animation: { animateScale: true },
data: data
});
}, null, c);
}