Commit dda561c3 authored by Romain Loth's avatar Romain Loth

add one level in TW.Clusters to allow metadata alongside the facets inverted index

parent 5a095c4c
...@@ -35,11 +35,11 @@ function changeGraphAppearanceByFacets( manualflag ) { ...@@ -35,11 +35,11 @@ function changeGraphAppearanceByFacets( manualflag ) {
// attribute counts: nb of classes // attribute counts: nb of classes
// POSS here distinguish [ty][attTitle].classes.length and ranges.length // POSS here distinguish [ty][attTitle].classes.length and ranges.length
var attNbClasses = TW.Clusters[ty][attTitle].length var attNbClasses = TW.Clusters[ty][attTitle].invIdx.length
var attNbNodes = currentNbNodes var attNbNodes = currentNbNodes
if (attNbClasses) { if (attNbClasses) {
let lastClass = TW.Clusters[ty][attTitle][attNbClasses-1] let lastClass = TW.Clusters[ty][attTitle].invIdx[attNbClasses-1]
if (lastClass.labl && lastClass.labl == '_non_numeric_' && lastClass.nids) { if (lastClass.labl && lastClass.labl == '_non_numeric_' && lastClass.nids) {
if (lastClass.nids.length) { if (lastClass.nids.length) {
attNbNodes -= lastClass.nids.length attNbNodes -= lastClass.nids.length
...@@ -133,18 +133,18 @@ function RunLouvain() { ...@@ -133,18 +133,18 @@ function RunLouvain() {
let nClasses = 0 let nClasses = 0
for (let typ in louvainValNids) { for (let typ in louvainValNids) {
let revIdx = louvainValNids[typ]["clust_louvain"]['map'] let reinvIdx = louvainValNids[typ]["clust_louvain"]['map']
// init a new legend in TW.Clusters // init a new legend in TW.Clusters
TW.Clusters[typ]['clust_louvain'] = [] TW.Clusters[typ]['clust_louvain'] = {'meta':{}, 'invIdx':[]}
for (let entry in revIdx) { for (let entry in reinvIdx) {
let len = revIdx[entry].length let len = reinvIdx[entry].length
if (len) { if (len) {
TW.Clusters[typ]['clust_louvain'].push({ TW.Clusters[typ]['clust_louvain'].invIdx.push({
'labl': `${entry} (${len})`, 'labl': `${entry} (${len})`,
'fullLabl': `${typ}||Louvain||${entry} (${len})`, 'fullLabl': `${typ}||Louvain||${entry} (${len})`,
'nids': revIdx[entry], 'nids': reinvIdx[entry],
'val': entry 'val': entry
}) })
nClasses ++ nClasses ++
...@@ -191,10 +191,11 @@ function SomeEffect( ValueclassCode ) { ...@@ -191,10 +191,11 @@ function SomeEffect( ValueclassCode ) {
var activetypesKey = getActivetypesKey() var activetypesKey = getActivetypesKey()
// console.log( "\t"+activetypesKey) // console.log( "\t"+activetypesKey)
// we have our precomputed idmaps for nodes_2_colour // we have our precomputed idmaps for nodes_2_colour
// ------------------------------------------------- // -------------------------------------------------
for (var k in TW.Clusters[nodeType][cluType][iClu].nids) { for (var k in TW.Clusters[nodeType][cluType].invIdx[iClu].nids) {
var nid = TW.Clusters[nodeType][cluType][iClu].nids[k] var nid = TW.Clusters[nodeType][cluType].invIdx[iClu].nids[k]
nodes_2_colour[nid] = true nodes_2_colour[nid] = true
} }
...@@ -280,7 +281,7 @@ function set_ClustersLegend ( daclass, groupedByTicks ) { ...@@ -280,7 +281,7 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
LegendDiv += ' <div class="legend-scale">' LegendDiv += ' <div class="legend-scale">'
LegendDiv += ' <ul class="legend-labels">' LegendDiv += ' <ul class="legend-labels">'
var legendInfo = groupedByTicks || TW.Clusters[curType][daclass] var legendInfo = groupedByTicks || TW.Clusters[curType][daclass].invIdx
// valueclasses (values or intervals or classes) are already sorted in TW.Clusters // valueclasses (values or intervals or classes) are already sorted in TW.Clusters
for (var l in legendInfo) { for (var l in legendInfo) {
......
...@@ -294,7 +294,7 @@ TW.conf = (function(TW){ ...@@ -294,7 +294,7 @@ TW.conf = (function(TW){
// show verbose console logs... // show verbose console logs...
logFetchers: false, // ...about ajax/fetching of graph data logFetchers: false, // ...about ajax/fetching of graph data
logParsers: false, // ...about parsing said data logParsers: false, // ...about parsing said data
logFacets: false, // ...about parsing node attribute:value facets logFacets: true, // ...about parsing node attribute:value facets
logSettings: false, // ...about settings at Tina and Sigma init time logSettings: false, // ...about settings at Tina and Sigma init time
logSelections: false logSelections: false
} }
......
...@@ -1028,7 +1028,8 @@ var TinaWebJS = function ( sigmacanvas ) { ...@@ -1028,7 +1028,8 @@ var TinaWebJS = function ( sigmacanvas ) {
// attributes' facet-options init & handler // attributes' facet-options init & handler
fillAttrsInForm() fillAttrsInForm('choose-attr')
fillAttrsInForm('choose-titling-metric', 'metric')
document.getElementById('choose-attr').onchange = showAttrConf document.getElementById('choose-attr').onchange = showAttrConf
// cancelSelection(false); // cancelSelection(false);
......
...@@ -291,8 +291,8 @@ function facetsBinning (valuesIdx) { ...@@ -291,8 +291,8 @@ function facetsBinning (valuesIdx) {
// console.warn("all raw vals before binning" valuesIdx[cat][at].vals) // console.warn("all raw vals before binning" valuesIdx[cat][at].vals)
// new array of valueclass/interval/bin objects // meta + new array of values/intervals with inverted index to node ids
facetIdx[cat][at] = [] facetIdx[cat][at] = {meta:{}, invIdx:[]}
// the full array of values of the accepted type // the full array of values of the accepted type
...@@ -376,7 +376,7 @@ function facetsBinning (valuesIdx) { ...@@ -376,7 +376,7 @@ function facetsBinning (valuesIdx) {
for (var pval in valuesIdx[cat][at].map) { for (var pval in valuesIdx[cat][at].map) {
var idList = valuesIdx[cat][at].map[pval] var idList = valuesIdx[cat][at].map[pval]
facetIdx[cat][at].push({ facetIdx[cat][at].invIdx.push({
// simple label // simple label
'labl': `${pval} (${idList.length})`, 'labl': `${pval} (${idList.length})`,
// verbose label // verbose label
...@@ -550,12 +550,12 @@ function facetsBinning (valuesIdx) { ...@@ -550,12 +550,12 @@ function facetsBinning (valuesIdx) {
// save these bins as the cluster index (aka faceting) // save these bins as the cluster index (aka faceting)
if (newTick.nids.length) { if (newTick.nids.length) {
facetIdx[cat][at].push(newTick) facetIdx[cat][at].invIdx.push(newTick)
} }
} }
// finally add the 'trash' category with any non_numeric vals // finally add the 'trash' category with any non_numeric vals
facetIdx[cat][at].push({ facetIdx[cat][at].invIdx.push({
'labl':'_non_numeric_', 'labl':'_non_numeric_',
'fullLabl':'`${cat}||${at}||_non_numeric_', 'fullLabl':'`${cat}||${at}||_non_numeric_',
'nids': valuesIdx[cat][at].map['_non_numeric_'], 'nids': valuesIdx[cat][at].map['_non_numeric_'],
......
...@@ -803,7 +803,7 @@ function heatmapColoring(daclass) { ...@@ -803,7 +803,7 @@ function heatmapColoring(daclass) {
var ty = actypes[0] var ty = actypes[0]
// our binning // our binning
var tickThresholds = TW.Clusters[ty][daclass] var tickThresholds = TW.Clusters[ty][daclass].invIdx
// verifications // verifications
if (tickThresholds.length - 1 != nColors) { if (tickThresholds.length - 1 != nColors) {
......
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