Commit b5307731 authored by PkSM3's avatar PkSM3

last fixes

parent 236873ae
...@@ -135,18 +135,18 @@ ...@@ -135,18 +135,18 @@
</a></li> </a></li>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul id="colorGraph" class="nav navbar-nav navbar-right">
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img title="Set Colors" src="img/colors.png" width="20px"><b class="caret"></b></img> <img title="Set Colors" src="img/colors.png" width="20px"><b class="caret"></b></img>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#" id="colorbyCC">By Country</a></li> <li><a href="#" onclick='clustersBy("country")'>By Country</a></li>
<li><a href="#"><strike>By Acronym</strike></a></li> <li><a href="#" onclick='clustersBy("acronym")'>By Acronym</a></li>
<li><a href="#" id="colorbyDef">By Default</a></li> <li><a href="#" onclick='clustersBy("default")'>By Default</a></li>
<li class="divider"></li> <li class="divider"></li>
<li><a href="#"> <span class="glyphicon glyphicon-repeat"></span> <strike>Properties</strike></a></li> <li><a href="#"> <span class="glyphicon glyphicon-repeat"></span> <strike>Properties</strike></a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
......
* Running on http://127.0.0.1:8080/
...@@ -166,9 +166,18 @@ function changeType() { ...@@ -166,9 +166,18 @@ function changeType() {
pushSWClick("semantic"); pushSWClick("semantic");
RefreshState("B") RefreshState("B")
} else { } else {
changeToMeso("sociosemantic");
pushSWClick("sociosemantic"); if(is_empty(selections)) {
RefreshState("AaBb")
changeToMacro("semantic");
pushSWClick("semantic");
RefreshState("B")
} else {
changeToMeso("sociosemantic");
pushSWClick("sociosemantic");
RefreshState("AaBb")
}
} }
return; return;
} }
...@@ -177,11 +186,19 @@ function changeType() { ...@@ -177,11 +186,19 @@ function changeType() {
if(swMacro) { if(swMacro) {
changeToMacro("social"); changeToMacro("social");
pushSWClick("social"); pushSWClick("social");
RefreshState("A") RefreshState("A");
} else { } else {
changeToMeso("sociosemantic");
pushSWClick("sociosemantic"); if(is_empty(selections)) {
RefreshState("AaBb") changeToMacro("social");
pushSWClick("social");
RefreshState("A");
} else {
changeToMeso("sociosemantic");
pushSWClick("sociosemantic");
RefreshState("AaBb");
}
} }
return; return;
} }
......
...@@ -732,18 +732,6 @@ function theListeners(){ ...@@ -732,18 +732,6 @@ function theListeners(){
}); });
$("#colorbyCC").click(function(){
clustersBy("country");
});
$("#colorbyDef").click(function(){
clustersBy("default");
});
// $.doTimeout(10,function (){ // $.doTimeout(10,function (){
// var deftoph=$("#defaultop").height(); // var deftoph=$("#defaultop").height();
// var refh=$("#fixedtop").height(); // var refh=$("#fixedtop").height();
......
...@@ -223,25 +223,37 @@ function RefreshState(newNOW){ ...@@ -223,25 +223,37 @@ function RefreshState(newNOW){
// k : number of ( selected nodes + their neighbors ) // k : number of ( selected nodes + their neighbors )
// s : number of selections // s : number of selections
var N=Object.keys(partialGraph._core.graph.nodes.filter(function(n){return n.type==catSoc && !n.hidden })).length; var N=Object.keys(partialGraph._core.graph.nodes.filter(function(n){return n.type==catSoc && !n.hidden })).length;
var k=Object.keys(getNeighs(selections,nodes1)).length var k=Object.keys(getNeighs(Object.keys(selections),nodes1)).length
var s=Object.keys(selections).length var s=Object.keys(selections).length
pr("in social N: "+N+" - k: "+k+" - s: "+s) pr("in social N: "+N+" - k: "+k+" - s: "+s)
if(NOW=="A" && (s==0 || k>=N)) LevelButtonDisable(true); if(NOW=="A"){
else LevelButtonDisable(false); if( (s==0 || k>=(N-1)) ) {
EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight"); LevelButtonDisable(true);
} else LevelButtonDisable(false);
if(s==N) LevelButtonDisable(false);
}
EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight");
$("#colorGraph").show();
} }
if(NOW=="B" || NOW=="b") { if(NOW=="B" || NOW=="b") {
var N=Object.keys(partialGraph._core.graph.nodes.filter(function(n){return n.type==catSem && !n.hidden })).length; var N=Object.keys(partialGraph._core.graph.nodes.filter(function(n){return n.type==catSem && !n.hidden })).length;
var k=Object.keys(getNeighs(selections,nodes2)).length var k=Object.keys(getNeighs(Object.keys(selections),nodes2)).length
var s=Object.keys(selections).length var s=Object.keys(selections).length
pr("in semantic N: "+N+" - k: "+k+" - s: "+s) pr("in semantic N: "+N+" - k: "+k+" - s: "+s)
if( NOW=="B" && (s==0 || k>=N) ) LevelButtonDisable(true); if(NOW=="B") {
else LevelButtonDisable(false); if( (s==0 || k>=(N-1)) ) {
LevelButtonDisable(true);
} else LevelButtonDisable(false);
if(s==N) LevelButtonDisable(false);
}
EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight"); EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
NodeWeightFilter ( "#sliderBNodeWeight" , "type" , "NGram" , "size") NodeWeightFilter ( "#sliderBNodeWeight" , "type" , "NGram" , "size")
$("#colorGraph").hide();
} }
if(NOW=="AaBb"){ if(NOW=="AaBb"){
LevelButtonDisable(true); LevelButtonDisable(true);
$("#colorGraph").hide();
} }
} }
...@@ -442,10 +454,10 @@ function getNodeIDs(elems){ ...@@ -442,10 +454,10 @@ function getNodeIDs(elems){
// tag cloud div // tag cloud div
//missing: the graphNGrams javascript //missing: the graphNGrams javascript
function htmlfied_alternodes(elems){ function htmlfied_alternodes(elems) {
var oppositesNodes=[] var oppositesNodes=[]
js1=""//'onclick="edgesTF=false;cancelSelection(true);graphNGrams(\''; js1='onclick="graphTagCloudElem(\'';
js2=""//"');" js2="');\""
frecMAX=elems[0].value frecMAX=elems[0].value
for(var i in elems){ for(var i in elems){
id=elems[i].key id=elems[i].key
...@@ -458,11 +470,9 @@ function htmlfied_alternodes(elems){ ...@@ -458,11 +470,9 @@ function htmlfied_alternodes(elems){
((desirableTagCloudFont_MAX-desirableTagCloudFont_MIN)/(frecMAX-1)); ((desirableTagCloudFont_MAX-desirableTagCloudFont_MIN)/(frecMAX-1));
} }
if(!isUndef(Nodes[id])){ if(!isUndef(Nodes[id])){
// js1 js2
htmlfied_alternode= '<span class="tagcloud-item" style="font-size:'+fontSize+'px;"' // onclick="graphNGrams(' ');
htmlfied_alternode = '<span class="tagcloud-item" style="font-size:'+fontSize+'px;" '+js1+id+js2+'>'+ Nodes[id].label+ '</span>';
+">"//+js1+id+js2+'>'
+ Nodes[id].label+ '</span>';
oppositesNodes.push(htmlfied_alternode) oppositesNodes.push(htmlfied_alternode)
} }
} }
...@@ -555,63 +565,18 @@ function LevelButtonDisable( TF ){ ...@@ -555,63 +565,18 @@ function LevelButtonDisable( TF ){
$('#changelevel').prop('disabled', TF); $('#changelevel').prop('disabled', TF);
} }
function graphNGrams(node_id){ function graphTagCloudElem(node_id){
pr("\tin graphNGrams");/**/ pr("\tin graphTagCloudElem");/**/
fullurl = returnBaseUrl()+"img/trans/";
document.getElementById("viewType").src=fullurl+"status_meso_view.png";
document.getElementById("socio").src=fullurl+"inactive_scholars.png";
document.getElementById("semantic").src=fullurl+"active_tags.png";
document.getElementById("sociosemantic").src=fullurl+"inactive_sociosem.png";
document.getElementById("switch").src=fullurl+"graph_macro.png";
console.log("in graphNGrams, nodae_id: "+node_id);
if(Nodes[node_id].type==catSem) {
labels = [];
hideEverything()
//partialGraph.stopForceAtlas2();
unHide(node_id);
for(i=0;i<nodes2[node_id].neighbours.length;i++) { console.log("in graphTagCloudElem, nodae_id: "+node_id);
unHide(nodes2[node_id].neighbours[i]); cancelSelection();
} swMacro=true;
changeType();
/* ALGORITMO ESTRELLA*/ MultipleSelection(node_id);
existingNodes = partialGraph._core.graph.nodes.filter(function(n) { changeLevel();
return !n['hidden'];
});
edgesFound = [];
for(i=0; i < existingNodes.length ; i++){
if(existingNodes[i].id==node_id) i++;
for(j=0; j < existingNodes.length ; j++){
i1=existingNodes[i].id+";"+existingNodes[j].id;
i2=existingNodes[j].id+";"+existingNodes[i].id;
if(!isUndef(Edges[i1]) && !isUndef(Edges[i2])){
if(Edges[i1].weight > Edges[i2].weight){
unHide(i1);
}
if(Edges[i1].weight < Edges[i2].weight){
unHide(i2);
}
if(Edges[i1].weight == Edges[i2].weight){
unHide(i1);
}
}
}
}
node = partialGraph._core.graph.nodesIndex[node_id];
selection(node);
partialGraph.startForceAtlas2();
$("#category-A").hide();
$("#category-B").show();
changeButton("active_tags.png");
}
} }
//obsolete
function graphDocs(node_id){ function graphDocs(node_id){
pr("\tin graphDocs, node_id: "+node_id); pr("\tin graphDocs, node_id: "+node_id);
...@@ -658,8 +623,7 @@ function graphDocs(node_id){ ...@@ -658,8 +623,7 @@ function graphDocs(node_id){
} }
} }
node = partialGraph._core.graph.nodesIndex[node_id]; node = partialGraph._core.graph.nodesIndex[node_id];
selection(node); selection(node);
partialGraph.startForceAtlas2();
$("#category-A").show(); $("#category-A").show();
$("#category-B").hide(); $("#category-B").hide();
changeButton("active_scholars.png"); changeButton("active_scholars.png");
...@@ -1143,7 +1107,7 @@ function markAsSelected(n_id,sel) { ...@@ -1143,7 +1107,7 @@ function markAsSelected(n_id,sel) {
// } // }
} }
//obsolete au non
function DrawAsSelectedNodes( nodeskeys ) { function DrawAsSelectedNodes( nodeskeys ) {
greyEverything(); greyEverything();
...@@ -1495,7 +1459,6 @@ function unHideElem(id){ ...@@ -1495,7 +1459,6 @@ function unHideElem(id){
function changeToMeso(iwannagraph) { function changeToMeso(iwannagraph) {
labels=[] labels=[]
pr("changing to Meso-"+iwannagraph); pr("changing to Meso-"+iwannagraph);
fullurl = returnBaseUrl()+"img/trans/";
if(iwannagraph=="social") { if(iwannagraph=="social") {
if(!is_empty(selections)){ if(!is_empty(selections)){
//hideEverything(); //hideEverything();
...@@ -1607,8 +1570,6 @@ function changeToMeso(iwannagraph) { ...@@ -1607,8 +1570,6 @@ function changeToMeso(iwannagraph) {
} }
createEdgesForExistingNodes(iwannagraph); createEdgesForExistingNodes(iwannagraph);
partialGraph.startForceAtlas2();
socsemFlag=true; socsemFlag=true;
} }
} }
...@@ -1865,7 +1826,7 @@ function saveGraphIMG(){ ...@@ -1865,7 +1826,7 @@ function saveGraphIMG(){
document.location.href = strData.replace("image/png", strDownloadMime) document.location.href = strData.replace("image/png", strDownloadMime)
} }
//to erase
function testSave(){ function testSave(){
var strDownloadMime = "image/octet-stream" var strDownloadMime = "image/octet-stream"
......
// Mathieu Jacomy @ Sciences Po Médialab & WebAtlas // Mathieu Jacomy @ Sciences Po Médialab & WebAtlas
// (requires sigma.js to be loaded) // (requires sigma.js to be loaded)
sigma.forceatlas2 = sigma.forceatlas2 || {}; sigma.forceatlas2 = sigma.forceatlas2 || {};
sigma.forceatlas2.ForceAtlas2 = function(graph) { sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
sigma.classes.Cascade.call(this); sigma.classes.Cascade.call(this);
var self = this; var self = this;
this.graph = graph; this.graph = graph;
...@@ -35,9 +35,14 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) { ...@@ -35,9 +35,14 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) {
// Runtime (the ForceAtlas2 itself) // Runtime (the ForceAtlas2 itself)
this.init = function() { this.init = function() {
console.log("#Nodes: "+V)
console.log("#Edges: "+E)
self.state = {step: 0, index: 0}; self.state = {step: 0, index: 0};
self.graph.nodes.forEach(function(n) { self.graph.nodes.forEach(function(n) {
n.fa2 = { n.fa2 = {
mass: 1 + n.degree, mass: 1 + n.degree,
old_dx: 0, old_dx: 0,
...@@ -45,6 +50,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) { ...@@ -45,6 +50,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) {
dx: 0, dx: 0,
dy: 0 dy: 0
}; };
}); });
return self; return self;
...@@ -67,6 +73,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) { ...@@ -67,6 +73,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) {
// Initialise layout data // Initialise layout data
self.count++; self.count++;
nodes.forEach(function(n) { nodes.forEach(function(n) {
if(n.fa2) { if(n.fa2) {
n.fa2.mass = 1 + n.degree; n.fa2.mass = 1 + n.degree;
n.fa2.old_dx = n.fa2.dx; n.fa2.old_dx = n.fa2.dx;
...@@ -82,6 +89,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) { ...@@ -82,6 +89,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) {
dy: 0 dy: 0
}; };
} }
}); });
// If Barnes Hut active, initialize root region // If Barnes Hut active, initialize root region
...@@ -964,7 +972,41 @@ sigma.forceatlas2.Region.prototype.applyForce = function(n, Force, theta) { ...@@ -964,7 +972,41 @@ sigma.forceatlas2.Region.prototype.applyForce = function(n, Force, theta) {
sigma.publicPrototype.startForceAtlas2 = function() { sigma.publicPrototype.startForceAtlas2 = function() {
//if(!this.forceatlas2) { //if(!this.forceatlas2) {
if(fa2enabled) { if(fa2enabled) {
this.forceatlas2 = new sigma.forceatlas2.ForceAtlas2(this._core.graph);
// -- UPDATING THE DEGREE --
for (var i in this._core.graph.nodesIndex) {
pr(i+" -> "+this._core.graph.nodesIndex[i].degree)
}
for (var i in this._core.graph.nodes) {
if(!this._core.graph.nodes[i].hidden) {
this._core.graph.nodes[i].degree = 0;
this._core.graph.nodesIndex[this._core.graph.nodes[i].id].degree = 0;
}
}
for (var e in this._core.graph.edges) {
edge = this._core.graph.edges[e];
if(!edge.hidden) {
nodeIDS = edge.source.id;
nodeIDT = edge.target.id;
this._core.graph.nodesIndex[nodeIDS].degree++;
this._core.graph.nodesIndex[nodeIDT].degree++;
}
}
for (var i in this._core.graph.nodesIndex) {
// if(this._core.graph.nodesIndex[i].degree==0)
// this._core.graph.nodesIndex[i].hidden = true;
pr(i+" -> "+this._core.graph.nodesIndex[i].degree)
}
// -- / UPDATING THE DEGREE --
var V = 10;
var E = 100;
this.forceatlas2 = new sigma.forceatlas2.ForceAtlas2(this._core.graph , V, E);
this.forceatlas2.setAutoSettings(); this.forceatlas2.setAutoSettings();
this.forceatlas2.init(); this.forceatlas2.init();
$("#overviewzone").hide(); $("#overviewzone").hide();
......
...@@ -13,7 +13,7 @@ function showMeSomeLabels(N){ ...@@ -13,7 +13,7 @@ function showMeSomeLabels(N){
} }
}); });
counter=0; counter=0;
n = partialGraph._core.graph.nodes; n = getVisibleNodes();
for(i=0;i<n.length;i++) { for(i=0;i<n.length;i++) {
if(n[i].hidden==false){ if(n[i].hidden==false){
if(n[i].inDegree==minIn && n[i].forceLabel==false) { if(n[i].inDegree==minIn && n[i].forceLabel==false) {
...@@ -183,6 +183,21 @@ function getCountries(){ ...@@ -183,6 +183,21 @@ function getCountries(){
return Object.keys(countries); return Object.keys(countries);
} }
function getAcronyms() {
var nodes = getVisibleNodes();
var acrs = {}
pr("in getAcronyms")
for(var i in nodes) {
// pr(i)
// pr(nodes[i].id+" : "+nodes[i].attr["CC"]+" , "+nodes[i].attr["ACR"])
if (nodes[i].attr["ACR"]!="-")
acrs[nodes[i].attr["ACR"]]=1
// pr("")
}
return ( Object.keys(acrs) );
}
function clustersBy(daclass) { function clustersBy(daclass) {
if (daclass=="country") { if (daclass=="country") {
...@@ -195,6 +210,10 @@ function clustersBy(daclass) { ...@@ -195,6 +210,10 @@ function clustersBy(daclass) {
pr(CCxID) pr(CCxID)
var nodes = getVisibleNodes(); var nodes = getVisibleNodes();
for(var i in nodes) {
nodes[i].color = Nodes[ nodes[i].id ].color;
}
colorList.sort(function(){ return Math.random()-0.5; }); colorList.sort(function(){ return Math.random()-0.5; });
// pr(colorList); // pr(colorList);
for(var i in nodes) { for(var i in nodes) {
...@@ -205,6 +224,33 @@ function clustersBy(daclass) { ...@@ -205,6 +224,33 @@ function clustersBy(daclass) {
} }
} }
if (daclass=="acronym") {
CCs = getAcronyms()
CCxID = {}
for(var i in CCs) {
code = CCs[i]
CCxID[code]=parseInt(i);
}
pr(CCxID)
var nodes = getVisibleNodes();
for(var i in nodes) {
nodes[i].color = Nodes[ nodes[i].id ].color;
}
colorList.sort(function(){ return Math.random()-0.5; });
// pr(colorList);
for(var i in nodes) {
cc = nodes[i].attr["ACR"]
if( !isUndef( cc ) && cc!="-" ) {
nodes[i].color = colorList[ CCxID[cc] ];
}
}
}
if (daclass=="default") { if (daclass=="default") {
var nodes = getVisibleNodes(); var nodes = getVisibleNodes();
for(var i in nodes) { for(var i in nodes) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment