Commit 18ba0e00 authored by PkSM3's avatar PkSM3

edge weight social filter finally ok

parent b3481133
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
/* ZOOM IN OUT */ /* ZOOM IN OUT */
#ctlzoom { #ctlzoom {
position: absolute; right: 220px; bottom: 5px; list-style: none; padding: 0; margin: 0;/*EDIT*/ position: absolute; right: 300px; bottom: 5px; list-style: none; padding: 0; margin: 0;/*EDIT*/
} }
#ctlzoom li { #ctlzoom li {
......
...@@ -23,12 +23,12 @@ box-shadow: 0px 0px 3px 0px #888888; ...@@ -23,12 +23,12 @@ box-shadow: 0px 0px 3px 0px #888888;
#leftcolumn { #leftcolumn {
overflow-y: scroll; overflow-y: scroll;
margin-right: -210px; margin-right: -300px;
margin-left: 0px; margin-left: 0px;
padding-bottom: 10px; padding-bottom: 10px;
padding-left: 5px; padding-left: 5px;
right: 210px; right: 300px;
width: 210px; width: 300px;
position: fixed; position: fixed;
height: 100%; height: 100%;
border: 1px #888888 solid; border: 1px #888888 solid;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<title>TinawebJS</title> <title>TinawebJS</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" href="jquery/jquery-ui.css" media="screen"> <link rel="stylesheet" href="jquery/jquery-ui.css" media="screen">
<link rel="stylesheet" href="css/bootstrap.css" media="screen"> <link rel="stylesheet" href="css/bootstrap.css" media="screen">
<link rel="stylesheet" href="css/freshstyle.css" media="screen"> <link rel="stylesheet" href="css/freshstyle.css" media="screen">
......
This diff is collapsed.
# -*- coding: utf-8 -*-
from FA2 import ForceAtlas2
from extractData import extract as SQLite
import json
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
def main():
#query = request.args['query']
#{"categorya"%3A"Keywords"%2C"categoryb"%3A"Scholars"%2C"keywords"%3A[]%2C"countries"%3A["Chile"]%2C"laboratories"%3A[]%2C"coloredby"%3A[]%2C"tags"%3A[]%2C"organizations"%3A[]}
# i=int(sys.argv[2])
# unique_id = sys.argv[1]
# db=SQLite(unique_id)
# db.extract()
# < Data Extraction > #
i = 100
unique_id = "Carla__Taramasco"#"Noël__Bonneuil"
db=SQLite(unique_id)
db.extract()
# < / Data Extraction > #
tempGraph = db.buildSimpleJSONFinal(db.Graph)
# Arnaud Banos network:
# Bruce Edmonds exists twice, but one of them has no keywords
# import pprint as p
# A=tempGraph["edges"]
# for j in A:
# s=j["source"]
# t=j["target"]
# if s=="D::593" or t=="D::593":
# print j
# spatialized = ForceAtlas2(tempGraph)
# spatialized.init()
# spatialized.getGraph()
# for i in range(0,i):
# spatialized.atomicGo()
graphArray = db.buildJSON_sansfa2(db.Graph)
# A=graphArray["edges"]
# for j in A:
# print A[j]
#
# print "finish"
return json.dumps(graphArray)
if __name__ == "__main__":
main()
...@@ -665,19 +665,20 @@ class extract: ...@@ -665,19 +665,20 @@ class extract:
return graph return graph
def buildJSON_sansfa2(self,graph,coordsRAW): def buildJSON_sansfa2(self,graph,coordsRAW=None):
print "printing in buildJSON_sansfa2()" print "printing in buildJSON_sansfa2()"
nodes = {} nodes = {}
edges = {} edges = {}
import json if coordsRAW:
xy = coordsRAW #For FA2.java: json.loads(coordsRAW) import json
#print xy xy = coordsRAW #For FA2.java: json.loads(coordsRAW)
coords = {} #print xy
for i in xy: coords = {}
coords[i['sID']] = {} for i in xy:
coords[i['sID']]['x'] = i['x'] coords[i['sID']] = {}
coords[i['sID']]['y'] = i['y'] coords[i['sID']]['x'] = i['x']
#print coords coords[i['sID']]['y'] = i['y']
#print coords
for idNode in graph.nodes_iter(): for idNode in graph.nodes_iter():
if idNode[0]=="N":#If it is NGram if idNode[0]=="N":#If it is NGram
...@@ -691,8 +692,8 @@ class extract: ...@@ -691,8 +692,8 @@ class extract:
node["label"] = nodeLabel node["label"] = nodeLabel
node["color"] = "19,"+str(colorg)+",244" node["color"] = "19,"+str(colorg)+",244"
node["term_occ"] = term_occ node["term_occ"] = term_occ
node["x"] = str(coords[idNode]['x']) if coordsRAW: node["x"] = str(coords[idNode]['x'])
node["y"] = str(coords[idNode]['y']) if coordsRAW: node["y"] = str(coords[idNode]['y'])
nodes[idNode] = node nodes[idNode] = node
...@@ -732,7 +733,7 @@ class extract: ...@@ -732,7 +733,7 @@ class extract:
if self.scholars[idNode]['homepage'][0:3] == "www": if self.scholars[idNode]['homepage'][0:3] == "www":
content += '[ <a href=http://' +self.scholars[idNode]['homepage'].replace("&"," and ")+ ' target=blank > View homepage </a ><br/>]' content += '[ <a href=http://' +self.scholars[idNode]['homepage'].replace("&"," and ")+ ' target=blank > View homepage </a ><br/>]'
elif self.scholars[idNode]['homepage'][0:4] == "http": elif self.scholars[idNode]['homepage'][0:4] == "http":
content += '[ <a href=' +self.scholars[idNode]['homepage'].replace("&"," and ")+ ' target=blank > View homepage </a ><br/>]' content += '[ <a href=' +self.scholars[idNode]['homepage'].replace("&"," and ")+ ' target=blank > View homepage </a >]<br/>'
node = {} node = {}
...@@ -740,19 +741,39 @@ class extract: ...@@ -740,19 +741,39 @@ class extract:
node["label"] = nodeLabel node["label"] = nodeLabel
node["color"] = color node["color"] = color
node["term_occ"] = "12" node["term_occ"] = "12"
node["x"] = str(coords[idNode]['x']) if coordsRAW: node["x"] = str(coords[idNode]['x'])
node["y"] = str(coords[idNode]['y']) if coordsRAW: node["y"] = str(coords[idNode]['y'])
node["content"] = self.toHTML(content) node["content"] = self.toHTML(content)
nodes[idNode] = node nodes[idNode] = node
GG = nx.Graph()
for n in self.Graph.edges_iter():
s = n[0]
t = n[1]
w = float(self.Graph[n[0]][n[1]]['weight'])
tp = self.Graph[n[0]][n[1]]['type']
if GG.has_edge(s,t):
oldw = GG[s][t]['weight']
avgw = (oldw+w)/2
GG[s][t]['weight'] = avgw
else:
GG.add_edge( s , t , { "weight":w , "type":tp } )
e = 0 e = 0
for n in self.Graph.edges_iter():#Memory, what's wrong with you? for n in GG.edges_iter():#Memory, what's wrong with you?
weight = str("%.2f" % self.Graph[n[0]][n[1]]['weight']) wr = 0.0
origw = GG[n[0]][n[1]]['weight']
for i in range(2,10):
wr = round( origw , i)
if wr > 0.0: break
edge = {} edge = {}
edge["s"] = n[0] edge["s"] = n[0]
edge["t"] = n[1] edge["t"] = n[1]
edge["w"] = str(self.Graph[n[0]][n[1]]['weight']) edge["w"] = str(wr)
edge["type"] = self.Graph[n[0]][n[1]]['type'] edge["type"] = GG[n[0]][n[1]]['type']
if edge["type"]=="nodes1": print wr
edges[str(e)] = edge edges[str(e)] = edge
e+=1 e+=1
#if e%1000 == 0: #if e%1000 == 0:
...@@ -964,7 +985,7 @@ class extract: ...@@ -964,7 +985,7 @@ class extract:
nodes2.append(node) nodes2.append(node)
nodes[idNode] = countnodes nodes[idNode] = countnodes
countnodes+=1 countnodes+=1
e = 0 e = 0
for n in self.Graph.edges_iter():#Memory, what's wrong with you? for n in self.Graph.edges_iter():#Memory, what's wrong with you?
weight = str("%.2f" % self.Graph[n[0]][n[1]]['weight']) weight = str("%.2f" % self.Graph[n[0]][n[1]]['weight'])
edge = {} edge = {}
......
...@@ -52,16 +52,16 @@ def main(): ...@@ -52,16 +52,16 @@ def main():
# if s=="D::593" or t=="D::593": # if s=="D::593" or t=="D::593":
# print j # print j
spatialized = ForceAtlas2(tempGraph) # spatialized = ForceAtlas2(tempGraph)
spatialized.init() # spatialized.init()
spatialized.getGraph() # spatialized.getGraph()
# for i in range(0,i): # for i in range(0,i):
# spatialized.atomicGo() # spatialized.atomicGo()
graphArray = db.buildJSON_sansfa2(db.Graph,spatialized.getGraph()) graphArray = db.buildJSON_sansfa2(db.Graph)
return json.dumps(graphArray) return json.dumps(graphArray)
......
...@@ -45,39 +45,38 @@ var desirableScholarSize=6; //Remember that all scholars have the same size! ...@@ -45,39 +45,38 @@ var desirableScholarSize=6; //Remember that all scholars have the same size!
* - true: fa2 running at start * - true: fa2 running at start
* - false: fa2 stopped at start, button exists * - false: fa2 stopped at start, button exists
* - "off": button doesn't exist, fa2 stopped forever * - "off": button doesn't exist, fa2 stopped forever
**/ **/ var fa2enabled=false;//"off";
var fa2enabled="off"; var stopcriteria = false;
var iterationsFA2=1000; var iterationsFA2=1000;
var seed=999999999;//defaultseed var seed=999999999;//defaultseed
var showLabelsIfZoom=2.0; var showLabelsIfZoom=2.0;
// ============ < SIGMA.JS PROPERTIES > ============
var desirableNodeSizeMIN=1; // ============ < SIGMA.JS PROPERTIES > ============
var desirableNodeSizeMAX=12;
var desirableScholarSize=6; //Remember that all scholars have the same size! var sigmaJsDrawingProperties = {
defaultLabelColor: 'black',
var sigmaJsDrawingProperties = { defaultLabelSize: 10,//in fact I'm using it as minLabelSize'
defaultLabelColor: 'black', defaultLabelBGColor: '#fff',
defaultLabelSize: 10,//in fact I'm using it as minLabelSize' defaultLabelHoverColor: '#000',
defaultLabelBGColor: '#fff', labelThreshold: 6,
defaultLabelHoverColor: '#000', defaultEdgeType: 'curve',
labelThreshold: 6,
defaultEdgeType: 'curve', borderSize: 2.5,//Something other than 0
nodeBorderColor: "default",//exactly like this
borderSize: 2.5,//Something other than 0 defaultNodeBorderColor: "black"//,//Any color of your choice
nodeBorderColor: "default",//exactly like this //defaultBorderView: "always"
defaultNodeBorderColor: "black"//,//Any color of your choice };
//defaultBorderView: "always" var sigmaJsGraphProperties = {
}; minEdgeSize: 2,
var sigmaJsGraphProperties = { maxEdgeSize: 2
minEdgeSize: 2, };
maxEdgeSize: 2 var sigmaJsMouseProperties = {
}; minRatio:0.1,
var sigmaJsMouseProperties = { maxRatio: 15
minRatio:0.1, };
maxRatio: 100 // ============ < / SIGMA.JS PROPERTIES > ============
};
// ============ < / SIGMA.JS PROPERTIES > ============
// ============ < / DEVELOPER OPTIONS > ============ // ============ < / DEVELOPER OPTIONS > ============
...@@ -108,6 +107,18 @@ var swMacro=true; ...@@ -108,6 +107,18 @@ var swMacro=true;
var socsemFlag=false; var socsemFlag=false;
var constantNGramFilter; var constantNGramFilter;
// var nodeFilterA_past = ""
// var nodeFilterA_now = ""
// var nodeFilterB_past = ""
// var nodeFilterB_now = ""
var lastEdgeFilterA = "-"
// var edgeFilterB_past = ""
// var edgeFilterB_now = ""
var overviewWidth = 200; var overviewWidth = 200;
var overviewHeight = 175; var overviewHeight = 175;
......
This diff is collapsed.
$("#zoomSlider").slider({
orientation: "vertical",
value: 10,
min: 0,
max: 100,
range: "min",
step: 1,
slide: function( event, ui ) {
console.log("ui.value : "+ui.value)
}
});
...@@ -337,8 +337,84 @@ function justhide(){ ...@@ -337,8 +337,84 @@ function justhide(){
//=========================== < FILTERS-SLIDERS > ===========================// //=========================== < FILTERS-SLIDERS > ===========================//
function OrganizeEdgeWeightsForSlider( edgtype ) {
// ( 1 )
// get visible sigma edges
visible_edges=partialGraph._core.graph.edges.filter(function(e) {
return !e['hidden'] && e["label"]==edgtype;
});
// ( 2 )
// extract [ "edgeID" : edgeWEIGHT ]
// and save this into edges_weight
var edges_weight=[]
for (var i in visible_edges) {
e = visible_edges[i]
id = e.id
edges_weight[id]=e.weight
// pr(id+"\t:\t"+e.weight)
}
// ( 3 )
// order dict edges_weight by edge weight
var result = ArraySortByValue(edges_weight, function(a,b){
return a-b
//ASCENDENT
});
// // ( 4 )
// printing ordered ASC by weigth
// for (var i in result) {
// r = result[i]
// edgeid = r.key
// edgeweight = r.value
// pr(edgeid+"\t:\t"+edgeweight)
// // e = result[i]
// // pr(e.weight)
// }
var nb_E = result.length
var magnitude = (""+nb_E).length //order of magnitude of #visibleedges
var exponent = magnitude - 1
var steps = Math.pow(10,exponent) // #(10 ^ magnit-1) steps
var stepsize = Math.round(nb_E/steps)// ~~(visibledges / #steps)
// pr("-----------------------------------")
// pr("number of visible edges: "+nb_E);
// pr("result array:")
// pr(result)
// pr("magnitude : "+magnitude)
// pr("number of steps : "+steps)
// pr("size of one step : "+stepsize)
// pr("-----------------------------------")
var finalarray = []
var counter=0
for(var i = 0; i < steps; i++) {
// pr(i)
var edgIDs = []
for(var j = 0; j < stepsize; j++) {
if(!isUndef(result[counter])) {
k = result[counter].key
// w = result[counter].value
// pr("\t["+counter+"] : "+w)
edgIDs.push(k)
}
counter++;
}
if(edgIDs.length==0) break;
finalarray[i] = edgIDs
}
return {"steps":finalarray.length,"finalarray":finalarray}
}
function updateEdgeFilter(edgeFilterName) { function updateEdgeFilter(edgeFilterName) {
pr("Updating filter_ "+edgeFilterName); pr("nothing: Updating edge filter_ "+edgeFilterName);
/*
thing=""; thing="";
if(edgeFilterName=="social") { if(edgeFilterName=="social") {
edgeFilterName="#sliderAEdgeWeight"; edgeFilterName="#sliderAEdgeWeight";
...@@ -445,9 +521,12 @@ function updateEdgeFilter(edgeFilterName) { ...@@ -445,9 +521,12 @@ function updateEdgeFilter(edgeFilterName) {
}); });
} }
}); });
*/
} }
function updateBothEdgeFilters() { function updateBothEdgeFilters() {
pr("nothing: Updating both edge filters");
/*
edges=partialGraph._core.graph.edges.filter(function(e) { edges=partialGraph._core.graph.edges.filter(function(e) {
return !e['hidden']; return !e['hidden'];
});; });;
...@@ -564,10 +643,12 @@ function updateBothEdgeFilters() { ...@@ -564,10 +643,12 @@ function updateBothEdgeFilters() {
}); });
} }
}); });
*/
} }
function updateNodeFilter(nodeFilterName) { function updateNodeFilter(nodeFilterName) {
pr("nothing: Updating node filter_ "+nodeFilterName);
/*
scholarsNodesBySize=[]; scholarsNodesBySize=[];
keywordsNodesBySize=[]; keywordsNodesBySize=[];
nodesSortedBySize=[]; nodesSortedBySize=[];
...@@ -638,9 +719,12 @@ function updateNodeFilter(nodeFilterName) { ...@@ -638,9 +719,12 @@ function updateNodeFilter(nodeFilterName) {
// }); // });
// } // }
// }); // });
*/
} }
function updateBothNodeFilters() { function updateBothNodeFilters() {
pr("nothing: Updating both node filters");
/*
nodes=partialGraph._core.graph.nodes.filter(function(n) { nodes=partialGraph._core.graph.nodes.filter(function(n) {
return !n['hidden']; return !n['hidden'];
}); });
...@@ -727,6 +811,7 @@ function updateBothNodeFilters() { ...@@ -727,6 +811,7 @@ function updateBothNodeFilters() {
}); });
} }
}); });
*/
} }
//=========================== </ FILTERS-SLIDERS > ===========================// //=========================== </ FILTERS-SLIDERS > ===========================//
......
...@@ -70,7 +70,7 @@ function sigmaLimits(){ ...@@ -70,7 +70,7 @@ function sigmaLimits(){
} }
function bringTheNoise(pathfile,type){ function bringTheNoise(pathfile,type){
// $('.modal').modal('show'); // $('.modal').modal('show');
// === get width and height === // // === get width and height === //
sigmaLimits(); sigmaLimits();
...@@ -187,6 +187,7 @@ function bringTheNoise(pathfile,type){ ...@@ -187,6 +187,7 @@ function bringTheNoise(pathfile,type){
if(type=="unique_id") { if(type=="unique_id") {
pr("bring the noise, case: unique_id"); pr("bring the noise, case: unique_id");
pr(getClientTime()+" : DataExt Ini"); pr(getClientTime()+" : DataExt Ini");
// < === DATA EXTRACTION === >
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: bridge["forNormalQuery"], url: bridge["forNormalQuery"],
...@@ -231,22 +232,6 @@ function bringTheNoise(pathfile,type){ ...@@ -231,22 +232,6 @@ function bringTheNoise(pathfile,type){
pr(getClientTime()+" : Fin FA2"); pr(getClientTime()+" : Fin FA2");
console.log("Parsing and FA2 complete."); console.log("Parsing and FA2 complete.");
// < === ASYNCHRONOUS FA2.JS DONE!! === > // < === ASYNCHRONOUS FA2.JS DONE!! === >
// // leftPanel("close");
// $("#closemodal").click();//modal.hide doesnt work :c
// // startForceAtlas2(partialGraph._core.graph);r(
// cancelSelection(false);
// $("#tips").html(getTips());
// //$('#sigma-example').css('background-color','white');
// $("#category-B").hide();
// $("#labelchange").hide();
// $("#availableView").hide();
// showMeSomeLabels(6);
// initializeMap();
// updateMap();
// updateDownNodeEvent(false);
// partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw(2,2,2);
theListeners(); theListeners();
}); });
}, },
...@@ -279,35 +264,6 @@ function theListeners(){ ...@@ -279,35 +264,6 @@ function theListeners(){
saveGEXF(); saveGEXF();
}); });
// $("#aUnfold").click(function() {
// _cG = $("#leftcolumn");
// anchototal=$('#fixedtop').width();
// sidebar=_cG.width();
//
// if (_cG.offset().left < 0) {
// _cG.animate({
// "left" : sidebar+"px"
// }, function() {
// $("#aUnfold").attr("class","leftarrow");
// $('#sigma-example').width(anchototal-sidebar);
// $("#ctlzoom").css({
// left: (sidebar+10)+"px"
// });
// });
// } else {
// _cG.animate({
// "left" : "-" + _cG.width() + "px"
// }, function() {
// $("#aUnfold").attr("class","rightarrow");
// $('#sigma-example').width(anchototal);
// $("#ctlzoom").css({
// left: "0px"
// });
// });
// }
// return false;
// });
//
/******************* /SEARCH ***********************/ /******************* /SEARCH ***********************/
$.ui.autocomplete.prototype._renderItem = function(ul, item) { $.ui.autocomplete.prototype._renderItem = function(ul, item) {
var searchVal = $("#searchinput").val(); var searchVal = $("#searchinput").val();
...@@ -431,7 +387,7 @@ function theListeners(){ ...@@ -431,7 +387,7 @@ function theListeners(){
} }
}); });
// minimap stuff
// $("#overview") // $("#overview")
// .mousemove(onOverviewMove) // .mousemove(onOverviewMove)
// .mousedown(startMove) // .mousedown(startMove)
...@@ -447,12 +403,8 @@ function theListeners(){ ...@@ -447,12 +403,8 @@ function theListeners(){
}) })
.contextmenu(function(){ .contextmenu(function(){
return false; return false;
}); })
// .mousemove(onOverviewMove) .mousewheel(onGraphScroll);
// .mousedown(startMove)
// .mouseup(endMove)
// .mouseout(endMove)
// .mousewheel(onGraphScroll); -> it doesn't answer!
$(document).keydown(function(e) { $(document).keydown(function(e) {
if( e.shiftKey || e.which==16 ) { if( e.shiftKey || e.which==16 ) {
...@@ -478,23 +430,23 @@ function theListeners(){ ...@@ -478,23 +430,23 @@ function theListeners(){
range: "min", range: "min",
step: 0.1, step: 0.1,
slide: function( event, ui ) { slide: function( event, ui ) {
pr("*******lalala***********") // pr("*******lalala***********")
pr(partialGraph.position().ratio) // pr(partialGraph.position().ratio)
pr(sigmaJsMouseProperties.minRatio) // pr(sigmaJsMouseProperties.minRatio)
pr(sigmaJsMouseProperties.maxRatio) // pr(sigmaJsMouseProperties.maxRatio)
partialGraph.zoomTo( partialGraph.zoomTo(
partialGraph._core.width / 2, partialGraph._core.width / 2,
partialGraph._core.height / 2, partialGraph._core.height / 2,
ui.value); ui.value);
} }
}); });
$("#zoomPlusButton").click(function () { $("#zoomPlusButton").click(function () {
partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 1.5); partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 1.5);
$("#zoomSlider").slider("value",partialGraph.position().ratio); $("#zoomSlider").slider("value",partialGraph.position().ratio);
return false; return false;
}); });
$("#zoomMinusButton").click(function () { $("#zoomMinusButton").click(function () {
partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5); partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5);
$("#zoomSlider").slider("value",partialGraph.position().ratio); $("#zoomSlider").slider("value",partialGraph.position().ratio);
...@@ -502,42 +454,93 @@ function theListeners(){ ...@@ -502,42 +454,93 @@ function theListeners(){
}); });
$("#edgesButton").click(function () { $("#edgesButton").click(function () {
if(fa2enabled===false){ if(!fa2enabled){
edgesTF=true;
fa2enabled=true; fa2enabled=true;
}
if(edgesTF==false){
partialGraph.stopForceAtlas2();
partialGraph.draw();
edgesTF=true;
}
else {
partialGraph.startForceAtlas2(); partialGraph.startForceAtlas2();
edgesTF=false; } else {
partialGraph.stopForceAtlas2();
} }
}); });
//finished
$("#sliderANodeWeight").freshslider({ $("#sliderANodeWeight").freshslider({
range: true, range: true,
step:1, step:1,
value:[10, 60], value:[10, 60],
enabled: false,
onchange:function(low, high){ onchange:function(low, high){
console.log(low, high); console.log(low, high);
} }
}); });
var filterparams = OrganizeEdgeWeightsForSlider ( "nodes1" )
var steps = filterparams["steps"]
var finalarray = filterparams["finalarray"]
//finished
$("#sliderAEdgeWeight").freshslider({ $("#sliderAEdgeWeight").freshslider({
range: true, range: true,
step:1, step: 1,
value:[10, 100], min:0,
onchange:function(low, high){ max:steps-1,
console.log(low, high); onchange:function(low, high){
var filtervalue = low+"-"+high
// pr("filterNOW: "+filtervalue+" | filterPAST: "+lastEdgeFilterA+" => "+(filtervalue!=lastEdgeFilterA))
if(filtervalue!=lastEdgeFilterA) {
if(lastEdgeFilterA=="-") {
pushEdgesFilterA(filtervalue)
return false
}
// $.doTimeout(300,function (){
for(var i in finalarray) {
ids = finalarray[i]
if(i>=low && i<=high){
for(var id in ids) {
edgeid = ids[id]
add1Edge(edgeid)
// partialGraph.addEdge(edgeid,Edges[edgeid].source,target,edge);
// unHideElem(edgeid)
}
} else {
for(var id in ids) {
edgeid = ids[id]
remove1Edge(edgeid)
// hideElem(edgeid)
}
}
}
pushEdgesFilterA(filtervalue)
partialGraph.refresh()
partialGraph.draw()
// });
}
// pr("filterNOW: "+filtervalue+" | filterPAST: "+lastEdgeFilterA+" => "+(filtervalue!=lastEdgeFilterA))
} }
}); });
//finished
$("#sliderANodeSize").freshslider({ $("#sliderANodeSize").freshslider({
step:1, step:1,
value:10, min:1,
max:25,
value:1,
onchange:function(value){ onchange:function(value){
console.log(value); $.doTimeout(100,function (){2
partialGraph.iterNodes(function (n) {
if(Nodes[n.id].type==catSoc) {
n.size = parseFloat(Nodes[n.id].size) + parseFloat((value-1))*0.3;
}
});
partialGraph.draw();
});
} }
}); });
...@@ -549,6 +552,7 @@ function theListeners(){ ...@@ -549,6 +552,7 @@ function theListeners(){
console.log(low, high); console.log(low, high);
} }
}); });
$("#sliderBEdgeWeight").freshslider({ $("#sliderBEdgeWeight").freshslider({
range: true, range: true,
step:1, step:1,
...@@ -557,13 +561,26 @@ function theListeners(){ ...@@ -557,13 +561,26 @@ function theListeners(){
console.log(low, high); console.log(low, high);
} }
}); });
//finished
$("#sliderBNodeSize").freshslider({ $("#sliderBNodeSize").freshslider({
step:1, step:1,
value:20, min:1,
max:25,
value:1,
onchange:function(value){ onchange:function(value){
console.log(value); $.doTimeout(100,function (){
partialGraph.iterNodes(function (n) {
if(Nodes[n.id].type==catSem) {
n.size = parseFloat(Nodes[n.id].size) + parseFloat((value-1))*0.3;
}
});
partialGraph.draw();
});
} }
}); });
//finished
$("#unranged-value").freshslider({ $("#unranged-value").freshslider({
step: 1, step: 1,
min:cursor_size_min, min:cursor_size_min,
...@@ -626,17 +643,5 @@ function theListeners(){ ...@@ -626,17 +643,5 @@ function theListeners(){
// }); // });
// } // }
// }); // });
// $("#sliderSelectionZone").slider({
// value: cursor_size,
// min: parseFloat(cursor_size_min),
// max: parseFloat(cursor_size_max),
// animate: true,
// change: function(event, ui) {
// cursor_size= ui.value;
// //if(cursor_size==0) updateDownNodeEvent(false);
// //else updateDownNodeEvent(true);
// //return callSlider("#sliderSelectionZone", "selectionRadius");
// }
// });
} }
This diff is collapsed.
...@@ -101,57 +101,58 @@ function endMove(evt){ ...@@ -101,57 +101,58 @@ function endMove(evt){
} }
function onGraphScroll(evt, delta) { function onGraphScroll(evt, delta) {
partialGraph.totalScroll += delta; $("#zoomSlider").slider("value",partialGraph.position().ratio);
if (Math.abs(partialGraph.totalScroll) >= 1) { // partialGraph.totalScroll += delta;
if (partialGraph.totalScroll < 0) { // if (Math.abs(partialGraph.totalScroll) >= 1) {
//ZoomOUT // if (partialGraph.totalScroll < 0) {
if (partialGraph.position().ratio > sigmaJsMouseProperties.minRatio) { // //ZoomOUT
//partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5); // if (partialGraph.position().ratio > sigmaJsMouseProperties.minRatio) {
//var _el = $(this), // //partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5);
//_off = $(this).offset(), // //var _el = $(this),
//_deltaX = evt.pageX - _el.width() / 2 - _off.left, // //_off = $(this).offset(),
//_deltaY = evt.pageY - _el.height() / 2 - _off.top; // //_deltaX = evt.pageX - _el.width() / 2 - _off.left,
var // //_deltaY = evt.pageY - _el.height() / 2 - _off.top;
mx=evt.offsetX, // var
my=evt.offsetY; // mx=evt.offsetX,
partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)), // my=evt.offsetY;
partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight)); // partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)),
// partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight));
// console.log("mx: "+mx+" - my: "+ my); // // console.log("mx: "+mx+" - my: "+ my);
// console.log("cx: "+cx+" - cy: "+ cy); // // console.log("cx: "+cx+" - cy: "+ cy);
// partialGraph.centreX =cx; // // partialGraph.centreX =cx;
// partialGraph.centreY =cy; // // partialGraph.centreY =cy;
partialGraph.zoomTo(partialGraph.centreX, partialGraph.centreY, partialGraph._core.mousecaptor.ratio * 0.5); // partialGraph.zoomTo(partialGraph.centreX, partialGraph.centreY, partialGraph._core.mousecaptor.ratio * 0.5);
// partialGraph.centreX -= ( Math.SQRT2 - 1 ) * _deltaX / partialGraph.echelleGenerale; // // partialGraph.centreX -= ( Math.SQRT2 - 1 ) * _deltaX / partialGraph.echelleGenerale;
// partialGraph.centreY -= ( Math.SQRT2 - 1 ) * _deltaY / partialGraph.echelleGenerale; // // partialGraph.centreY -= ( Math.SQRT2 - 1 ) * _deltaY / partialGraph.echelleGenerale;
// partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5); // // partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5);
$("#zoomSlider").slider("value",partialGraph.position().ratio); // $("#zoomSlider").slider("value",partialGraph.position().ratio);
} // }
} else { // } else {
//ZoomIN // //ZoomIN
if (partialGraph.position().ratio < sigmaJsMouseProperties.maxRatio) { // if (partialGraph.position().ratio < sigmaJsMouseProperties.maxRatio) {
// partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 1.5); // // partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 1.5);
// partialGraph.echelleGenerale = Math.pow( Math.SQRT2, partialGraph.position().ratio ); // // partialGraph.echelleGenerale = Math.pow( Math.SQRT2, partialGraph.position().ratio );
//var _el = $(this), // //var _el = $(this),
//_off = $(this).offset(), // //_off = $(this).offset(),
//_deltaX = evt.pageX - _el.width() / 2 - _off.left, // //_deltaX = evt.pageX - _el.width() / 2 - _off.left,
//_deltaY = evt.pageY - _el.height() / 2 - _off.top; // //_deltaY = evt.pageY - _el.height() / 2 - _off.top;
var // var
mx=evt.offsetX, // mx=evt.offsetX,
my=evt.offsetY; // my=evt.offsetY;
partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)), // partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)),
partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight)); // partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight));
// console.log("mx: "+mx+" - my: "+ my); // // console.log("mx: "+mx+" - my: "+ my);
// console.log("cx: "+cx+" - cy: "+ cy); // // console.log("cx: "+cx+" - cy: "+ cy);
// partialGraph.centreX =cx; // // partialGraph.centreX =cx;
// partialGraph.centreY =cy; // // partialGraph.centreY =cy;
partialGraph.zoomTo(partialGraph.centreX, partialGraph.centreY, partialGraph._core.mousecaptor.ratio * 1.5); // partialGraph.zoomTo(partialGraph.centreX, partialGraph.centreY, partialGraph._core.mousecaptor.ratio * 1.5);
$("#zoomSlider").slider("value",partialGraph.position().ratio); // $("#zoomSlider").slider("value",partialGraph.position().ratio);
} // }
} // }
partialGraph.totalScroll = 0; // partialGraph.totalScroll = 0;
} // }
} }
function initializeMap() { function initializeMap() {
......
...@@ -248,7 +248,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) { ...@@ -248,7 +248,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) {
var convg= ((Math.pow(nodes.length,2))/promdxdy); /**/ var convg= ((Math.pow(nodes.length,2))/promdxdy); /**/
var swingingVSnodes_length = swingingSum/nodes.length; /**/ var swingingVSnodes_length = swingingSum/nodes.length; /**/
if(convg > swingingVSnodes_length){ if(stopcriteria && convg > swingingVSnodes_length){
if(numberOfDocs==nodes.length){ if(numberOfDocs==nodes.length){
socialConverged++; socialConverged++;
} }
...@@ -963,11 +963,10 @@ sigma.forceatlas2.Region.prototype.applyForce = function(n, Force, theta) { ...@@ -963,11 +963,10 @@ 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===true) { if(fa2enabled) {
this.forceatlas2 = new sigma.forceatlas2.ForceAtlas2(this._core.graph); this.forceatlas2 = new sigma.forceatlas2.ForceAtlas2(this._core.graph);
this.forceatlas2.setAutoSettings(); this.forceatlas2.setAutoSettings();
this.forceatlas2.init(); this.forceatlas2.init();
//}
$("#overviewzone").hide(); $("#overviewzone").hide();
this.addGenerator('forceatlas2', this.forceatlas2.atomicGo, function(){ this.addGenerator('forceatlas2', this.forceatlas2.atomicGo, function(){
return true; return true;
...@@ -976,6 +975,7 @@ sigma.publicPrototype.startForceAtlas2 = function() { ...@@ -976,6 +975,7 @@ sigma.publicPrototype.startForceAtlas2 = function() {
}; };
sigma.publicPrototype.stopForceAtlas2 = function() { sigma.publicPrototype.stopForceAtlas2 = function() {
fa2enabled=false;
this.removeGenerator('forceatlas2'); this.removeGenerator('forceatlas2');
updateMap(); updateMap();
partialGraph.refresh(); partialGraph.refresh();
......
...@@ -505,7 +505,7 @@ sigma.classes.Cascade = function() { ...@@ -505,7 +505,7 @@ sigma.classes.Cascade = function() {
var counter=0; var counter=0;
var actualSel=[]; var actualSel=[];
partialGraph.iterNodes(function(n){ partialGraph.iterNodes(function(n){
if(n.hidden==false){ if(!n.hidden){
distance = Math.sqrt( distance = Math.sqrt(
Math.pow((x1-parseInt(n.displayX)),2) + Math.pow((x1-parseInt(n.displayX)),2) +
Math.pow((y1-parseInt(n.displayY)),2) Math.pow((y1-parseInt(n.displayY)),2)
...@@ -1167,6 +1167,7 @@ sigma.classes.Cascade = function() { ...@@ -1167,6 +1167,7 @@ sigma.classes.Cascade = function() {
'source': self.nodesIndex[source], 'source': self.nodesIndex[source],
'target': self.nodesIndex[target], 'target': self.nodesIndex[target],
'size': 1, 'size': 1,
'dead':false,
'weight': 1, 'weight': 1,
'displaySize': 0.5, 'displaySize': 0.5,
'color': color, 'color': color,
...@@ -1183,6 +1184,7 @@ sigma.classes.Cascade = function() { ...@@ -1183,6 +1184,7 @@ sigma.classes.Cascade = function() {
for (var k in params) { for (var k in params) {
switch (k) { switch (k) {
case 'id': case 'id':
case 'dead':
case 'source': case 'source':
case 'target': case 'target':
break; break;
...@@ -1202,6 +1204,7 @@ sigma.classes.Cascade = function() { ...@@ -1202,6 +1204,7 @@ sigma.classes.Cascade = function() {
case 'label': case 'label':
e[k] = params[k]; e[k] = params[k];
break; break;
default: default:
e['attr'][k] = params[k]; e['attr'][k] = params[k];
} }
...@@ -1225,6 +1228,7 @@ sigma.classes.Cascade = function() { ...@@ -1225,6 +1228,7 @@ sigma.classes.Cascade = function() {
'size': edge['size'], 'size': edge['size'],
'type': edge['type'], 'type': edge['type'],
'weight': edge['weight'], 'weight': edge['weight'],
'dead' : edge['dead'],
'displaySize': edge['displaySize'], 'displaySize': edge['displaySize'],
'label': edge['label'], 'label': edge['label'],
'hidden': edge['hidden'], 'hidden': edge['hidden'],
...@@ -1247,6 +1251,7 @@ sigma.classes.Cascade = function() { ...@@ -1247,6 +1251,7 @@ sigma.classes.Cascade = function() {
for (var k in copy) { for (var k in copy) {
switch (k) { switch (k) {
case 'id': case 'id':
case 'dead':
case 'displaySize': case 'displaySize':
break; break;
case 'weight': case 'weight':
......
...@@ -671,57 +671,88 @@ function extractFromJson(data,seed){ ...@@ -671,57 +671,88 @@ function extractFromJson(data,seed){
if(edge.label=="nodes1"){ if(edge.label=="nodes1"){
if( (typeof partialGraph._core.graph.edgesIndex[target+";"+source])=="undefined" ){ edge.hidden=false;
edge.hidden=false;
} if(isUndef(nodes1[source])) {
else edge.hidden=true;
if((typeof nodes1[source])=="undefined"){
nodes1[source] = { nodes1[source] = {
label: Nodes[source].label, label: Nodes[source].label,
neighbours: [] neighbours: []
}; };
nodes1[source].neighbours.push(target);
} }
else nodes1[source].neighbours.push(target); if(isUndef(nodes1[target])) {
nodes1[target] = {
label: Nodes[target].label,
neighbours: []
};
}
nodes1[source].neighbours.push(target);
nodes1[target].neighbours.push(source);
} }
if(edge.label=="nodes2"){ if(edge.label=="nodes2"){
edge.hidden=true; edge.hidden=true;
if((typeof nodes2[source])=="undefined"){
if(isUndef(nodes2[source])) {
nodes2[source] = { nodes2[source] = {
label: Nodes[source].label, label: Nodes[source].label,
neighbours: [] neighbours: []
}; };
nodes2[source].neighbours.push(target);
} }
else nodes2[source].neighbours.push(target); if(isUndef(nodes2[target])) {
nodes2[target] = {
label: Nodes[target].label,
neighbours: []
};
}
nodes2[source].neighbours.push(target);
nodes2[target].neighbours.push(source);
} }
if(edge.label=="bipartite"){ if(edge.label=="bipartite"){
edge.hidden=true; edge.hidden=true;
// Document to NGram
if((typeof bipartiteD2N[source])=="undefined"){ s = edge.sourceID
bipartiteD2N[source] = {
label: Nodes[source].label, // // Source is Document
neighbours: [] if(Nodes[s].type == catSoc) {
};
if(isUndef(bipartiteD2N[source])) {
bipartiteD2N[source] = {
label: Nodes[source].label,
neighbours: []
};
}
if(isUndef(bipartiteN2D[target])) {
bipartiteN2D[target] = {
label: Nodes[target].label,
neighbours: []
};
}
bipartiteD2N[source].neighbours.push(target); bipartiteD2N[source].neighbours.push(target);
}
else bipartiteD2N[source].neighbours.push(target);
// NGram to Document
if((typeof bipartiteN2D[target])=="undefined"){
bipartiteN2D[target] = {
label: Nodes[target].label,
neighbours: []
};
bipartiteN2D[target].neighbours.push(source); bipartiteN2D[target].neighbours.push(source);
// // Source is NGram
} else {
if(isUndef(bipartiteN2D[source])) {
bipartiteN2D[source] = {
label: Nodes[source].label,
neighbours: []
};
}
if(isUndef(bipartiteD2N[target])) {
bipartiteD2N[target] = {
label: Nodes[target].label,
neighbours: []
};
}
bipartiteN2D[source].neighbours.push(target);
bipartiteD2N[target].neighbours.push(source);
} }
else bipartiteN2D[target].neighbours.push(source);
} }
//edge.hidden=false/**///should be commented //edge.hidden=false/**///should be commented
......
...@@ -54,6 +54,12 @@ function getedgesIndex(){ ...@@ -54,6 +54,12 @@ function getedgesIndex(){
return partialGraph._core.graph.edgesIndex; return partialGraph._core.graph.edgesIndex;
} }
function getVisibleEdges() {
partialGraph._core.graph.edges.filter(function(e) {
return !e['hidden'];
});
}
function getn(id){ function getn(id){
return partialGraph._core.graph.nodesIndex[id]; return partialGraph._core.graph.nodesIndex[id];
} }
......
...@@ -31,7 +31,7 @@ function test2 { ...@@ -31,7 +31,7 @@ function test2 {
for f in $iter for f in $iter
do do
filename=`echo $f | sed s/"\.\/"//g` filename=`echo $f | sed s/"\.\/"//g`
variable=`cat $filename | grep "zoomTo"` variable=`cat $filename | grep "edgesTF"`
if [[ "$variable" != "" ]] if [[ "$variable" != "" ]]
then then
echo $filename echo $filename
......
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