Commit 15f1f819 authored by Romain Loth's avatar Romain Loth

alternate titles for clustering/colors menu

parent d76dc7f5
...@@ -12,14 +12,21 @@ function newPopup(url) { ...@@ -12,14 +12,21 @@ function newPopup(url) {
// Execution: ChangeGraphAppearanceByAtt( true ) // Execution: ChangeGraphAppearanceByAtt( true )
// It scans the existing node-attributes and t keeps only those which are Numeric. // It scans the existing node-attributes and t keeps only those which are Numeric.
// then, add the button in the html with the sigmaUtils.clustersBy(x) listener. // then, add the button in the html with the sigmaUtils.clustersBy(x) listener.
// [TODO: fonction un peu lourde dans le profilage] // [TODO: fonction un peu lourde dans le profilage => préparer la liste des attributs dès la lecture initiale des données dans parseCustom, ne faire que les conséquences ici]
function ChangeGraphAppearanceByAtt( manualflag ) { function ChangeGraphAppearanceByAtt( manualflag ) {
if ( !isUndef(manualflag) && !TW.colorByAtt ) TW.colorByAtt = manualflag; if ( !isUndef(manualflag) && !TW.handpickedcolor ) TW.handpickedcolor = manualflag;
if(!TW.colorByAtt) return; if(!TW.handpickedcolor) return;
// Seeing all the possible attributes! // Seeing all the possible attributes!
var AttsDict = {} var AttsDict = {}
var AttsTranslations = {
'clust_louvain': 'Groupes de voisins, méthode de Louvain',
'pageranks': 'Importance dans le réseau, méthode Google',
'age': 'Date initiale d\'apparition du terme dans le corpus',
'growth_rate': 'Tendances et oubliés de la semaine',
'modularity_class': 'Groupes de voisins, méthode des classes de modularité'
}
var Atts_2_Exclude = {} var Atts_2_Exclude = {}
for (var j in TW.nodeIds) { for (var j in TW.nodeIds) {
let nid = TW.nodeIds[j] let nid = TW.nodeIds[j]
...@@ -76,6 +83,9 @@ function ChangeGraphAppearanceByAtt( manualflag ) { ...@@ -76,6 +83,9 @@ function ChangeGraphAppearanceByAtt( manualflag ) {
if(att_s == "growth_rate") the_method = "colorsRelByBins" if(att_s == "growth_rate") the_method = "colorsRelByBins"
if(att_s == "age") the_method = "colorsRelByBins" if(att_s == "age") the_method = "colorsRelByBins"
// labels
if(AttsTranslations[att_s]) att_s = AttsTranslations[att_s]
color_menu_info += '<li><a href="#" onclick=\''+the_method+'("'+att_s+'")\'>By '+att_s+'('+att_c+')'+'</a></li>' color_menu_info += '<li><a href="#" onclick=\''+the_method+'("'+att_s+'")\'>By '+att_s+'('+att_c+')'+'</a></li>'
// console.log('<li><a href="#" onclick=\''+the_method+'("'+att_s+'")\'>By '+att_s+'('+att_c+')'+'</a></li>') // console.log('<li><a href="#" onclick=\''+the_method+'("'+att_s+'")\'>By '+att_s+'('+att_c+')'+'</a></li>')
} }
...@@ -240,18 +250,38 @@ function graphResetColor(){ ...@@ -240,18 +250,38 @@ function graphResetColor(){
function set_ClustersLegend ( daclass ) { function set_ClustersLegend ( daclass ) {
//TW.partialGraph.states.slice(-1)[0].LouvainFait = true //TW.partialGraph.states.slice(-1)[0].LouvainFait = true
console.log("set_ClustersLegend", daclass)
$("#legend_for_clusters").hide()
$("#legend_for_clusters").removeClass( "my-legend" ) $("#legend_for_clusters").removeClass( "my-legend" )
$("#legend_for_clusters").html("") $("#legend_for_clusters").html("")
if(daclass==null) return; if(daclass==null) return;
var ClustNB_CurrentColor = {} var ClustNB_CurrentColor = {}
var nodesV = getVisibleNodes() var nodesV = getVisibleNodes()
for(var i in nodesV) { for(var j in TW.nodeIds) {
n = nodesV[i] n = TW.partialGraph.graph.nodes(TW.nodeIds[j])
color = n.color if (!n.hidden) {
type = TW.Nodes[n.id].type color = n.color
clstNB = TW.Nodes[n.id].attributes[daclass] type = TW.Nodes[n.id].type
ClustNB_CurrentColor[type+"||"+daclass+"||"+clstNB] = color
if (daclass == 'clust_default' && TW.nodeClusAtt) {
clstNB = TW.Nodes[n.id].attributes[TW.nodeClusAtt]
}
else {
clstNB = TW.Nodes[n.id].attributes[daclass]
}
if (daclass == 'age' && (Number(clstNB) == clstNB)) {
//clstNB is probably in ms since epoch
// ex: 1451692800000
theDate = new Date(Number(clstNB))
clstNB = theDate.toDateString()
}
// TODO if ticks use them !
ClustNB_CurrentColor[type+"||"+daclass+"||"+clstNB] = color
}
} }
LegendDiv = "" LegendDiv = ""
...@@ -295,6 +325,7 @@ function set_ClustersLegend ( daclass ) { ...@@ -295,6 +325,7 @@ function set_ClustersLegend ( daclass ) {
LegendDiv += ' </div>' LegendDiv += ' </div>'
$("#legend_for_clusters").show();
$("#legend_for_clusters").addClass( "my-legend" ); $("#legend_for_clusters").addClass( "my-legend" );
$("#legend_for_clusters").html( LegendDiv ) $("#legend_for_clusters").html( LegendDiv )
} }
...@@ -631,6 +662,9 @@ function circleTrackMouse(e) { ...@@ -631,6 +662,9 @@ function circleTrackMouse(e) {
ctx.globalAlpha = 0.5; ctx.globalAlpha = 0.5;
ctx.beginPath(); ctx.beginPath();
// // labels appear on circle hover : OFF // // labels appear on circle hover : OFF
// convert (TODO CHECK IN THIS CONTEXT) // convert (TODO CHECK IN THIS CONTEXT)
...@@ -666,7 +700,9 @@ function circleTrackMouse(e) { ...@@ -666,7 +700,9 @@ function circleTrackMouse(e) {
} }
// exact subset of nodes under circle // ----------------------------------------
// fast exact subset of nodes under circle
// ---------------------------------------
function circleGetAreaNodes(camX0, camY0) { function circleGetAreaNodes(camX0, camY0) {
var cursor_ray = cursor_size * TW.cam.ratio // cursor_size to cam units var cursor_ray = cursor_size * TW.cam.ratio // cursor_size to cam units
......
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