Commit 269a4f58 authored by Romain Loth's avatar Romain Loth

transitive titling + option for no titling

parent 8f770926
...@@ -724,6 +724,7 @@ ...@@ -724,6 +724,7 @@
<label for="attr-titling-metric" class="smlabel input-group-addon">Titling metric</label> <label for="attr-titling-metric" class="smlabel input-group-addon">Titling metric</label>
<select id="attr-titling-metric" name="attr-titling-metric" <select id="attr-titling-metric" name="attr-titling-metric"
class="custom-select form-control"> class="custom-select form-control">
<option value="off">No titling (preserve original values)</option>
<!-- other attrs filled by fillAttrsInForm(., 'num') --> <!-- other attrs filled by fillAttrsInForm(., 'num') -->
</select> </select>
</div> </div>
......
...@@ -73,12 +73,13 @@ TW.conf = (function(TW){ ...@@ -73,12 +73,13 @@ TW.conf = (function(TW){
'auto-outdegree' : {'col': "heatmap", 'n': 7, 'binmode': 'samepop', 'legend': 'Auto OutDegree'}, 'auto-outdegree' : {'col': "heatmap", 'n': 7, 'binmode': 'samepop', 'legend': 'Auto OutDegree'},
'cluster_index' : {'col': "cluster" , 'binmode': 'off' }, 'cluster_index' : {'col': "cluster" , 'binmode': 'off' },
'clust_louvain' : {'col': "cluster" , 'binmode': 'off', 'clust_louvain' : {'col': "cluster" , 'binmode': 'off',
'legend':'Louvain clustering' }, 'legend':'Louvain clustering', 'titlingMetric': 'auto-outdegree'},
'country':{ 'country':{
'col':"cluster" , 'col':"cluster" ,
'binmode': 'off', 'binmode': 'off',
'legend': 'Country' 'legend': 'Country'
}, 'titlingMetric': 'off';
},
'total_occurrences':{ 'total_occurrences':{
'col':"heatmap" , 'col':"heatmap" ,
'binmode': 'samerange', 'binmode': 'samerange',
......
...@@ -430,7 +430,10 @@ function updateColorsLegend ( daclass, forTypes, groupedByTicks ) { ...@@ -430,7 +430,10 @@ function updateColorsLegend ( daclass, forTypes, groupedByTicks ) {
} }
// we add a title to cluster classes by ranking their nodes and taking k best labels, except if type is "social" // we add a title to cluster classes by ranking their nodes and taking k best labels, except if type is "social"
if (TW.facetOptions[daclass] && TW.facetOptions[daclass].col == 'cluster' && curType != TW.categories[1]) { if (TW.facetOptions[daclass]
&& TW.facetOptions[daclass].titlingMetric
&& TW.facetOptions[daclass].titlingMetric != 'off'
&& TW.facetOptions[daclass].col == 'cluster') {
// let t0 = performance.now() // let t0 = performance.now()
...@@ -455,10 +458,42 @@ function updateColorsLegend ( daclass, forTypes, groupedByTicks ) { ...@@ -455,10 +458,42 @@ function updateColorsLegend ( daclass, forTypes, groupedByTicks ) {
getVal = function(node) {return node.size} getVal = function(node) {return node.size}
} }
for (let j in legendInfo[l]['nids']) { // our source of words (labels)
let n = TW.partialGraph.graph.nodes(legendInfo[l]['nids'][j]) let ndsToRetrieveNameFrom = {}
// if node0 contains meaningful labels for titling
// we can title node1 clusters using node0 neighborhood
// => we'll use metric on bipartite neighborhood labels
// POSS it could be a conf option to use another type or not
if (curType == TW.categories[1] && TW.Relations["XR"]) {
// transitive step from nodetype to their surrogate nodetype
for (var i in legendInfo[l]['nids']) {
let start_nid = legendInfo[l]['nids'][i]
let transitiveNids = TW.Relations["XR"][start_nid]
for (var j in transitiveNids) {
let nei_nid = transitiveNids[j]
if (!ndsToRetrieveNameFrom[nei_nid]) {
ndsToRetrieveNameFrom[nei_nid] = 1
}
else {
ndsToRetrieveNameFrom[nei_nid] += 1 // <== coef
}
}
}
}
// normal case => directly use metric on these nodes' labels
else {
for (var i in legendInfo[l]['nids']) {
let nid = legendInfo[l]['nids'][i]
ndsToRetrieveNameFrom[nid] = 1
}
}
for (var nid in ndsToRetrieveNameFrom) {
let n = TW.Nodes[nid]
let coef = ndsToRetrieveNameFrom[nid]
let theRankingVal = getVal(n) let theRankingVal = getVal(n) * Math.sqrt(coef)
if (titles.length < maxLen) { if (titles.length < maxLen) {
titles.push({'key':n.label, 'val':theRankingVal}) titles.push({'key':n.label, 'val':theRankingVal})
...@@ -1107,9 +1142,9 @@ function fillAttrsInForm(menuId, optionalAttTypeConstraint) { ...@@ -1107,9 +1142,9 @@ function fillAttrsInForm(menuId, optionalAttTypeConstraint) {
let elChooser = document.getElementById(menuId) let elChooser = document.getElementById(menuId)
// 1- remove any previous options from possible previous graphs // 1- remove any previous options from possible previous graphs
let autoOptions = document.getElementById(menuId).querySelectorAll('option') let filledOptions = document.getElementById(menuId).querySelectorAll('option[data-opttype=filled]')
for (var i = 0 ; i <= autoOptions.length - 1 ; i++) { for (var i = 0 ; i <= filledOptions.length - 1 ; i++) {
elChooser.removeChild(autoOptions[i]) elChooser.removeChild(filledOptions[i])
} }
// 2- ls | uniq all options (no matter what active type they belong too) // 2- ls | uniq all options (no matter what active type they belong too)
...@@ -1146,7 +1181,7 @@ function fillAttrsInForm(menuId, optionalAttTypeConstraint) { ...@@ -1146,7 +1181,7 @@ function fillAttrsInForm(menuId, optionalAttTypeConstraint) {
opt.dataset.opttype = "auto" opt.dataset.opttype = "auto"
} }
else { else {
opt.dataset.opttype = "fromFacets" opt.dataset.opttype = "filled"
} }
elChooser.appendChild(opt) elChooser.appendChild(opt)
} }
......
...@@ -73,12 +73,13 @@ TW.conf = (function(TW){ ...@@ -73,12 +73,13 @@ TW.conf = (function(TW){
'auto-outdegree' : {'col': "heatmap", 'n': 7, 'binmode': 'samepop', 'legend': 'Auto OutDegree'}, 'auto-outdegree' : {'col': "heatmap", 'n': 7, 'binmode': 'samepop', 'legend': 'Auto OutDegree'},
'cluster_index' : {'col': "cluster" , 'binmode': 'off' }, 'cluster_index' : {'col': "cluster" , 'binmode': 'off' },
'clust_louvain' : {'col': "cluster" , 'binmode': 'off', 'clust_louvain' : {'col': "cluster" , 'binmode': 'off',
'legend':'Louvain clustering' }, 'legend':'Louvain clustering', 'titlingMetric': 'auto-outdegree'},
'country':{ 'country':{
'col':"cluster" , 'col':"cluster" ,
'binmode': 'off', 'binmode': 'off',
'legend': 'Country' 'legend': 'Country'
}, 'titlingMetric': 'off';
},
'normfactor':{ 'normfactor':{
'col':"heatmap" , 'col':"heatmap" ,
...@@ -89,7 +90,8 @@ TW.conf = (function(TW){ ...@@ -89,7 +90,8 @@ TW.conf = (function(TW){
'ACR':{ 'ACR':{
'col':"cluster" , 'col':"cluster" ,
'binmode': 'off', 'binmode': 'off',
'legend': 'Affiliation' 'legend': 'Affiliation',
'titlingMetric': 'off';
}, },
'nbjobs':{ 'nbjobs':{
'col':"heatmap" , 'col':"heatmap" ,
......
...@@ -73,12 +73,13 @@ TW.conf = (function(TW){ ...@@ -73,12 +73,13 @@ TW.conf = (function(TW){
'auto-outdegree' : {'col': "heatmap", 'n': 7, 'binmode': 'samepop', 'legend': 'Auto OutDegree'}, 'auto-outdegree' : {'col': "heatmap", 'n': 7, 'binmode': 'samepop', 'legend': 'Auto OutDegree'},
'cluster_index' : {'col': "cluster" , 'binmode': 'off' }, 'cluster_index' : {'col': "cluster" , 'binmode': 'off' },
'clust_louvain' : {'col': "cluster" , 'binmode': 'off', 'clust_louvain' : {'col': "cluster" , 'binmode': 'off',
'legend':'Louvain clustering' }, 'legend':'Louvain clustering', 'titlingMetric': 'auto-outdegree'},
'country':{ 'country':{
'col':"cluster" , 'col':"cluster" ,
'binmode': 'off', 'binmode': 'off',
'legend': 'Country' 'legend': 'Country'
}, 'titlingMetric': 'off';
},
'total_occurrences':{ 'total_occurrences':{
'col':"heatmap" , 'col':"heatmap" ,
'binmode': 'samerange', 'binmode': 'samerange',
......
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