Commit d06a320b authored by Romain Loth's avatar Romain Loth

activetypes is naturally an array

we adapt the functions that currently need only one element (ie colors, legends) instead of adapting activetypes expression
parent 17ad2bc8
......@@ -29,11 +29,14 @@ function changeGraphAppearanceByFacets( manualflag ) {
// create colormenu
var ty = getActivetypesName()
var color_menu_info = '<li><a href="#" onclick="graphResetColor()">By Default</a></li>';
if( $( "#colorgraph-menu" ).length>0 ){
if( $( "#colorgraph-menu" ).length>0 ) {
var actypes = getActivetypes()
for (var tid in actypes) {
let ty = actypes[tid]
// each facet family or clustering type was already prepared
for (var att_s in TW.Clusters[ty]) {
......@@ -57,6 +60,8 @@ function changeGraphAppearanceByFacets( manualflag ) {
color_menu_info += '<li><a href="#" onclick=\''+the_method+'("'+att_s+'")\'>By '+lab_att_s+'('+att_c+')'+'</a></li>'
}
}
$("#colorgraph-menu").html(color_menu_info)
}
......@@ -213,6 +218,8 @@ function graphResetColor(){
// reset each node's color and label
for (var j in TW.nodeIds) {
let n = TW.partialGraph.graph.nodes(TW.nodeIds[j])
// as usual, n can be absent if not in current subset !
if (n) {
n.color = n.customAttrs["true_color"];
n.customAttrs.alt_color = false
......@@ -224,6 +231,7 @@ function graphResetColor(){
n.size = TW.Nodes[n.id].size
}
}
// if (TW.partialGraph.settings('drawEdges')) {
// for(var x in eds){
// e=eds[x];
......@@ -249,8 +257,14 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
if (daclass=="clust_louvain")
daclass = "louvain"
// usually 'terms' or current display among TW.categories
var curType = getActivetypesName()
var actypes = getActivetypes()
// we have no specifications yet for colors (and legends) on multiple types
if (actypes.length > 1) {
console.warn("colors by bins will only color nodes of type 0")
}
// current display among TW.categories (ex: 'terms')
var curType = actypes[0]
// all infos in a bin array
var legendInfo = []
......
......@@ -86,12 +86,11 @@ function cancelSelection (fromTagCloud, settings) {
}
}
// returns the name(s) of active types
// returns an array of the name(s) of active type(s)
// this area is quite underspecified so we assume here
// - that all typenames have a mapping to cat[0] (terms) or cat[1] (contexts)
// - that currentState.activetypes is an array of 2 bools for the currently displayed cat(s)
// TODO transform result into array in all cases
function getActivetypesName() {
function getActivetypes() {
let currentTypes = []
let currentTypeIdx
let lastState = TW.partialGraph.states.slice(-1)[0]
......@@ -103,9 +102,8 @@ function getActivetypesName() {
}
}
// ex: 'Document' or 'Ngrams' or 'Document-Ngrams'
return currentTypes.join('-')
// ex: ['Document'] or ['Ngrams'] or ['Document','Ngrams']
return currentTypes
}
function getActivetypesKey() {
......
......@@ -858,6 +858,8 @@ function repaintEdges() {
let src = TW.partialGraph.graph.nodes(idPair[0])
let tgt = TW.partialGraph.graph.nodes(idPair[1])
if (src && tgt) {
let src_color = src.customAttrs.alt_color || '#555'
let tgt_color = tgt.customAttrs.alt_color || '#555'
e.customAttrs.alt_rgb = sigmaTools.edgeRGB(src_color,tgt_color)
......@@ -865,6 +867,7 @@ function repaintEdges() {
}
}
}
}
}
// rewrite of clustersBy with binning and for attributes that can have negative float values
......@@ -874,7 +877,14 @@ function repaintEdges() {
function colorsRelByBins(daclass) {
var binColors
var doModifyLabel = false
var ty = getActivetypesName()
var actypes = getActivetypes()
// we have no specifications yet for colors and legends on multiple types
if (actypes.length > 1) {
console.warn("colors by bins will only color nodes of type 0")
}
var ty = actypes[0]
// our binning
var tickThresholds = TW.Clusters[ty][daclass]
......@@ -1157,6 +1167,7 @@ function colorsBy(daclass) {
console.log(" = = = = = = = = = = = = = = = = = ")
console.log("")
// louvain needs preparation
if(daclass=="clust_louvain") {
if(!TW.partialGraph.states.slice(-1)[0].LouvainFait) {
RunLouvain()
......@@ -1164,9 +1175,6 @@ function colorsBy(daclass) {
}
}
var v_nodes = getVisibleNodes();
if (daclass=="clust_default") {
for(var j in TW.nodeIds) {
var original_node_color = TW.Nodes[ TW.nodeIds[j] ].color
......
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