Commit b5307731 authored by PkSM3's avatar PkSM3

last fixes

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