Commit 4d5fba0b authored by Romain Loth's avatar Romain Loth

just remove trailing spaces

parent e013a462
...@@ -11,7 +11,7 @@ SOURCE CODE REPOSITORY ...@@ -11,7 +11,7 @@ SOURCE CODE REPOSITORY
AUTHORS AUTHORS
- Researchers and engineers of the ISC-PIF - Researchers and engineers of the ISC-PIF
David Chavalarias <david dot chavalarias at iscpif ... fr> David Chavalarias <david dot chavalarias at iscpif ... fr>
Samuel Castillo Samuel Castillo
...@@ -25,7 +25,7 @@ TinawebJS is build on Alexis Jacomy's sigmaJS (http://sigmajs.org) ...@@ -25,7 +25,7 @@ TinawebJS is build on Alexis Jacomy's sigmaJS (http://sigmajs.org)
This work is the continuation of the TINA project, an European Union FP7 project - FP7-ICT-2009-C This work is the continuation of the TINA project, an European Union FP7 project - FP7-ICT-2009-C
REQUIREMENTS REQUIREMENTS
WEB BROWSER compatible with javascript : we recommend Chrome/Chromium or Firefox WEB BROWSER compatible with javascript : we recommend Chrome/Chromium or Firefox
HOW TO USE: HOW TO USE:
......
...@@ -9,4 +9,3 @@ sqlite> CREATE TABLE terms (source CHAR(250),suggestion CHAR(250),time CHAR(30)) ...@@ -9,4 +9,3 @@ sqlite> CREATE TABLE terms (source CHAR(250),suggestion CHAR(250),time CHAR(30))
sqlite> .exit sqlite> .exit
> chmod -v 775 crowdsourcing.db > chmod -v 775 crowdsourcing.db
``` ```
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// ==================== // ====================
// Allows suggestions from search box // Allows suggestions from search box
// Our module_name is simultaneously 3 things: // Our module_name is simultaneously 3 things:
// - a DivsFlag for settings_explorerjs // - a DivsFlag for settings_explorerjs
// - our current dir for this module's files (and this init.js) // - our current dir for this module's files (and this init.js)
// - the class of module's html elements // - the class of module's html elements
......
...@@ -24,7 +24,7 @@ $("#searchinput").on("tw:eraseNodeSet", function(e) { ...@@ -24,7 +24,7 @@ $("#searchinput").on("tw:eraseNodeSet", function(e) {
// emptyNodeSet event when Tinawab had a search but with no matches // emptyNodeSet event when Tinawab had a search but with no matches
$("#searchinput").on("tw:emptyNodeSet", function(e) { $("#searchinput").on("tw:emptyNodeSet", function(e) {
$('#savesuggestion').prop('disabled', false) ; $('#savesuggestion').prop('disabled', false) ;
// when query has no match // when query has no match
if (e.nodeIds == null || e.nodeIds.length == 0) { if (e.nodeIds == null || e.nodeIds.length == 0) {
...@@ -59,12 +59,12 @@ function save_suggestions(term) { ...@@ -59,12 +59,12 @@ function save_suggestions(term) {
"data" : term, "data" : term,
"date" : (new Date()).toISOString(), "date" : (new Date()).toISOString(),
} }
// sqlite columns in new table 'terms' // sqlite columns in new table 'terms'
// 0|source|CHAR(250)|0||0 // 0|source|CHAR(250)|0||0
// 1|suggestion|CHAR(250)|0||0 // 1|suggestion|CHAR(250)|0||0
// 2|time|CHAR(30)|0||0 // 2|time|CHAR(30)|0||0
// console.log( "SAVE INFO:" + info ) // console.log( "SAVE INFO:" + info )
$.ajax({ $.ajax({
type: "POST", type: "POST",
...@@ -84,21 +84,21 @@ function save_suggestions(term) { ...@@ -84,21 +84,21 @@ function save_suggestions(term) {
p.append(i); p.append(i);
p.append(' was saved as a suggestion'); p.append(' was saved as a suggestion');
$("#crowdsourcing_answer").html(p) ; $("#crowdsourcing_answer").html(p) ;
// show "saved" icon // show "saved" icon
$("#saveicon").removeClass("glyphicon-save"); $("#saveicon").removeClass("glyphicon-save");
$("#saveicon").addClass("glyphicon-saved"); $("#saveicon").addClass("glyphicon-saved");
// reset state after 3 secs // reset state after 3 secs
setTimeout(function() { setTimeout(function() {
clean_crowdsourcingzone() ; clean_crowdsourcingzone() ;
// if we want to reset the input value too // if we want to reset the input value too
// $("#proposed_terms").val('') ; // $("#proposed_terms").val('') ;
}, 3000); }, 3000);
}, },
error: function(exception) { error: function(exception) {
console.log(exception) console.log(exception)
console.log("exception!:"+exception.status) console.log("exception!:"+exception.status)
} }
...@@ -134,11 +134,11 @@ function clean_crowdsourcingzone() { ...@@ -134,11 +134,11 @@ function clean_crowdsourcingzone() {
//~ }, 3000); //~ }, 3000);
//~ }, 1000); //~ }, 1000);
//~ }, //~ },
//~ //~
//~ error: function(exception) { //~ error: function(exception) {
//~ console.log(exception) //~ console.log(exception)
//~ console.log("exception!:"+exception.status) //~ console.log("exception!:"+exception.status)
//~ } //~ }
//~ //~
//~ }) //~ })
//~ } //~ }
This diff is collapsed.
...@@ -18,7 +18,7 @@ function ChangeGraphAppearanceByAtt( manualflag ) { ...@@ -18,7 +18,7 @@ function ChangeGraphAppearanceByAtt( manualflag ) {
if(!TW.colorByAtt) return; if(!TW.colorByAtt) return;
// Seeing all the possible attributes! // Seeing all the possible attributes!
var AttsDict = {} var AttsDict = {}
var Atts_2_Exclude = {} var Atts_2_Exclude = {}
var v_nodes = getVisibleNodes(); var v_nodes = getVisibleNodes();
for (var i in v_nodes) { for (var i in v_nodes) {
...@@ -33,11 +33,11 @@ function ChangeGraphAppearanceByAtt( manualflag ) { ...@@ -33,11 +33,11 @@ function ChangeGraphAppearanceByAtt( manualflag ) {
if ( ( typeof(someatt)=="string" && isNaN(Number(someatt)) ) || typeof(someatt)=="object" ) { if ( ( typeof(someatt)=="string" && isNaN(Number(someatt)) ) || typeof(someatt)=="object" ) {
if (!Atts_2_Exclude[a]) Atts_2_Exclude[a]=0; if (!Atts_2_Exclude[a]) Atts_2_Exclude[a]=0;
Atts_2_Exclude[a]++; Atts_2_Exclude[a]++;
} }
} }
var possible_atts = []; var possible_atts = [];
if (!isUndef(TW.Nodes[id].attributes)) if (!isUndef(TW.Nodes[id].attributes))
possible_atts = Object.keys(TW.Nodes[id].attributes) possible_atts = Object.keys(TW.Nodes[id].attributes)
if(!isUndef(v_nodes[i].degree)) if(!isUndef(v_nodes[i].degree))
...@@ -45,15 +45,15 @@ function ChangeGraphAppearanceByAtt( manualflag ) { ...@@ -45,15 +45,15 @@ function ChangeGraphAppearanceByAtt( manualflag ) {
possible_atts.push("clust_louvain") possible_atts.push("clust_louvain")
for(var a in possible_atts){ for(var a in possible_atts){
if ( !AttsDict[ possible_atts[a] ] ) if ( !AttsDict[ possible_atts[a] ] )
AttsDict[ possible_atts[a] ] = 0 AttsDict[ possible_atts[a] ] = 0
AttsDict[ possible_atts[a] ] ++; AttsDict[ possible_atts[a] ] ++;
} }
} }
} }
for(var i in Atts_2_Exclude) for(var i in Atts_2_Exclude)
delete AttsDict[i]; delete AttsDict[i];
var AttsDict_sorted = ArraySortByValue(AttsDict, function(a,b){ var AttsDict_sorted = ArraySortByValue(AttsDict, function(a,b){
...@@ -64,9 +64,9 @@ function ChangeGraphAppearanceByAtt( manualflag ) { ...@@ -64,9 +64,9 @@ function ChangeGraphAppearanceByAtt( manualflag ) {
// console.log( AttsDict_sorted ) // console.log( AttsDict_sorted )
var div_info = ""; var div_info = "";
if( $( ".colorgraph_div" ).length>0 ) if( $( ".colorgraph_div" ).length>0 )
div_info += '<ul id="colorGraph" class="nav navbar-nav navbar-right">' div_info += '<ul id="colorGraph" class="nav navbar-nav navbar-right">'
div_info += ' <li class="dropdown">' div_info += ' <li class="dropdown">'
...@@ -116,7 +116,7 @@ function RunLouvain() { ...@@ -116,7 +116,7 @@ function RunLouvain() {
} }
edge_realdata.push(info) edge_realdata.push(info)
} }
var community = jLouvain().nodes(node_realdata).edges(edge_realdata); var community = jLouvain().nodes(node_realdata).edges(edge_realdata);
var results = community(); var results = community();
for(var i in results) for(var i in results)
TW.Nodes[i].attributes["clust_louvain"]=results[i] TW.Nodes[i].attributes["clust_louvain"]=results[i]
...@@ -130,7 +130,7 @@ function SomeEffect( ClusterCode ) { ...@@ -130,7 +130,7 @@ function SomeEffect( ClusterCode ) {
var Type=raw[0], Cluster=raw[1], clstID=Number(raw[2]); var Type=raw[0], Cluster=raw[1], clstID=Number(raw[2]);
var present = TW.partialGraph.states.slice(-1)[0]; // Last var present = TW.partialGraph.states.slice(-1)[0]; // Last
var type_t0 = present.type; var type_t0 = present.type;
var str_type_t0 = type_t0.map(Number).join("|") var str_type_t0 = type_t0.map(Number).join("|")
console.log( "\t"+str_type_t0) console.log( "\t"+str_type_t0)
...@@ -195,7 +195,7 @@ function SomeEffect( ClusterCode ) { ...@@ -195,7 +195,7 @@ function SomeEffect( ClusterCode ) {
}); });
for(var n in nodes_2_label) { for(var n in nodes_2_label) {
if(n==4) if(n==4)
break break
var ID = nodes_2_label[n].key var ID = nodes_2_label[n].key
TW.partialGraph._core.graph.nodesIndex[ID].forceLabel = true; TW.partialGraph._core.graph.nodesIndex[ID].forceLabel = true;
...@@ -257,7 +257,7 @@ function set_ClustersLegend ( daclass ) { ...@@ -257,7 +257,7 @@ function set_ClustersLegend ( daclass ) {
} }
LegendDiv += ' </ul>' LegendDiv += ' </ul>'
LegendDiv += ' </div>' LegendDiv += ' </div>'
$("#legend_for_clusters").addClass( "my-legend" ); $("#legend_for_clusters").addClass( "my-legend" );
$("#legend_for_clusters").html( LegendDiv ) $("#legend_for_clusters").html( LegendDiv )
...@@ -283,11 +283,11 @@ function getTopPapers(type){ ...@@ -283,11 +283,11 @@ function getTopPapers(type){
data: "type="+type+"&bi="+bi+"&query="+jsonparams+"&gexf="+thisgexf+"&index="+TW.field[getUrlParam.file], data: "type="+type+"&bi="+bi+"&query="+jsonparams+"&gexf="+thisgexf+"&index="+TW.field[getUrlParam.file],
//contentType: "application/json", //contentType: "application/json",
//dataType: 'json', //dataType: 'json',
success : function(data){ success : function(data){
pr(TW.APINAME+'info_div.php?'+"type="+type+"&bi="+bi+"&query="+jsonparams+"&gexf="+thisgexf+"&index="+TW.field[getUrlParam.file]); pr(TW.APINAME+'info_div.php?'+"type="+type+"&bi="+bi+"&query="+jsonparams+"&gexf="+thisgexf+"&index="+TW.field[getUrlParam.file]);
$("#topPapers").html(data); $("#topPapers").html(data);
}, },
error: function(){ error: function(){
pr('Page Not found: getTopPapers'); pr('Page Not found: getTopPapers');
} }
}); });
...@@ -303,22 +303,22 @@ function selectionUni(currentNode){ ...@@ -303,22 +303,22 @@ function selectionUni(currentNode){
opossites = []; opossites = [];
selections = []; selections = [];
TW.partialGraph.refresh(); TW.partialGraph.refresh();
} }
if((typeof selections[currentNode.id])=="undefined"){ if((typeof selections[currentNode.id])=="undefined"){
selections[currentNode.id] = 1; selections[currentNode.id] = 1;
currentNode.active=true; currentNode.active=true;
} }
else { else {
delete selections[currentNode.id]; delete selections[currentNode.id];
currentNode.active=false; currentNode.active=false;
} }
//highlightOpossites(nodes1[currentNode.id].neighbours); //highlightOpossites(nodes1[currentNode.id].neighbours);
// currentNode.color = currentNode.attr['true_color']; // currentNode.color = currentNode.attr['true_color'];
// currentNode.attr['grey'] = 0; // currentNode.attr['grey'] = 0;
//
// //
//
TW.partialGraph.zoomTo(TW.partialGraph._core.width / 2, TW.partialGraph._core.height / 2, 0.8); TW.partialGraph.zoomTo(TW.partialGraph._core.width / 2, TW.partialGraph._core.height / 2, 0.8);
TW.partialGraph.refresh(); TW.partialGraph.refresh();
...@@ -327,60 +327,60 @@ function selectionUni(currentNode){ ...@@ -327,60 +327,60 @@ function selectionUni(currentNode){
//JUST ADEME //JUST ADEME
function camaraButton(){ function camaraButton(){
$("#PhotoGraph").click(function (){ $("#PhotoGraph").click(function (){
//canvas=TW.partialGraph._core.domElements.nodes; //canvas=TW.partialGraph._core.domElements.nodes;
var nodesCtx = TW.partialGraph._core.domElements.nodes; var nodesCtx = TW.partialGraph._core.domElements.nodes;
/* /*
var edgesCtx = document.getElementById("sigma_edges_1").getContext('2d'); var edgesCtx = document.getElementById("sigma_edges_1").getContext('2d');
var edgesImg = edgesCtx.getImageData(0, 0, document.getElementById("sigma_edges_1").width, document.getElementById("sigma_edges_1").height) var edgesImg = edgesCtx.getImageData(0, 0, document.getElementById("sigma_edges_1").width, document.getElementById("sigma_edges_1").height)
nodesCtx.putImageData(edgesImg,0,0); nodesCtx.putImageData(edgesImg,0,0);
//ctx.drawImage(TW.partialGraph._core.domElements.edges,0,0) //ctx.drawImage(TW.partialGraph._core.domElements.edges,0,0)
//var oCanvas = ctx; //var oCanvas = ctx;
*/ */
//div = document.getElementById("sigma_nodes_1").getContext('2d'); //div = document.getElementById("sigma_nodes_1").getContext('2d');
//ctx = div.getContext("2d"); //ctx = div.getContext("2d");
//oCanvas.drawImage(TW.partialGraph._core.domElements.edges,0,0); //oCanvas.drawImage(TW.partialGraph._core.domElements.edges,0,0);
Canvas2Image.saveAsPNG(nodesCtx); Canvas2Image.saveAsPNG(nodesCtx);
/* /*
Canvas2Image.saveAsJPEG(oCanvas); // will prompt the user to save the image as JPEG. Canvas2Image.saveAsJPEG(oCanvas); // will prompt the user to save the image as JPEG.
// Only supported by Firefox. // Only supported by Firefox.
Canvas2Image.saveAsBMP(oCanvas); // will prompt the user to save the image as BMP. Canvas2Image.saveAsBMP(oCanvas); // will prompt the user to save the image as BMP.
// returns an <img> element containing the converted PNG image // returns an <img> element containing the converted PNG image
var oImgPNG = Canvas2Image.saveAsPNG(oCanvas, true); var oImgPNG = Canvas2Image.saveAsPNG(oCanvas, true);
// returns an <img> element containing the converted JPEG image (Only supported by Firefox) // returns an <img> element containing the converted JPEG image (Only supported by Firefox)
var oImgJPEG = Canvas2Image.saveAsJPEG(oCanvas, true); var oImgJPEG = Canvas2Image.saveAsJPEG(oCanvas, true);
// returns an <img> element containing the converted BMP image // returns an <img> element containing the converted BMP image
var oImgBMP = Canvas2Image.saveAsBMP(oCanvas, true); var oImgBMP = Canvas2Image.saveAsBMP(oCanvas, true);
// all the functions also takes width and height arguments. // all the functions also takes width and height arguments.
// These can be used to scale the resulting image: // These can be used to scale the resulting image:
// saves a PNG image scaled to 100x100 // saves a PNG image scaled to 100x100
Canvas2Image.saveAsPNG(oCanvas, false, 100, 100); Canvas2Image.saveAsPNG(oCanvas, false, 100, 100);
*/ */
}); });
} }
function getTips(){ function getTips(){
param=''; param='';
text = text =
"<br>"+ "<br>"+
"Basic Interactions:"+ "Basic Interactions:"+
"<ul>"+ "<ul>"+
...@@ -401,7 +401,7 @@ function getTips(){ ...@@ -401,7 +401,7 @@ function getTips(){
"<li>The 'change level' button allows to change between global view and node centered view,</li>"+ "<li>The 'change level' button allows to change between global view and node centered view,</li>"+
"<li>To explore the neighborhood of a selection click on the 'change level' button.</li>"+ "<li>To explore the neighborhood of a selection click on the 'change level' button.</li>"+
"</ul>"; "</ul>";
$("#tab-container").hide(); $("#tab-container").hide();
$("#tab-container-top").hide(); $("#tab-container-top").hide();
return text; return text;
...@@ -409,7 +409,7 @@ function getTips(){ ...@@ -409,7 +409,7 @@ function getTips(){
function draw1Circle(ctx , x , y , color) { function draw1Circle(ctx , x , y , color) {
ctx.strokeStyle = '#000'; ctx.strokeStyle = '#000';
ctx.lineWidth = 1; ctx.lineWidth = 1;
ctx.fillStyle = color; ctx.fillStyle = color;
...@@ -432,13 +432,13 @@ function trackMouse() { ...@@ -432,13 +432,13 @@ function trackMouse() {
x = TW.partialGraph._core.mousecaptor.mouseX; x = TW.partialGraph._core.mousecaptor.mouseX;
y = TW.partialGraph._core.mousecaptor.mouseY; y = TW.partialGraph._core.mousecaptor.mouseY;
ctx.strokeStyle = '#000'; ctx.strokeStyle = '#000';
ctx.lineWidth = 1; ctx.lineWidth = 1;
ctx.fillStyle = "#71C3FF"; ctx.fillStyle = "#71C3FF";
ctx.globalAlpha = 0.5; ctx.globalAlpha = 0.5;
ctx.beginPath(); ctx.beginPath();
if(TW.partialGraph._core.mousecaptor.ratio>showLabelsIfZoom){ if(TW.partialGraph._core.mousecaptor.ratio>showLabelsIfZoom){
for(var i in TW.partialGraph._core.graph.nodesIndex){ for(var i in TW.partialGraph._core.graph.nodesIndex){
n=TW.partialGraph._core.graph.nodesIndex[i]; n=TW.partialGraph._core.graph.nodesIndex[i];
...@@ -473,7 +473,7 @@ function trackMouse() { ...@@ -473,7 +473,7 @@ function trackMouse() {
if(TW.partialGraph.forceatlas2 && TW.partialGraph.forceatlas2.count<=1) { if(TW.partialGraph.forceatlas2 && TW.partialGraph.forceatlas2.count<=1) {
TW.partialGraph.draw(2,2,2); TW.partialGraph.draw(2,2,2);
} }
} }
ctx.arc(x, y, cursor_size, 0, Math.PI * 2, true); ctx.arc(x, y, cursor_size, 0, Math.PI * 2, true);
//ctx.arc(TW.partialGraph._core.width/2, TW.partialGraph._core.height/2, 4, 0, 2 * Math.PI, true);/*todel*/ //ctx.arc(TW.partialGraph._core.width/2, TW.partialGraph._core.height/2, 4, 0, 2 * Math.PI, true);/*todel*/
ctx.closePath(); ctx.closePath();
...@@ -512,7 +512,7 @@ function ProcessDivsFlags() { ...@@ -512,7 +512,7 @@ function ProcessDivsFlags() {
//both obsolete //both obsolete
function closeDialog () { function closeDialog () {
$('#windowTitleDialog').modal('hide'); $('#windowTitleDialog').modal('hide');
} }
function okClicked () { function okClicked () {
//document.title = document.getElementById ("xlInput").value; //document.title = document.getElementById ("xlInput").value;
......
This diff is collapsed.
...@@ -22,7 +22,7 @@ aside { ...@@ -22,7 +22,7 @@ aside {
} }
#subtitle a:visited { #subtitle a:visited {
color: blue; color: blue;
} }
#workarea { #workarea {
...@@ -132,7 +132,7 @@ a { ...@@ -132,7 +132,7 @@ a {
/* CSS for styled-chart-label */ /* CSS for styled-chart-label */
#workarea #styled-chart-labels .infotext { #workarea #styled-chart-labels .infotext {
} }
#workarea #styled-chart-labels #div_g .dygraph-label { #workarea #styled-chart-labels #div_g .dygraph-label {
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#search_histogram_wrapper{ #search_histogram_wrapper{
margin: 0 ; margin: 0 ;
/* overwrite bootstrap's /* overwrite bootstrap's
* grid element padding*/ * grid element padding*/
padding-right: 2em ; padding-right: 2em ;
margin-left: -.5em ; margin-left: -.5em ;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// ================= // =================
// Presents a histogram from WOS API // Presents a histogram from WOS API
// Our module_name is simultaneously 3 things: // Our module_name is simultaneously 3 things:
// - a DivsFlag for settings_explorerjs // - a DivsFlag for settings_explorerjs
// - our current dir for this module's files (and this init.js) // - our current dir for this module's files (and this init.js)
// - the class of module's html elements // - the class of module's html elements
......
...@@ -8,9 +8,9 @@ function search_proposed_terms_and_draw( the_queries ) { ...@@ -8,9 +8,9 @@ function search_proposed_terms_and_draw( the_queries ) {
// console.log("search_proposed_terms_and_draw:\n" // console.log("search_proposed_terms_and_draw:\n"
// +"i'm searching:\n" // +"i'm searching:\n"
// +JSON.stringify(the_queries)) ; // +JSON.stringify(the_queries)) ;
$("#search_histogram").html("Searching for matching WOS data...") $("#search_histogram").html("Searching for matching WOS data...")
var args = { var args = {
// the_queries is an array of str // the_queries is an array of str
"q": the_queries, "q": the_queries,
...@@ -18,7 +18,7 @@ function search_proposed_terms_and_draw( the_queries ) { ...@@ -18,7 +18,7 @@ function search_proposed_terms_and_draw( the_queries ) {
"until": 2013 "until": 2013
} }
var docs_years = [] ; var docs_years = [] ;
$("#search_histogram") $("#search_histogram")
.html('<p class="micromessage">Waiting for histogram data</p>') .html('<p class="micromessage">Waiting for histogram data</p>')
...@@ -28,12 +28,12 @@ function search_proposed_terms_and_draw( the_queries ) { ...@@ -28,12 +28,12 @@ function search_proposed_terms_and_draw( the_queries ) {
data: args, data: args,
dataType: "json", dataType: "json",
success : function(data, textStatus, jqXHR) { success : function(data, textStatus, jqXHR) {
// ES aggs response, for example // ES aggs response, for example
// data = {"took":91,"total":121673,"aggs":{"publicationCount":{"buckets":[{"key":1989,"doc_count":880},{"key":1990,"doc_count":1088},...,{"key":2012,"doc_count":9543},{"key":2013,"doc_count":8832}]}},"hits":{"total":121673,"max_score":0,"hits":[]}} // data = {"took":91,"total":121673,"aggs":{"publicationCount":{"buckets":[{"key":1989,"doc_count":880},{"key":1990,"doc_count":1088},...,{"key":2012,"doc_count":9543},{"key":2013,"doc_count":8832}]}},"hits":{"total":121673,"max_score":0,"hits":[]}}
// console.log(">> incoming api data <<") // console.log(">> incoming api data <<")
// console.log(data) // console.log(data)
if(data.total==0) { if(data.total==0) {
return false; return false;
} }
...@@ -42,7 +42,7 @@ function search_proposed_terms_and_draw( the_queries ) { ...@@ -42,7 +42,7 @@ function search_proposed_terms_and_draw( the_queries ) {
var elem = data.aggs.publicationCount.buckets[i] var elem = data.aggs.publicationCount.buckets[i]
docs_years.push( [ elem.key+"" , elem.doc_count] ) docs_years.push( [ elem.key+"" , elem.doc_count] )
} }
// counts_by_year_array // counts_by_year_array
draw_histogram(docs_years, "search_histogram") ; draw_histogram(docs_years, "search_histogram") ;
return true ; return true ;
...@@ -50,7 +50,7 @@ function search_proposed_terms_and_draw( the_queries ) { ...@@ -50,7 +50,7 @@ function search_proposed_terms_and_draw( the_queries ) {
}, },
error: function(exception) { error: function(exception) {
console.log("search_proposed_terms_and_draw:exception" console.log("search_proposed_terms_and_draw:exception"
+ JSON.stringify(exception)) + JSON.stringify(exception))
$("#search_histogram") $("#search_histogram")
.html('<p class="micromessage">' .html('<p class="micromessage">'
...@@ -64,7 +64,7 @@ function search_proposed_terms_and_draw( the_queries ) { ...@@ -64,7 +64,7 @@ function search_proposed_terms_and_draw( the_queries ) {
$("#searchinput").on("tw:gotNodeSet", function(e) { $("#searchinput").on("tw:gotNodeSet", function(e) {
// console.log("event 'nodes' --> the event's nodes: " + JSON.stringify(e.nodeIds)) ; // console.log("event 'nodes' --> the event's nodes: " + JSON.stringify(e.nodeIds)) ;
clean_histogram() ; clean_histogram() ;
// now we may want to do other things (draw histogram, suggest term) // now we may want to do other things (draw histogram, suggest term)
newnodesHistogramBehavior(e.nodeIds, e.q) ; newnodesHistogramBehavior(e.nodeIds, e.q) ;
}); });
...@@ -83,12 +83,12 @@ $("#searchinput").on("tw:emptyNodeSet", function(e) { ...@@ -83,12 +83,12 @@ $("#searchinput").on("tw:emptyNodeSet", function(e) {
function newnodesHistogramBehavior(selectedNodeIds, unusedQuery) { function newnodesHistogramBehavior(selectedNodeIds, unusedQuery) {
// console.log('FUN additionalSearchBehavior' + '\nselectedNodeIds:' +JSON.stringify(selectedNodeIds) ) ; // console.log('FUN additionalSearchBehavior' + '\nselectedNodeIds:' +JSON.stringify(selectedNodeIds) ) ;
if( selectedNodeIds != null && selectedNodeIds.length > 0 ) { if( selectedNodeIds != null && selectedNodeIds.length > 0 ) {
// query : IF in the Map -> GO to ISC-API (search and draw it) // query : IF in the Map -> GO to ISC-API (search and draw it)
var selectedLabels = [] ; var selectedLabels = [] ;
for (i in selectedNodeIds) { for (i in selectedNodeIds) {
var thisId = selectedNodeIds[i] var thisId = selectedNodeIds[i]
...@@ -100,7 +100,7 @@ function newnodesHistogramBehavior(selectedNodeIds, unusedQuery) { ...@@ -100,7 +100,7 @@ function newnodesHistogramBehavior(selectedNodeIds, unusedQuery) {
} }
} }
// console.log('\n\n\n<---!--->\nselectedLabels' + JSON.stringify(selectedLabels)) // console.log('\n\n\n<---!--->\nselectedLabels' + JSON.stringify(selectedLabels))
search_proposed_terms_and_draw ( selectedLabels ) ; search_proposed_terms_and_draw ( selectedLabels ) ;
} }
} }
...@@ -108,21 +108,21 @@ function newnodesHistogramBehavior(selectedNodeIds, unusedQuery) { ...@@ -108,21 +108,21 @@ function newnodesHistogramBehavior(selectedNodeIds, unusedQuery) {
// use dygraph lib to draw below the crowdsourcing div // use dygraph lib to draw below the crowdsourcing div
function draw_histogram(counts_by_year_array, div_id) { function draw_histogram(counts_by_year_array, div_id) {
// 1) layout for the div#search_histogram // 1) layout for the div#search_histogram
// /!\ this div *needs* padding:0 /!\; // /!\ this div *needs* padding:0 /!\;
$("#"+div_id).height("15em") ; $("#"+div_id).height("15em") ;
// 2) data preparation // 2) data preparation
//~ var years = [] ; //~ var years = [] ;
//~ for (i in counts_by_year_array) { //~ for (i in counts_by_year_array) {
//~ couple = counts_by_year_array[i] ; //~ couple = counts_by_year_array[i] ;
//~ //~
//~ // x values (year as int) => Date objects //~ // x values (year as int) => Date objects
//~ counts_by_year_array[i][0] = new Date(couple[0]) ; //~ counts_by_year_array[i][0] = new Date(couple[0]) ;
//~ } //~ }
// console.log('=== GRAPH PREPARATION ===') ; // console.log('=== GRAPH PREPARATION ===') ;
// 3) call histogram lib // 3) call histogram lib
new Dygraph(document.getElementById(div_id), new Dygraph(document.getElementById(div_id),
counts_by_year_array, counts_by_year_array,
...@@ -138,5 +138,3 @@ function draw_histogram(counts_by_year_array, div_id) { ...@@ -138,5 +138,3 @@ function draw_histogram(counts_by_year_array, div_id) {
function clean_histogram() { function clean_histogram() {
$("#search_histogram").html("") ; $("#search_histogram").html("") ;
} }
...@@ -52,7 +52,7 @@ var TW = {} ...@@ -52,7 +52,7 @@ var TW = {}
TW.SystemStates.opposites = []; TW.SystemStates.opposites = [];
TW.catSoc = "Document"; TW.catSoc = "Document";
TW.catSem = "NGram"; TW.catSem = "NGram";
TW.strSearchBar = "Select or suggest topics"; TW.strSearchBar = "Select or suggest topics";
var ParseCustom = function () {}; var ParseCustom = function () {};
...@@ -85,7 +85,7 @@ var desirableScholarSize=6; //Remember that all scholars have the same size! ...@@ -85,7 +85,7 @@ var desirableScholarSize=6; //Remember that all scholars have the same size!
*Three states: *Three states:
* - 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=false;//"off";
var stopcriteria = false; var stopcriteria = false;
var iterationsFA2=1000; var iterationsFA2=1000;
...@@ -120,7 +120,7 @@ var sigmaJsMouseProperties = { ...@@ -120,7 +120,7 @@ var sigmaJsMouseProperties = {
maxRatio: 50 maxRatio: 50
}; };
// ============ < / SIGMA.JS PROPERTIES > ============ // ============ < / SIGMA.JS PROPERTIES > ============
// ============ < / DEVELOPER OPTIONS > ============ // ============ < / DEVELOPER OPTIONS > ============
...@@ -165,15 +165,15 @@ var overviewScale = 0.25; ...@@ -165,15 +165,15 @@ var overviewScale = 0.25;
var overviewHover=false; var overviewHover=false;
var moveDelay = 80, zoomDelay = 2; var moveDelay = 80, zoomDelay = 2;
//var Vecindad; //var Vecindad;
TW.partialGraph; TW.partialGraph;
var otherGraph; var otherGraph;
TW.Nodes = []; TW.Nodes = [];
TW.Edges = []; TW.Edges = [];
TW.Clusters = []; TW.Clusters = [];
var nodeslength=0; var nodeslength=0;
var labels = []; var labels = [];
var numberOfDocs=0; var numberOfDocs=0;
var numberOfNGrams=0; var numberOfNGrams=0;
...@@ -232,4 +232,3 @@ var RVUniformC = function(seed){ ...@@ -232,4 +232,3 @@ var RVUniformC = function(seed){
}; };
} }
//unifCont = new RVUniformC(100000000) //unifCont = new RVUniformC(100000000)
This diff is collapsed.
...@@ -237,7 +237,7 @@ var ForceAtlas2 = function(graph) { ...@@ -237,7 +237,7 @@ var ForceAtlas2 = function(graph) {
totalSwinging += n.fa2.mass * swinging; totalSwinging += n.fa2.mass * swinging;
swingingSum += swinging; swingingSum += swinging;
promdxdy += (Math.abs(n.fa2.dx)+Math.abs(n.fa2.dy))/2; /**/ promdxdy += (Math.abs(n.fa2.dx)+Math.abs(n.fa2.dy))/2; /**/
totalEffectiveTraction += n.fa2.mass * totalEffectiveTraction += n.fa2.mass *
0.5 * 0.5 *
Math.sqrt( Math.sqrt(
...@@ -246,15 +246,15 @@ var ForceAtlas2 = function(graph) { ...@@ -246,15 +246,15 @@ var ForceAtlas2 = function(graph) {
); );
} }
}); });
self.p.totalSwinging = totalSwinging; self.p.totalSwinging = totalSwinging;
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(convg > swingingVSnodes_length){
// self.p.banderita=true; // self.p.banderita=true;
// } // }
self.p.totalEffectiveTraction = totalEffectiveTraction; self.p.totalEffectiveTraction = totalEffectiveTraction;
// We want that swingingMovement < tolerance * convergenceMovement // We want that swingingMovement < tolerance * convergenceMovement
...@@ -880,7 +880,7 @@ var Region = function(nodes, depth) { ...@@ -880,7 +880,7 @@ var Region = function(nodes, depth) {
massCenterX: 0, massCenterX: 0,
massCenterY: 0 massCenterY: 0
}; };
console.log("updating mass and geometry"); console.log("updating mass and geometry");
this.updateMassAndGeometry(); this.updateMassAndGeometry();
} }
...@@ -960,7 +960,7 @@ var applyForce = function(n, Force, theta) { ...@@ -960,7 +960,7 @@ var applyForce = function(n, Force, theta) {
// [ NEW STUFF FOR WORKERS ] // [ NEW STUFF FOR WORKERS ]
// 01. Return the values to MainContext when spatialization is finished // 01. Return the values to MainContext when spatialization is finished
var startForceAtlas2 = function(graph,limit_it) { var startForceAtlas2 = function(graph,limit_it) {
...@@ -987,7 +987,7 @@ var applyForce = function(n, Force, theta) { ...@@ -987,7 +987,7 @@ var applyForce = function(n, Force, theta) {
forceatlas2 = new ForceAtlas2(graph); forceatlas2 = new ForceAtlas2(graph);
forceatlas2.setAutoSettings(); forceatlas2.setAutoSettings();
forceatlas2.init(); forceatlas2.init();
count=0; count=0;
flag=false; flag=false;
while(true){ while(true){
...@@ -1000,13 +1000,13 @@ var applyForce = function(n, Force, theta) { ...@@ -1000,13 +1000,13 @@ var applyForce = function(n, Force, theta) {
} }
count++; count++;
if(flag||count>limit_it) break; if(flag||count>limit_it) break;
} }
// pr(forceatlas2.graph.nodes[0].x) // pr(forceatlas2.graph.nodes[0].x)
// pr(forceatlas2.graph.nodes[0].y) // pr(forceatlas2.graph.nodes[0].y)
// console.log("\titerations: "+count) // console.log("\titerations: "+count)
result={ result={
"nodes":forceatlas2.graph.nodes, "nodes":forceatlas2.graph.nodes,
"it":count "it":count
} }
return result; return result;
}; };
...@@ -1024,8 +1024,8 @@ var applyForce = function(n, Force, theta) { ...@@ -1024,8 +1024,8 @@ var applyForce = function(n, Force, theta) {
"nodes":result.nodes, "nodes":result.nodes,
"it":result.it "it":result.it
}); });
}, false); }, false);
// [ / NEW STUFF FOR WORKERS ] // [ / NEW STUFF FOR WORKERS ]
\ No newline at end of file
This diff is collapsed.
...@@ -51,7 +51,7 @@ function isUndef(variable){ ...@@ -51,7 +51,7 @@ function isUndef(variable){
$.fn.toggleClick = function(){ $.fn.toggleClick = function(){
methods = arguments, // store the passed arguments for future reference methods = arguments, // store the passed arguments for future reference
count = methods.length; // cache the number of methods count = methods.length; // cache the number of methods
//use return this to maintain jQuery chainability //use return this to maintain jQuery chainability
return this.each(function(i, item){ return this.each(function(i, item){
...@@ -101,7 +101,7 @@ function ArraySortByValue(array, sortFunc){ ...@@ -101,7 +101,7 @@ function ArraySortByValue(array, sortFunc){
for (var k in array) { for (var k in array) {
if (array.hasOwnProperty(k)) { if (array.hasOwnProperty(k)) {
tmp.push({ tmp.push({
key: k, key: k,
value: array[k] value: array[k]
}); });
if((array[k]) > oposMAX) oposMAX= array[k]; if((array[k]) > oposMAX) oposMAX= array[k];
...@@ -110,8 +110,8 @@ function ArraySortByValue(array, sortFunc){ ...@@ -110,8 +110,8 @@ function ArraySortByValue(array, sortFunc){
tmp.sort(function(o1, o2) { tmp.sort(function(o1, o2) {
return sortFunc(o1.value, o2.value); return sortFunc(o1.value, o2.value);
}); });
return tmp; return tmp;
} }
...@@ -121,7 +121,7 @@ function ArraySortByKey(array, sortFunc){ ...@@ -121,7 +121,7 @@ function ArraySortByKey(array, sortFunc){
for (var k in array) { for (var k in array) {
if (array.hasOwnProperty(k)) { if (array.hasOwnProperty(k)) {
tmp.push({ tmp.push({
key: k, key: k,
value: array[k] value: array[k]
}); });
} }
...@@ -129,10 +129,10 @@ function ArraySortByKey(array, sortFunc){ ...@@ -129,10 +129,10 @@ function ArraySortByKey(array, sortFunc){
tmp.sort(function(o1, o2) { tmp.sort(function(o1, o2) {
return sortFunc(o1.key, o2.key); return sortFunc(o1.key, o2.key);
}); });
return tmp; return tmp;
} }
function is_empty(obj) { function is_empty(obj) {
// Assume if it has a length property with a non-zero value // Assume if it has a length property with a non-zero value
...@@ -214,7 +214,7 @@ normalizeString = function(string, escapeHtml) { ...@@ -214,7 +214,7 @@ normalizeString = function(string, escapeHtml) {
// (or use jquery .text()) // (or use jquery .text())
saferString = function(string) { saferString = function(string) {
// TODO table in an outer scope // TODO table in an outer scope
conversions = { conversions = {
'&' : '&amp;' , '&' : '&amp;' ,
'<' : '&lt;' , '<' : '&lt;' ,
'>' : '&gt;' , '>' : '&gt;' ,
...@@ -222,17 +222,17 @@ saferString = function(string) { ...@@ -222,17 +222,17 @@ saferString = function(string) {
"'" : '&apos;' , "'" : '&apos;' ,
"{" : '&lcub;' , "{" : '&lcub;' ,
"}" : '&rcub;' , "}" : '&rcub;' ,
'%' : '&percnt;' '%' : '&percnt;'
} ; } ;
matchables = /[&<>"'{}%]/g ; matchables = /[&<>"'{}%]/g ;
if (! typeof string == "string") { if (! typeof string == "string") {
return "" ; return "" ;
} }
else { else {
return string.replace( return string.replace(
matchables, matchables,
function(char) { function(char) {
return conversions[char] return conversions[char]
} }
...@@ -243,17 +243,17 @@ saferString = function(string) { ...@@ -243,17 +243,17 @@ saferString = function(string) {
/** /**
* function to load a given css file * function to load a given css file
*/ */
loadCSS = function(href) { loadCSS = function(href) {
var cssLink = $("<link rel='stylesheet' type='text/css' href='"+href+"'>"); var cssLink = $("<link rel='stylesheet' type='text/css' href='"+href+"'>");
$("head").append(cssLink); $("head").append(cssLink);
}; };
/** /**
* function to load a given js file * function to load a given js file
*/ */
loadJS = function(src) { loadJS = function(src) {
var jsLink = $("<script type='text/javascript' src='"+src+"'>"); var jsLink = $("<script type='text/javascript' src='"+src+"'>");
$("head").append(jsLink); $("head").append(jsLink);
}; };
/* /*
Author: Corneliu S. (github.com/upphiminn) Author: Corneliu S. (github.com/upphiminn)
This is a javascript implementation of the Louvain This is a javascript implementation of the Louvain
community detection algorithm (http://arxiv.org/abs/0803.0476) community detection algorithm (http://arxiv.org/abs/0803.0476)
Based on https://bitbucket.org/taynaud/python-louvain/overview Based on https://bitbucket.org/taynaud/python-louvain/overview
*/ */
(function(){ (function(){
...@@ -48,16 +48,16 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -48,16 +48,16 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
}); });
return weight; return weight;
}; };
function get_neighbours_of_node(graph, node){ function get_neighbours_of_node(graph, node){
if(typeof graph._assoc_mat[node] == 'undefined') if(typeof graph._assoc_mat[node] == 'undefined')
return []; return [];
var neighbours = Object.keys(graph._assoc_mat[node]); var neighbours = Object.keys(graph._assoc_mat[node]);
return neighbours; return neighbours;
} }
function get_edge_weight(graph, node1, node2){ function get_edge_weight(graph, node1, node2){
return graph._assoc_mat[node1] ? graph._assoc_mat[node1][node2] : undefined; return graph._assoc_mat[node1] ? graph._assoc_mat[node1][node2] : undefined;
} }
...@@ -113,7 +113,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -113,7 +113,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
return temp; return temp;
} }
//Core-Algorithm Related //Core-Algorithm Related
function init_status(graph, status, part){ function init_status(graph, status, part){
status['nodes_to_com'] = {}; status['nodes_to_com'] = {};
status['total_weight'] = 0; status['total_weight'] = 0;
...@@ -184,13 +184,13 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -184,13 +184,13 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
var weights = {}; var weights = {};
var neighboorhood = get_neighbours_of_node(graph, node);//make iterable; var neighboorhood = get_neighbours_of_node(graph, node);//make iterable;
neighboorhood.forEach(function(neighbour, i){ neighboorhood.forEach(function(neighbour, i){
if(neighbour != node){ if(neighbour != node){
var weight = graph._assoc_mat[node][neighbour] || 1; var weight = graph._assoc_mat[node][neighbour] || 1;
var neighbourcom = status.nodes_to_com[neighbour]; var neighbourcom = status.nodes_to_com[neighbour];
weights[neighbourcom] = (weights[neighbourcom] || 0) + weight; weights[neighbourcom] = (weights[neighbourcom] || 0) + weight;
} }
}); });
return weights; return weights;
...@@ -212,7 +212,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -212,7 +212,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
function __renumber(dict){ function __renumber(dict){
var count = 0; var count = 0;
var ret = clone(dict); //deep copy :) var ret = clone(dict); //deep copy :)
var new_values = {}; var new_values = {};
var dict_keys = Object.keys(dict); var dict_keys = Object.keys(dict);
dict_keys.forEach(function(key){ dict_keys.forEach(function(key){
...@@ -255,7 +255,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -255,7 +255,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
best_increase = incr; best_increase = incr;
best_com = com; best_com = com;
} }
}); });
__insert(node, best_com, neigh_communities[best_com] || 0, status); __insert(node, best_com, neigh_communities[best_com] || 0, status);
...@@ -278,7 +278,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -278,7 +278,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
weight = edge.weight || 1; weight = edge.weight || 1;
var com1 = partition[edge.source]; var com1 = partition[edge.source];
var com2 = partition[edge.target]; var com2 = partition[edge.target];
w_prec = (get_edge_weight(ret, com1, com2) || 0); w_prec = (get_edge_weight(ret, com1, com2) || 0);
var new_weight = (w_prec + weight); var new_weight = (w_prec + weight);
add_edge_to_graph(ret, {'source': com1, 'target': com2, 'weight': new_weight}); add_edge_to_graph(ret, {'source': com1, 'target': com2, 'weight': new_weight});
}); });
...@@ -298,7 +298,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -298,7 +298,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
function generate_dendogram(graph, part_init){ function generate_dendogram(graph, part_init){
if(graph.edges.length == 0){ if(graph.edges.length == 0){
var part = {}; var part = {};
graph.nodes.forEach(function(node,i){ graph.nodes.forEach(function(node,i){
...@@ -326,14 +326,14 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -326,14 +326,14 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
break; break;
partition = __renumber(status.nodes_to_com); partition = __renumber(status.nodes_to_com);
status_list.push(partition); status_list.push(partition);
mod = new_mod; mod = new_mod;
current_graph = induced_graph(partition, current_graph); current_graph = induced_graph(partition, current_graph);
init_status(current_graph, status); init_status(current_graph, status);
} }
return status_list; return status_list;
} }
var core = function(){ var core = function(){
...@@ -361,7 +361,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -361,7 +361,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
'_assoc_mat': assoc_mat }; '_assoc_mat': assoc_mat };
} }
return core; return core;
}; };
core.partition_init = function(prttn){ core.partition_init = function(prttn){
...@@ -373,4 +373,4 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -373,4 +373,4 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
return core; return core;
} }
})(); })();
\ No newline at end of file
...@@ -47,13 +47,13 @@ var AjaxSync = (function(TYPE, URL, DATA, CT , DT) { ...@@ -47,13 +47,13 @@ var AjaxSync = (function(TYPE, URL, DATA, CT , DT) {
} }
Result = { "OK":true , "format":format , "data":data }; Result = { "OK":true , "format":format , "data":data };
}, },
error: function(exception) { error: function(exception) {
Result = { "OK":false , "format":false , "data":exception.status }; Result = { "OK":false , "format":false , "data":exception.status };
} }
}); });
return Result; return Result;
}).index(); }).index();
function getGexfPath(v){ function getGexfPath(v){
var gexfpath=(TW.gexfDictReverse[v])?TW.gexfDictReverse[v]:v; var gexfpath=(TW.gexfDictReverse[v])?TW.gexfDictReverse[v]:v;
return gexfpath; return gexfpath;
...@@ -73,7 +73,7 @@ var file ="" ...@@ -73,7 +73,7 @@ var file =""
if(!isUndef(getUrlParam.mode)) { // if {db|api}.json if(!isUndef(getUrlParam.mode)) { // if {db|api}.json
file = getUrlParam.mode file = getUrlParam.mode
} else { } else {
if( !isUndef(getUrlParam.file) ) if( !isUndef(getUrlParam.file) )
TW.mainfile.unshift( getUrlParam.file ); TW.mainfile.unshift( getUrlParam.file );
var unique_mainfile = TW.mainfile.filter(function(item, pos) { var unique_mainfile = TW.mainfile.filter(function(item, pos) {
...@@ -87,7 +87,7 @@ if(RES["OK"]) { ...@@ -87,7 +87,7 @@ if(RES["OK"]) {
var fileparam;// = { db|api.json , somefile.json|gexf } var fileparam;// = { db|api.json , somefile.json|gexf }
var the_data = RES["data"]; var the_data = RES["data"];
var the_file = ""; var the_file = "";
if ( !isUndef(getUrlParam.mode) && getUrlParam.mode=="db.json") { if ( !isUndef(getUrlParam.mode) && getUrlParam.mode=="db.json") {
...@@ -141,7 +141,7 @@ if(RES["OK"]) { ...@@ -141,7 +141,7 @@ if(RES["OK"]) {
fileparam = sub_RES["format"] fileparam = sub_RES["format"]
pr(the_data.length) pr(the_data.length)
pr(fileparam) pr(fileparam)
getUrlParam.file=the_file; getUrlParam.file=the_file;
console.log(" . .. . -. - .- . - -.") console.log(" . .. . -. - .- . - -.")
console.log(getUrlParam.file) console.log(getUrlParam.file)
...@@ -161,7 +161,7 @@ if(RES["OK"]) { ...@@ -161,7 +161,7 @@ if(RES["OK"]) {
if ( file!="db.json" && file!="api.json" ) if ( file!="db.json" && file!="api.json" )
fileparam = RES["format"]; fileparam = RES["format"];
start = new ParseCustom( fileparam , the_data ); start = new ParseCustom( fileparam , the_data );
categories = start.scanFile(); //user should choose the order of categories categories = start.scanFile(); //user should choose the order of categories
pr("Categories: ") pr("Categories: ")
...@@ -186,11 +186,11 @@ if(RES["OK"]) { ...@@ -186,11 +186,11 @@ if(RES["OK"]) {
for(var i in categories) { for(var i in categories) {
TW.Filters[i] = {} TW.Filters[i] = {}
TW.Filters[i]["#slidercat"+i+"edgesweight"] = true; TW.Filters[i]["#slidercat"+i+"edgesweight"] = true;
} }
// [ Initiating Sigma-Canvas ] // [ Initiating Sigma-Canvas ]
var twjs_ = new TinaWebJS('#sigma-example'); var twjs_ = new TinaWebJS('#sigma-example');
console.log( twjs_.AdjustSigmaCanvas() ); console.log( twjs_.AdjustSigmaCanvas() );
$( window ).resize(function() { console.log(twjs_.AdjustSigmaCanvas()) }); $( window ).resize(function() { console.log(twjs_.AdjustSigmaCanvas()) });
// [ / Initiating Sigma-Canvas ] // [ / Initiating Sigma-Canvas ]
...@@ -242,7 +242,7 @@ if(RES["OK"]) { ...@@ -242,7 +242,7 @@ if(RES["OK"]) {
var past = TW.partialGraph.states.slice(-2)[0] // avant Last var past = TW.partialGraph.states.slice(-2)[0] // avant Last
console.log("previous level: "+past.level) console.log("previous level: "+past.level)
console.log("new level: "+present.level) console.log("new level: "+present.level)
console.log(" % % % % % % % % % % ") console.log(" % % % % % % % % % % ")
console.log("") console.log("")
...@@ -270,7 +270,7 @@ if(RES["OK"]) { ...@@ -270,7 +270,7 @@ if(RES["OK"]) {
$("#category0").hide(); $("#category0").hide();
$("#category1").show(); $("#category1").show();
if($("#slidercat1nodesweight").html()=="") if($("#slidercat1nodesweight").html()=="")
NodeWeightFilter( this.categories , "#slidercat1nodesweight" , this.categories[1], "type" ,"size"); NodeWeightFilter( this.categories , "#slidercat1nodesweight" , this.categories[1], "type" ,"size");
if($("#slidercat1edgesweight").html()=="") if($("#slidercat1edgesweight").html()=="")
...@@ -288,7 +288,7 @@ if(RES["OK"]) { ...@@ -288,7 +288,7 @@ if(RES["OK"]) {
$("#category0").show(); $("#category0").show();
$("#category1").hide(); $("#category1").hide();
if($("#slidercat0nodesweight").html()=="") if($("#slidercat0nodesweight").html()=="")
NodeWeightFilter( this.categories , "#slidercat0nodesweight" , this.categories[0], "type" ,"size"); NodeWeightFilter( this.categories , "#slidercat0nodesweight" , this.categories[0], "type" ,"size");
if($("#slidercat0edgesweight").html()=="") if($("#slidercat0edgesweight").html()=="")
...@@ -300,7 +300,7 @@ if(RES["OK"]) { ...@@ -300,7 +300,7 @@ if(RES["OK"]) {
} }
set_ClustersLegend ( "clust_default" ) set_ClustersLegend ( "clust_default" )
} else { } else {
//finished //finished
$("#slidercat1nodessize").freshslider({ $("#slidercat1nodessize").freshslider({
step:1, step:1,
...@@ -320,7 +320,7 @@ if(RES["OK"]) { ...@@ -320,7 +320,7 @@ if(RES["OK"]) {
TW.partialGraph.draw(); TW.partialGraph.draw();
}); });
} }
}); });
} }
...@@ -370,6 +370,3 @@ ProcessDivsFlags() ; ...@@ -370,6 +370,3 @@ ProcessDivsFlags() ;
$("#searchinput").attr('placeholder', TW.strSearchBar) ; $("#searchinput").attr('placeholder', TW.strSearchBar) ;
console.log("finish") console.log("finish")
...@@ -10,7 +10,7 @@ function cancelSelection (fromTagCloud) { ...@@ -10,7 +10,7 @@ function cancelSelection (fromTagCloud) {
TW.partialGraph.refresh(); TW.partialGraph.refresh();
TW.partialGraph.states.slice(-1)[0].selections=[] TW.partialGraph.states.slice(-1)[0].selections=[]
//Nodes colors go back to normal //Nodes colors go back to normal
overNodes=false; overNodes=false;
e = TW.partialGraph._core.graph.edges; e = TW.partialGraph._core.graph.edges;
...@@ -19,18 +19,18 @@ function cancelSelection (fromTagCloud) { ...@@ -19,18 +19,18 @@ function cancelSelection (fromTagCloud) {
e[i].attr['grey'] = 0; e[i].attr['grey'] = 0;
} }
TW.partialGraph.draw(2,1,2); TW.partialGraph.draw(2,1,2);
TW.partialGraph.iterNodes(function(n){ TW.partialGraph.iterNodes(function(n){
n.active=false; n.active=false;
n.color = n.attr['grey'] ? n.attr['true_color'] : n.color; n.color = n.attr['grey'] ? n.attr['true_color'] : n.color;
n.attr['grey'] = 0; n.attr['grey'] = 0;
}).draw(2,1,2); }).draw(2,1,2);
//Nodes colors go back to normal //Nodes colors go back to normal
if(fromTagCloud==false){ if(fromTagCloud==false){
$("#names").html(""); $("#names").html("");
$("#topPapers").html(""); $("#topPapers").hide(); $("#topPapers").html(""); $("#topPapers").hide();
$("#opossiteNodes").html(""); $("#tab-container").hide(); $("#opossiteNodes").html(""); $("#tab-container").hide();
$("#information").html(""); $("#information").html("");
...@@ -38,11 +38,11 @@ function cancelSelection (fromTagCloud) { ...@@ -38,11 +38,11 @@ function cancelSelection (fromTagCloud) {
$("#unselectbutton").hide(); $("#unselectbutton").hide();
$("#tips").html(getTips()); $("#tips").html(getTips());
} }
// we send our "eraseNodeSet" event // we send our "eraseNodeSet" event
// (signal for plugins that any selection behavior is finished) // (signal for plugins that any selection behavior is finished)
$('#searchinput').trigger("tw:eraseNodeSet"); $('#searchinput').trigger("tw:eraseNodeSet");
for(var i in deselections){ for(var i in deselections){
if( !isUndef(TW.partialGraph._core.graph.nodesIndex[i]) ) { if( !isUndef(TW.partialGraph._core.graph.nodesIndex[i]) ) {
TW.partialGraph._core.graph.nodesIndex[i].forceLabel=false; TW.partialGraph._core.graph.nodesIndex[i].forceLabel=false;
...@@ -57,9 +57,9 @@ function cancelSelection (fromTagCloud) { ...@@ -57,9 +57,9 @@ function cancelSelection (fromTagCloud) {
TW.partialGraph.draw(); TW.partialGraph.draw();
} }
function highlightSelectedNodes(flag){ function highlightSelectedNodes(flag){
pr("\t***methods.js:highlightSelectedNodes(flag)"+flag+" selEmpty:"+is_empty(selections)) pr("\t***methods.js:highlightSelectedNodes(flag)"+flag+" selEmpty:"+is_empty(selections))
if(!is_empty(selections)){ if(!is_empty(selections)){
for(var i in selections) { for(var i in selections) {
if(TW.Nodes[i].type==TW.catSoc && swclickActual=="social"){ if(TW.Nodes[i].type==TW.catSoc && swclickActual=="social"){
node = TW.partialGraph._core.graph.nodesIndex[i]; node = TW.partialGraph._core.graph.nodesIndex[i];
...@@ -73,13 +73,13 @@ function highlightSelectedNodes(flag){ ...@@ -73,13 +73,13 @@ function highlightSelectedNodes(flag){
node = TW.partialGraph._core.graph.nodesIndex[i]; node = TW.partialGraph._core.graph.nodesIndex[i];
node.active = flag; node.active = flag;
} }
else break; else break;
} }
} }
} }
function alertCheckBox(eventCheck){ function alertCheckBox(eventCheck){
if(!isUndef(eventCheck.checked)) checkBox=eventCheck.checked; if(!isUndef(eventCheck.checked)) checkBox=eventCheck.checked;
} }
...@@ -98,7 +98,7 @@ function RefreshState(newNOW){ ...@@ -98,7 +98,7 @@ function RefreshState(newNOW){
if (newNOW!="") { if (newNOW!="") {
PAST = NOW; PAST = NOW;
NOW = newNOW; NOW = newNOW;
// if(NOW=="a" || NOW=="A" || NOW=="AaBb") { // if(NOW=="a" || NOW=="A" || NOW=="AaBb") {
// $("#category-A").show(); // $("#category-A").show();
// } // }
...@@ -108,7 +108,7 @@ function RefreshState(newNOW){ ...@@ -108,7 +108,7 @@ function RefreshState(newNOW){
} }
$("#category-A").hide(); $("#category-A").hide();
$("#category-B").hide(); $("#category-B").hide();
// i=0; for(var s in selections) { i++; break;} // i=0; for(var s in selections) { i++; break;}
// if(is_empty(selections) || i==0) LevelButtonDisable(true); // if(is_empty(selections) || i==0) LevelButtonDisable(true);
// else LevelButtonDisable(false); // else LevelButtonDisable(false);
...@@ -137,7 +137,7 @@ function RefreshState(newNOW){ ...@@ -137,7 +137,7 @@ function RefreshState(newNOW){
$("#semLoader").hide(); $("#semLoader").hide();
$("#category-A").show(); $("#category-A").show();
$("#colorGraph").show(); $("#colorGraph").show();
} }
if(NOW=="B" || NOW=="b") { if(NOW=="B" || NOW=="b") {
var N=( Object.keys(TW.Nodes).filter(function(n){return TW.Nodes[n].type==TW.catSem}) ).length var N=( Object.keys(TW.Nodes).filter(function(n){return TW.Nodes[n].type==TW.catSem}) ).length
...@@ -160,7 +160,7 @@ function RefreshState(newNOW){ ...@@ -160,7 +160,7 @@ function RefreshState(newNOW){
$.doTimeout(30,function (){ $.doTimeout(30,function (){
EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight"); EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
NodeWeightFilter ( "#sliderBNodeWeight" , "NGram", "type" , "size"); NodeWeightFilter ( "#sliderBNodeWeight" , "NGram", "type" , "size");
}); });
} else { } else {
$("#semLoader").css('visibility', 'visible'); $("#semLoader").css('visibility', 'visible');
...@@ -261,7 +261,7 @@ function htmlfied_nodesatts(elems){ ...@@ -261,7 +261,7 @@ function htmlfied_nodesatts(elems){
} }
} else { } else {
information += '<li>' + $("<div/>").html(node.htmlCont).text() + '</li>'; information += '<li>' + $("<div/>").html(node.htmlCont).text() + '</li>';
} }
socnodes.push(information) socnodes.push(information)
} }
...@@ -330,7 +330,7 @@ function updateLeftPanel_fix( sels , oppos ) { ...@@ -330,7 +330,7 @@ function updateLeftPanel_fix( sels , oppos ) {
if(oppos.length>0) { if(oppos.length>0) {
alterNodesDIV+='<div id="opossitesBox">';//tagcloud alterNodesDIV+='<div id="opossitesBox">';//tagcloud
alterNodesDIV+= htmlfied_alternodes( oppos ).join("\n") alterNodesDIV+= htmlfied_alternodes( oppos ).join("\n")
alterNodesDIV+= '</div>'; alterNodesDIV+= '</div>';
} }
...@@ -362,18 +362,18 @@ function updateLeftPanel_fix( sels , oppos ) { ...@@ -362,18 +362,18 @@ function updateLeftPanel_fix( sels , oppos ) {
//using the readmore.js //using the readmore.js
// ive put a limit for nodes-name div // ive put a limit for nodes-name div
// and opposite-nodes div aka tagcloud div // and opposite-nodes div aka tagcloud div
// and im commenting now because github is not // and im commenting now because github is not
// pushing my commit // pushing my commit
// because i need more lines, idk // because i need more lines, idk
$("#names").html(namesDIV).readmore({maxHeight:100}); $("#names").html(namesDIV).readmore({maxHeight:100});
$("#tab-container").show(); $("#tab-container").show();
$("#opossiteNodes").html(alterNodesDIV).readmore({maxHeight:200}); $("#opossiteNodes").html(alterNodesDIV).readmore({maxHeight:200});
$("#sameNodes").html(sameNodesDIV).readmore({maxHeight:200}); $("#sameNodes").html(sameNodesDIV).readmore({maxHeight:200});
$("#information").html(informationDIV); $("#information").html(informationDIV);
$("#tips").html(""); $("#tips").html("");
if(TW.categoriesIndex.length==1) getTopPapers("semantic"); if(TW.categoriesIndex.length==1) getTopPapers("semantic");
else getTopPapers(swclickActual); else getTopPapers(swclickActual);
} }
function printStates() { function printStates() {
...@@ -437,7 +437,7 @@ function graphTagCloudElem(nodes) { ...@@ -437,7 +437,7 @@ function graphTagCloudElem(nodes) {
nodes_2_colour[t]=false; nodes_2_colour[t]=false;
edges_2_colour[s+";"+t]=true; edges_2_colour[s+";"+t]=true;
edges_2_colour[t+";"+s]=true; edges_2_colour[t+";"+s]=true;
if( !selections[t] ) if( !selections[t] )
voisinage[ Number(t) ] = true; voisinage[ Number(t) ] = true;
} }
} }
...@@ -461,10 +461,10 @@ function graphTagCloudElem(nodes) { ...@@ -461,10 +461,10 @@ function graphTagCloudElem(nodes) {
// console.log( "\t" + voisinage[i] + " vs " + voisinage[j] ) // console.log( "\t" + voisinage[i] + " vs " + voisinage[j] )
add1Elem( voisinage[i]+";"+voisinage[j] ) add1Elem( voisinage[i]+";"+voisinage[j] )
} }
} }
} }
futurelevel = false; futurelevel = false;
...@@ -481,7 +481,7 @@ function graphTagCloudElem(nodes) { ...@@ -481,7 +481,7 @@ function graphTagCloudElem(nodes) {
TW.partialGraph.states[avantlastpos] = {}; TW.partialGraph.states[avantlastpos] = {};
TW.partialGraph.states[avantlastpos].level = present.level; TW.partialGraph.states[avantlastpos].level = present.level;
TW.partialGraph.states[avantlastpos].selections = present.selections; TW.partialGraph.states[avantlastpos].selections = present.selections;
TW.partialGraph.states[avantlastpos].type = present.type; TW.partialGraph.states[avantlastpos].type = present.type;
TW.partialGraph.states[avantlastpos].opposites = present.opposites; TW.partialGraph.states[avantlastpos].opposites = present.opposites;
TW.partialGraph.states[avantlastpos].categories = present.categories;//to_del TW.partialGraph.states[avantlastpos].categories = present.categories;//to_del
TW.partialGraph.states[avantlastpos].categoriesDict = present.categoriesDict;//to_del TW.partialGraph.states[avantlastpos].categoriesDict = present.categoriesDict;//to_del
...@@ -503,7 +503,7 @@ function graphTagCloudElem(nodes) { ...@@ -503,7 +503,7 @@ function graphTagCloudElem(nodes) {
} }
function greyEverything(){ function greyEverything(){
nds = TW.partialGraph._core.graph.nodes.filter(function(n) { nds = TW.partialGraph._core.graph.nodes.filter(function(n) {
return !n['hidden']; return !n['hidden'];
}); });
...@@ -515,7 +515,7 @@ function greyEverything(){ ...@@ -515,7 +515,7 @@ function greyEverything(){
} }
nds[i].attr['grey'] = 1; nds[i].attr['grey'] = 1;
} }
eds = TW.partialGraph._core.graph.edges.filter(function(e) { eds = TW.partialGraph._core.graph.edges.filter(function(e) {
return !e['hidden']; return !e['hidden'];
}); });
...@@ -535,18 +535,18 @@ function graphResetColor(){ ...@@ -535,18 +535,18 @@ function graphResetColor(){
eds = TW.partialGraph._core.graph.edges.filter(function(x) { eds = TW.partialGraph._core.graph.edges.filter(function(x) {
return !x['hidden']; return !x['hidden'];
}); });
for(var x in nds){ for(var x in nds){
n=nds[x]; n=nds[x];
n.attr["grey"] = 0; n.attr["grey"] = 0;
n.color = n.attr["true_color"]; n.color = n.attr["true_color"];
} }
for(var x in eds){ for(var x in eds){
e=eds[x]; e=eds[x];
e.attr["grey"] = 0; e.attr["grey"] = 0;
e.color = e.attr["true_color"]; e.color = e.attr["true_color"];
} }
} }
function hideEverything(){ function hideEverything(){
...@@ -595,7 +595,7 @@ function add1Elem(id) { ...@@ -595,7 +595,7 @@ function add1Elem(id) {
} else { // It's an edge! } else { // It's an edge!
if(!isUndef(gete(id))) return; if(!isUndef(gete(id))) return;
if(TW.Edges[id] && !TW.Edges[id].lock){ if(TW.Edges[id] && !TW.Edges[id].lock){
// var present = TW.partialGraph.states.slice(-1)[0]; // var present = TW.partialGraph.states.slice(-1)[0];
var anedge = { var anedge = {
id: id, id: id,
sourceID: TW.Edges[id].source, sourceID: TW.Edges[id].source,
...@@ -625,7 +625,7 @@ function pushFilterValue(filtername,arg){ ...@@ -625,7 +625,7 @@ function pushFilterValue(filtername,arg){
} }
function saveGraph() { function saveGraph() {
size = getByID("check_size").checked size = getByID("check_size").checked
color = getByID("check_color").checked color = getByID("check_color").checked
atts = {"size":size,"color":color} atts = {"size":size,"color":color}
...@@ -657,15 +657,15 @@ function saveGEXF(nodes,edges,atts){ ...@@ -657,15 +657,15 @@ function saveGEXF(nodes,edges,atts){
gexf += '</attributes>\n'; gexf += '</attributes>\n';
gexf += "<nodes>\n"; gexf += "<nodes>\n";
for(var n in nodes){ for(var n in nodes){
gexf += '<node id="'+nodes[n].id+'" label="'+nodes[n].label+'">\n'; gexf += '<node id="'+nodes[n].id+'" label="'+nodes[n].label+'">\n';
gexf += ' <viz:position x="'+nodes[n].x+'" y="'+nodes[n].y+'" z="0" />\n'; gexf += ' <viz:position x="'+nodes[n].x+'" y="'+nodes[n].y+'" z="0" />\n';
if(atts["color"]) gexf += ' <viz:size value="'+nodes[n].size+'" />\n'; if(atts["color"]) gexf += ' <viz:size value="'+nodes[n].size+'" />\n';
if(atts["color"]) { if(atts["color"]) {
col = hex2rga(nodes[n].color); col = hex2rga(nodes[n].color);
gexf += ' <viz:color r="'+col[0]+'" g="'+col[1]+'" b="'+col[2]+'" a="1"/>\n'; gexf += ' <viz:color r="'+col[0]+'" g="'+col[1]+'" b="'+col[2]+'" a="1"/>\n';
} }
gexf += ' <attvalues>\n'; gexf += ' <attvalues>\n';
gexf += ' <attvalue for="0" value="'+nodes[n].type+'"/>\n'; gexf += ' <attvalue for="0" value="'+nodes[n].type+'"/>\n';
gexf += ' <attvalue for="1" value="'+TW.Nodes[nodes[n].id].CC+'"/>\n'; gexf += ' <attvalue for="1" value="'+TW.Nodes[nodes[n].id].CC+'"/>\n';
...@@ -673,7 +673,7 @@ function saveGEXF(nodes,edges,atts){ ...@@ -673,7 +673,7 @@ function saveGEXF(nodes,edges,atts){
gexf += '</node>\n'; gexf += '</node>\n';
} }
gexf += "\n</nodes>\n"; gexf += "\n</nodes>\n";
gexf += "<edges>\n"; gexf += "<edges>\n";
cont = 1; cont = 1;
for(var e in edges){ for(var e in edges){
gexf += '<edge id="'+cont+'" source="'+edges[e].source.id+'" target="'+edges[e].target.id+'" weight="'+edges[e].weight+'">\n'; gexf += '<edge id="'+cont+'" source="'+edges[e].source.id+'" target="'+edges[e].target.id+'" weight="'+edges[e].weight+'">\n';
...@@ -687,9 +687,9 @@ function saveGEXF(nodes,edges,atts){ ...@@ -687,9 +687,9 @@ function saveGEXF(nodes,edges,atts){
} }
function saveGraphIMG(){ function saveGraphIMG(){
var strDownloadMime = "image/octet-stream" var strDownloadMime = "image/octet-stream"
var nodesDiv = TW.partialGraph._core.domElements.nodes; var nodesDiv = TW.partialGraph._core.domElements.nodes;
var nodesCtx = nodesDiv.getContext("2d"); var nodesCtx = nodesDiv.getContext("2d");
......
...@@ -149,7 +149,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -149,7 +149,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
} }
} else { } else {
if( self.firstit ) { if( self.firstit ) {
n.x = self.Ox + self.R*Math.cos(Math.PI*self.stepDeg*mult); n.x = self.Ox + self.R*Math.cos(Math.PI*self.stepDeg*mult);
n.y = self.Oy + self.R*Math.sin(Math.PI*self.stepDeg*mult); n.y = self.Oy + self.R*Math.sin(Math.PI*self.stepDeg*mult);
...@@ -158,7 +158,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -158,7 +158,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
} }
} }
}); });
self.firstit = false ; self.firstit = false ;
...@@ -274,21 +274,21 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -274,21 +274,21 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
if (self.p.edgeWeightInfluence == 0) { if (self.p.edgeWeightInfluence == 0) {
while (i < edges.length && i < self.state.index + cInt) { while (i < edges.length && i < self.state.index + cInt) {
var e = edges[i++]; var e = edges[i++];
if(!e.hidden) { if(!e.hidden) {
Attraction.apply_nn(e.source, e.target, 1); Attraction.apply_nn(e.source, e.target, 1);
} }
} }
} else if (self.p.edgeWeightInfluence == 1) { } else if (self.p.edgeWeightInfluence == 1) {
while (i < edges.length && i < self.state.index + cInt) { while (i < edges.length && i < self.state.index + cInt) {
var e = edges[i++]; var e = edges[i++];
if(!e.hidden) { if(!e.hidden) {
Attraction.apply_nn(e.source, e.target, e.weight || 1); Attraction.apply_nn(e.source, e.target, e.weight || 1);
} }
} }
} else { } else {
while (i < edges.length && i < self.state.index + cInt) { while (i < edges.length && i < self.state.index + cInt) {
var e = edges[i++]; var e = edges[i++];
if(!e.hidden) { if(!e.hidden) {
Attraction.apply_nn( Attraction.apply_nn(
e.source, e.target, e.source, e.target,
Math.pow(e.weight || 1, self.p.edgeWeightInfluence) Math.pow(e.weight || 1, self.p.edgeWeightInfluence)
...@@ -325,7 +325,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -325,7 +325,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
totalSwinging += n.fa2.mass * swinging; totalSwinging += n.fa2.mass * swinging;
swingingSum += swinging; swingingSum += swinging;
promdxdy += (Math.abs(n.fa2.dx)+Math.abs(n.fa2.dy))/2; /**/ promdxdy += (Math.abs(n.fa2.dx)+Math.abs(n.fa2.dy))/2; /**/
totalEffectiveTraction += n.fa2.mass * totalEffectiveTraction += n.fa2.mass *
0.5 * 0.5 *
Math.sqrt( Math.sqrt(
...@@ -334,16 +334,16 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -334,16 +334,16 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
); );
} }
}); });
self.p.totalSwinging = totalSwinging; self.p.totalSwinging = totalSwinging;
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(stopcriteria && (convg > swingingVSnodes_length)){ if(stopcriteria && (convg > swingingVSnodes_length)){
pr("i've applied the stopcriteria: "+self.count) pr("i've applied the stopcriteria: "+self.count)
TW.partialGraph.stopForceAtlas2(); TW.partialGraph.stopForceAtlas2();
} }
self.p.totalEffectiveTraction = totalEffectiveTraction; self.p.totalEffectiveTraction = totalEffectiveTraction;
// We want that swingingMovement < tolerance * convergenceMovement // We want that swingingMovement < tolerance * convergenceMovement
...@@ -362,7 +362,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -362,7 +362,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
// Save old coordinates // Save old coordinates
nodes.forEach(function(n) { nodes.forEach(function(n) {
if(!n.hidden && n.degree>0) { if(!n.hidden && n.degree>0) {
n.old_x = +n.x; n.old_x = +n.x;
n.old_y = +n.y; n.old_y = +n.y;
} }
...@@ -403,7 +403,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -403,7 +403,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
} }
} }
if(self.isolated>0 && self.count%50 == 0) { if(self.isolated>0 && self.count%50 == 0) {
nodes.forEach(function(n) { nodes.forEach(function(n) {
if(n.degree>0) { if(n.degree>0) {
...@@ -994,7 +994,7 @@ sigma.forceatlas2.Region = function(nodes, depth) { ...@@ -994,7 +994,7 @@ sigma.forceatlas2.Region = function(nodes, depth) {
massCenterX: 0, massCenterX: 0,
massCenterY: 0 massCenterY: 0
}; };
this.updateMassAndGeometry(); this.updateMassAndGeometry();
} }
...@@ -1130,7 +1130,7 @@ sigma.publicPrototype.startForceAtlas2 = function() { ...@@ -1130,7 +1130,7 @@ sigma.publicPrototype.startForceAtlas2 = function() {
if(isolatedBCauseFilter==ene) { if(isolatedBCauseFilter==ene) {
TW.partialGraph.stopForceAtlas2(); TW.partialGraph.stopForceAtlas2();
return; return;
} }
$("#overviewzone").hide(); $("#overviewzone").hide();
...@@ -1148,7 +1148,7 @@ sigma.publicPrototype.startForceAtlas2 = function() { ...@@ -1148,7 +1148,7 @@ sigma.publicPrototype.startForceAtlas2 = function() {
return; return;
} }
}); });
} }
}; };
......
...@@ -487,7 +487,7 @@ sigma.classes.Cascade = function() { ...@@ -487,7 +487,7 @@ sigma.classes.Cascade = function() {
drawHover(); drawHover();
drawActive(); drawActive();
// if(cursor_size>0){ // if(cursor_size>0){
// pr("moving with mouse-circle ON"); // pr("moving with mouse-circle ON");
// } // }
...@@ -1074,9 +1074,9 @@ sigma.classes.Cascade = function() { ...@@ -1074,9 +1074,9 @@ sigma.classes.Cascade = function() {
var s = 'Edge\'s target "' + target + '" does not exist yet.'; var s = 'Edge\'s target "' + target + '" does not exist yet.';
throw new Error(s); throw new Error(s);
} }
// var ident = params.sourceID.charAt(0)+params.targetID.charAt(0); // var ident = params.sourceID.charAt(0)+params.targetID.charAt(0);
//edge color will be the combination of the 2 node colors //edge color will be the combination of the 2 node colors
var a = self.nodesIndex[source]['color']; var a = self.nodesIndex[source]['color'];
var b = self.nodesIndex[target]['color']; var b = self.nodesIndex[target]['color'];
...@@ -1098,7 +1098,7 @@ sigma.classes.Cascade = function() { ...@@ -1098,7 +1098,7 @@ sigma.classes.Cascade = function() {
var b = (a[2] + b[2]) >> 1; var b = (a[2] + b[2]) >> 1;
// var color = '#'+sigma.tools.rgbToHex(parseFloat(r),parseFloat(g),parseFloat(b)) // var color = '#'+sigma.tools.rgbToHex(parseFloat(r),parseFloat(g),parseFloat(b))
var color = "rgba( "+r+", "+g+" , "+b+" ,0.5)"; var color = "rgba( "+r+", "+g+" , "+b+" ,0.5)";
//pr(params.label); //pr(params.label);
// if(params.label=="nodes1") { // if(params.label=="nodes1") {
// color = "#cedc75"; // color = "#cedc75";
...@@ -1127,7 +1127,7 @@ sigma.classes.Cascade = function() { ...@@ -1127,7 +1127,7 @@ sigma.classes.Cascade = function() {
e['source']['outDegree']++; e['source']['outDegree']++;
e['target']['degree']++; e['target']['degree']++;
e['target']['inDegree']++; e['target']['inDegree']++;
for (var k in params) { for (var k in params) {
switch (k) { switch (k) {
case 'id': case 'id':
...@@ -1271,7 +1271,7 @@ sigma.classes.Cascade = function() { ...@@ -1271,7 +1271,7 @@ sigma.classes.Cascade = function() {
* Deletes every nodes and edges from the graph. * Deletes every nodes and edges from the graph.
* @return {Graph} Returns itself. * @return {Graph} Returns itself.
*/ */
function empty() { function empty() {
if(TW.partialGraph) { if(TW.partialGraph) {
if(TW.partialGraph.forceatlas2) { if(TW.partialGraph.forceatlas2) {
...@@ -1297,7 +1297,7 @@ sigma.classes.Cascade = function() { ...@@ -1297,7 +1297,7 @@ sigma.classes.Cascade = function() {
self.edges.splice(0, self.edges.length); self.edges.splice(0, self.edges.length);
} }
self.edgesIndex = {}; self.edgesIndex = {};
if(self.edgesIndex.length>0) { if(self.edgesIndex.length>0) {
pr("splicing edgesIndex") pr("splicing edgesIndex")
self.edgesIndex.splice(0, self.edgesIndex.length); self.edgesIndex.splice(0, self.edgesIndex.length);
...@@ -1773,7 +1773,7 @@ sigma.classes.Cascade = function() { ...@@ -1773,7 +1773,7 @@ sigma.classes.Cascade = function() {
return self; return self;
}; };
this.emptyGraph = function() { this.emptyGraph = function() {
s.graph.empty(); s.graph.empty();
return self; return self;
...@@ -2223,13 +2223,13 @@ sigma.classes.Cascade = function() { ...@@ -2223,13 +2223,13 @@ sigma.classes.Cascade = function() {
shape = self.p.defaultNodeShape; shape = self.p.defaultNodeShape;
} }
ctx = nodesCtx; ctx = nodesCtx;
ctx.fillStyle = node['color']; ctx.fillStyle = node['color'];
// Node border: // Node border:
ctx.beginPath(); ctx.beginPath();
switch(shape) { switch(shape) {
case 'square': case 'square':
wh=(node['displaySize'] * 2) + self.p.borderSize; wh=(node['displaySize'] * 2) + self.p.borderSize;
...@@ -2237,7 +2237,7 @@ sigma.classes.Cascade = function() { ...@@ -2237,7 +2237,7 @@ sigma.classes.Cascade = function() {
node['displayY']-wh/2, node['displayY']-wh/2,
wh, wh,
wh); wh);
// ctx.strokeRect(node['displayX']-size-(1.3), // ctx.strokeRect(node['displayX']-size-(1.3),
// node['displayY']-size-(1.3), // node['displayY']-size-(1.3),
// (node['displaySize'] * 2) + self.p.borderSize, // (node['displaySize'] * 2) + self.p.borderSize,
...@@ -2257,15 +2257,15 @@ sigma.classes.Cascade = function() { ...@@ -2257,15 +2257,15 @@ sigma.classes.Cascade = function() {
} }
ctx.closePath(); ctx.closePath();
ctx.fill(); ctx.fill();
// Node: // Node:
ctx.beginPath(); ctx.beginPath();
switch(shape) { switch(shape) {
case 'square': case 'square':
wh=size*2; wh=size*2;
ctx.fillRect(node['displayX']-wh/2, ctx.fillRect(node['displayX']-wh/2,
node['displayY']-wh/2, node['displayY']-wh/2,
wh, wh,
wh); wh);
...@@ -2309,12 +2309,12 @@ sigma.classes.Cascade = function() { ...@@ -2309,12 +2309,12 @@ sigma.classes.Cascade = function() {
* @param {Object} edge The edge to draw. * @param {Object} edge The edge to draw.
* @return {Plotter} Returns itself. * @return {Plotter} Returns itself.
*/ */
function drawEdge(edge) { function drawEdge(edge) {
var x1 = edge['source']['displayX']; var x1 = edge['source']['displayX'];
var y1 = edge['source']['displayY']; var y1 = edge['source']['displayY'];
var x2 = edge['target']['displayX']; var x2 = edge['target']['displayX'];
var y2 = edge['target']['displayY']; var y2 = edge['target']['displayY'];
var color = edge['color']; var color = edge['color'];
if(!color) { if(!color) {
var a = edge['source']['color']; var a = edge['source']['color'];
...@@ -2354,7 +2354,7 @@ sigma.classes.Cascade = function() { ...@@ -2354,7 +2354,7 @@ sigma.classes.Cascade = function() {
} }
else { else {
ctx.lineWidth = edge['displaySize'] / 3;/**/ ctx.lineWidth = edge['displaySize'] / 3;/**/
} }
} }
else { else {
//overNodes = TRUE //overNodes = TRUE
...@@ -2402,7 +2402,7 @@ sigma.classes.Cascade = function() { ...@@ -2402,7 +2402,7 @@ sigma.classes.Cascade = function() {
var fontSize;/* = self.p.labelSize == 'fixed' ? var fontSize;/* = self.p.labelSize == 'fixed' ?
self.p.defaultLabelSize : self.p.defaultLabelSize :
self.p.labelSizeRatio * node['displaySize'];*/ self.p.labelSizeRatio * node['displaySize'];*/
fontSize=(self.p.labelSizeRatio*node['displaySize'])<self.p.defaultLabelSize ? fontSize=(self.p.labelSizeRatio*node['displaySize'])<self.p.defaultLabelSize ?
self.p.defaultLabelSize: self.p.defaultLabelSize:
self.p.labelSizeRatio*node['displaySize']; self.p.labelSizeRatio*node['displaySize'];
...@@ -2430,7 +2430,7 @@ sigma.classes.Cascade = function() { ...@@ -2430,7 +2430,7 @@ sigma.classes.Cascade = function() {
function drawHoverNode(node) { function drawHoverNode(node) {
size = Math.round(node['displaySize'] * 10) / 10; size = Math.round(node['displaySize'] * 10) / 10;
ctx = hoverCtx; ctx = hoverCtx;
nodeShape = node['shape']; nodeShape = node['shape'];
if(!nodeShape) { if(!nodeShape) {
nodeShape = self.p.defaultNodeShape; nodeShape = self.p.defaultNodeShape;
...@@ -2439,7 +2439,7 @@ sigma.classes.Cascade = function() { ...@@ -2439,7 +2439,7 @@ sigma.classes.Cascade = function() {
/*var fontSize = self.p.labelSize == 'fixed' ? /*var fontSize = self.p.labelSize == 'fixed' ?
self.p.defaultLabelSize : self.p.defaultLabelSize :
self.p.labelSizeRatio * node['displaySize'];*/ self.p.labelSizeRatio * node['displaySize'];*/
fontSize=(self.p.labelSizeRatio*node['displaySize'])<self.p.defaultLabelSize ? fontSize=(self.p.labelSizeRatio*node['displaySize'])<self.p.defaultLabelSize ?
self.p.defaultLabelSize: self.p.defaultLabelSize:
self.p.labelSizeRatio*node['displaySize']; self.p.labelSizeRatio*node['displaySize'];
...@@ -2485,7 +2485,7 @@ sigma.classes.Cascade = function() { ...@@ -2485,7 +2485,7 @@ sigma.classes.Cascade = function() {
ctx.fillStyle = self.p.nodeBorderColor == 'node' ? ctx.fillStyle = self.p.nodeBorderColor == 'node' ?
(node['color'] || self.p.defaultNodeColor) : (node['color'] || self.p.defaultNodeColor) :
self.p.defaultNodeBorderColor; self.p.defaultNodeBorderColor;
switch(nodeShape) { switch(nodeShape) {
case 'square': case 'square':
ctx.lineWidth = 2; ctx.lineWidth = 2;
...@@ -2553,7 +2553,7 @@ sigma.classes.Cascade = function() { ...@@ -2553,7 +2553,7 @@ sigma.classes.Cascade = function() {
function drawActiveNode(node) { function drawActiveNode(node) {
size = Math.round(node['displaySize'] * 10) / 10; size = Math.round(node['displaySize'] * 10) / 10;
ctx = hoverCtx; ctx = hoverCtx;
if (!isOnScreen(node)) { if (!isOnScreen(node)) {
return self; return self;
} }
...@@ -2562,15 +2562,15 @@ sigma.classes.Cascade = function() { ...@@ -2562,15 +2562,15 @@ sigma.classes.Cascade = function() {
if(!nodeShape) { if(!nodeShape) {
nodeShape = self.p.defaultNodeShape; nodeShape = self.p.defaultNodeShape;
} }
/*var fontSize = self.p.labelSize == 'fixed' ? /*var fontSize = self.p.labelSize == 'fixed' ?
self.p.defaultLabelSize : self.p.defaultLabelSize :
self.p.labelSizeRatio * node['displaySize'];*/ self.p.labelSizeRatio * node['displaySize'];*/
fontSize=(self.p.labelSizeRatio*node['displaySize'])<self.p.defaultLabelSize ? fontSize=(self.p.labelSizeRatio*node['displaySize'])<self.p.defaultLabelSize ?
self.p.defaultLabelSize: self.p.defaultLabelSize:
self.p.labelSizeRatio*node['displaySize']; self.p.labelSizeRatio*node['displaySize'];
ctx.font = (self.p.activeFontStyle || self.p.fontStyle || '') + ' ' + ctx.font = (self.p.activeFontStyle || self.p.fontStyle || '') + ' ' +
fontSize + 'px ' + fontSize + 'px ' +
(self.p.activeFont || self.p.font || ''); (self.p.activeFont || self.p.font || '');
...@@ -2578,13 +2578,13 @@ sigma.classes.Cascade = function() { ...@@ -2578,13 +2578,13 @@ sigma.classes.Cascade = function() {
ctx.fillStyle = self.p.labelHoverBGColor == 'node' ? ctx.fillStyle = self.p.labelHoverBGColor == 'node' ?
(node['color'] || self.p.defaultNodeColor) : (node['color'] || self.p.defaultNodeColor) :
self.p.defaultActiveLabelBGColor; self.p.defaultActiveLabelBGColor;
switch(nodeShape) { switch(nodeShape) {
case 'square': case 'square':
// Node border: // Node border:
ctx.beginPath(); ctx.beginPath();
ctx.lineWidth = 2; ctx.lineWidth = 2;
wh=(node['displaySize'] * 2) + self.p.borderSize; wh=(node['displaySize'] * 2) + self.p.borderSize;
ctx.strokeStyle="red"; ctx.strokeStyle="red";
...@@ -2623,10 +2623,10 @@ sigma.classes.Cascade = function() { ...@@ -2623,10 +2623,10 @@ sigma.classes.Cascade = function() {
ctx.shadowOffsetX = 0; ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0; ctx.shadowOffsetY = 0;
ctx.shadowBlur = 0; ctx.shadowBlur = 0;
// Node border: // Node border:
ctx.beginPath(); ctx.beginPath();
ctx.fillStyle = self.p.nodeBorderColor == 'node' ? ctx.fillStyle = self.p.nodeBorderColor == 'node' ?
(node['color'] || self.p.defaultNodeColor) : (node['color'] || self.p.defaultNodeColor) :
self.p.defaultNodeBorderColor; self.p.defaultNodeBorderColor;
...@@ -2637,11 +2637,11 @@ sigma.classes.Cascade = function() { ...@@ -2637,11 +2637,11 @@ sigma.classes.Cascade = function() {
0, 0,
Math.PI * 2, Math.PI * 2,
true); true);
ctx.closePath(); ctx.closePath();
ctx.fill(); ctx.fill();
// Node: // Node:
ctx.beginPath(); ctx.beginPath();
ctx.fillStyle = self.p.nodeActiveColor == 'node' ? ctx.fillStyle = self.p.nodeActiveColor == 'node' ?
...@@ -2656,7 +2656,7 @@ sigma.classes.Cascade = function() { ...@@ -2656,7 +2656,7 @@ sigma.classes.Cascade = function() {
ctx.closePath(); ctx.closePath();
ctx.fill(); ctx.fill();
break; break;
} }
// Label: // Label:
...@@ -2912,7 +2912,7 @@ sigma.classes.Cascade = function() { ...@@ -2912,7 +2912,7 @@ sigma.classes.Cascade = function() {
); );
TW.partialGraph.centreX = (self.mouseX*(overviewWidth/(TW.partialGraph._core.width-1))); TW.partialGraph.centreX = (self.mouseX*(overviewWidth/(TW.partialGraph._core.width-1)));
TW.partialGraph.centreY = (self.mouseY*(overviewHeight/(TW.partialGraph._core.height-1))); TW.partialGraph.centreY = (self.mouseY*(overviewHeight/(TW.partialGraph._core.height-1)));
if (self.p['blockScroll']) { if (self.p['blockScroll']) {
if (event.preventDefault) { if (event.preventDefault) {
event.preventDefault(); event.preventDefault();
...@@ -3803,4 +3803,3 @@ sigma.classes.Cascade = function() { ...@@ -3803,4 +3803,3 @@ sigma.classes.Cascade = function() {
sigma.publicPrototype = SigmaPublic.prototype; sigma.publicPrototype = SigmaPublic.prototype;
})(); })();
This diff is collapsed.
...@@ -251,6 +251,8 @@ function getArrSubkeys(arr,id) { ...@@ -251,6 +251,8 @@ function getArrSubkeys(arr,id) {
return result; return result;
} }
// color & size scale using an attribute in the nodes' data
function clustersBy(daclass) { function clustersBy(daclass) {
cancelSelection(false); cancelSelection(false);
...@@ -259,6 +261,7 @@ function clustersBy(daclass) { ...@@ -259,6 +261,7 @@ function clustersBy(daclass) {
for(var i in v_nodes) { for(var i in v_nodes) {
var the_node = TW.Nodes[ v_nodes[i].id ] var the_node = TW.Nodes[ v_nodes[i].id ]
var attval = ( isUndef(the_node.attributes) || isUndef(the_node.attributes[daclass]) )? v_nodes[i][daclass]: the_node.attributes[daclass]; var attval = ( isUndef(the_node.attributes) || isUndef(the_node.attributes[daclass]) )? v_nodes[i][daclass]: the_node.attributes[daclass];
console.log("clustersBy begin trace",v_nodes[i].id, attval)
if( !isNaN(parseFloat(attval)) ) { //is float if( !isNaN(parseFloat(attval)) ) { //is float
while(true) { while(true) {
var themult = Math.pow(10,min_pow); var themult = Math.pow(10,min_pow);
...@@ -276,14 +279,24 @@ function clustersBy(daclass) { ...@@ -276,14 +279,24 @@ function clustersBy(daclass) {
var themult = Math.pow(10,min_pow); var themult = Math.pow(10,min_pow);
for(var i in v_nodes) { for(var i in v_nodes) {
var the_node = TW.Nodes[ v_nodes[i].id ] var the_node = TW.Nodes[ v_nodes[i].id ]
// debug
// console.log(the_node.label)
var attval = ( isUndef(the_node.attributes) || isUndef(the_node.attributes[daclass]) )? v_nodes[i][daclass]: the_node.attributes[daclass]; var attval = ( isUndef(the_node.attributes) || isUndef(the_node.attributes[daclass]) )? v_nodes[i][daclass]: the_node.attributes[daclass];
var attnumber = Number(attval); var attnumber = Number(attval);
var round_number = Math.round( attnumber*themult ) ; var round_number = Math.round( attnumber*themult ) ;
console.log({ the_node, "round":round_number , "real":attnumber })
// order per ascii val of label's first letter
// round_number = Math.round(the_node.label.charAt(0).charCodeAt())
// console.log({ "round":round_number , "real":attnumber })
NodeID_Val[v_nodes[i].id] = { "round":round_number , "real":attnumber }; NodeID_Val[v_nodes[i].id] = { "round":round_number , "real":attnumber };
if (round_number<real_min) real_min = round_number; // if (round_number<real_min) real_min = round_number;
if (round_number>real_max) real_max = round_number; // if (round_number>real_max) real_max = round_number;
} }
...@@ -300,14 +313,22 @@ function clustersBy(daclass) { ...@@ -300,14 +313,22 @@ function clustersBy(daclass) {
var Min_color = 0; var Min_color = 0;
var Max_color = 255; var Max_color = 255;
var Min_size = 2; var Min_size = 2;
var Max_size= 6; var Max_size= 5;
for(var i in NodeID_Val) { for(var i in NodeID_Val) {
var newval_color = Math.round( ( Min_color+(NodeID_Val[i]["round"]-real_min)*((Max_color-Min_color)/(real_max-real_min)) ) ); var newval_color = Math.round( ( Min_color+(NodeID_Val[i]["round"]-real_min)*((Max_color-Min_color)/(real_max-real_min)) ) );
var hex_color = rgbToHex(255, (255-newval_color) , 0) var hex_color = rgbToHex(255, (255-newval_color) , 0)
console.log({'round in': NodeID_Val[i]["round"],
'label':TW.partialGraph._core.graph.nodesIndex[i]["label"],
'newval col':newval_color,
'hex_color':hex_color
})
// paint the sigma node
TW.partialGraph._core.graph.nodesIndex[i].color = hex_color TW.partialGraph._core.graph.nodesIndex[i].color = hex_color
var newval_size = Math.round( ( Min_size+(NodeID_Val[i]["round"]-real_min)*((Max_size-Min_size)/(real_max-real_min)) ) ); var newval_size = Math.round( ( Min_size+(NodeID_Val[i]["round"]-real_min)*((Max_size-Min_size)/(real_max-real_min)) ) );
// size it too
TW.partialGraph._core.graph.nodesIndex[i].size = newval_size; TW.partialGraph._core.graph.nodesIndex[i].size = newval_size;
// pr("real:"+ NodeID_Val[i]["real"] + " | newvalue: "+newval_size) // pr("real:"+ NodeID_Val[i]["real"] + " | newvalue: "+newval_size)
...@@ -324,10 +345,13 @@ function clustersBy(daclass) { ...@@ -324,10 +345,13 @@ function clustersBy(daclass) {
var v_edges = getVisibleEdges(); var v_edges = getVisibleEdges();
for(var e in v_edges) { for(var e in v_edges) {
var e_id = v_edges[e].id; var e_id = v_edges[e].id;
// from a
var a = v_edges[e].source.color; var a = v_edges[e].source.color;
// to b
var b = v_edges[e].target.color; var b = v_edges[e].target.color;
a = hex2rga(a); a = hex2rga(a);
b = hex2rga(b); b = hex2rga(b);
// 3x bitwise right shifts
var r = (a[0] + b[0]) >> 1; var r = (a[0] + b[0]) >> 1;
var g = (a[1] + b[1]) >> 1; var g = (a[1] + b[1]) >> 1;
var b = (a[2] + b[2]) >> 1; var b = (a[2] + b[2]) >> 1;
......
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