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 ) {
// attribute counts: nb of classes
// 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
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.nids.length) {
attNbNodes -= lastClass.nids.length
......@@ -133,18 +133,18 @@ function RunLouvain() {
let nClasses = 0
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
TW.Clusters[typ]['clust_louvain'] = []
TW.Clusters[typ]['clust_louvain'] = {'meta':{}, 'invIdx':[]}
for (let entry in revIdx) {
let len = revIdx[entry].length
for (let entry in reinvIdx) {
let len = reinvIdx[entry].length
if (len) {
TW.Clusters[typ]['clust_louvain'].push({
TW.Clusters[typ]['clust_louvain'].invIdx.push({
'labl': `${entry} (${len})`,
'fullLabl': `${typ}||Louvain||${entry} (${len})`,
'nids': revIdx[entry],
'nids': reinvIdx[entry],
'val': entry
})
nClasses ++
......@@ -191,10 +191,11 @@ function SomeEffect( ValueclassCode ) {
var activetypesKey = getActivetypesKey()
// console.log( "\t"+activetypesKey)
// we have our precomputed idmaps for nodes_2_colour
// -------------------------------------------------
for (var k in TW.Clusters[nodeType][cluType][iClu].nids) {
var nid = TW.Clusters[nodeType][cluType][iClu].nids[k]
for (var k in TW.Clusters[nodeType][cluType].invIdx[iClu].nids) {
var nid = TW.Clusters[nodeType][cluType].invIdx[iClu].nids[k]
nodes_2_colour[nid] = true
}
......@@ -280,7 +281,7 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
LegendDiv += ' <div class="legend-scale">'
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
for (var l in legendInfo) {
......
......@@ -294,7 +294,7 @@ TW.conf = (function(TW){
// show verbose console logs...
logFetchers: false, // ...about ajax/fetching of graph 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
logSelections: false
}
......
......@@ -1028,7 +1028,8 @@ var TinaWebJS = function ( sigmacanvas ) {
// attributes' facet-options init & handler
fillAttrsInForm()
fillAttrsInForm('choose-attr')
fillAttrsInForm('choose-titling-metric', 'metric')
document.getElementById('choose-attr').onchange = showAttrConf
// cancelSelection(false);
......
......@@ -291,8 +291,8 @@ function facetsBinning (valuesIdx) {
// console.warn("all raw vals before binning" valuesIdx[cat][at].vals)
// new array of valueclass/interval/bin objects
facetIdx[cat][at] = []
// meta + new array of values/intervals with inverted index to node ids
facetIdx[cat][at] = {meta:{}, invIdx:[]}
// the full array of values of the accepted type
......@@ -376,7 +376,7 @@ function facetsBinning (valuesIdx) {
for (var pval in valuesIdx[cat][at].map) {
var idList = valuesIdx[cat][at].map[pval]
facetIdx[cat][at].push({
facetIdx[cat][at].invIdx.push({
// simple label
'labl': `${pval} (${idList.length})`,
// verbose label
......@@ -550,12 +550,12 @@ function facetsBinning (valuesIdx) {
// save these bins as the cluster index (aka faceting)
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
facetIdx[cat][at].push({
facetIdx[cat][at].invIdx.push({
'labl':'_non_numeric_',
'fullLabl':'`${cat}||${at}||_non_numeric_',
'nids': valuesIdx[cat][at].map['_non_numeric_'],
......
......@@ -803,7 +803,7 @@ function heatmapColoring(daclass) {
var ty = actypes[0]
// our binning
var tickThresholds = TW.Clusters[ty][daclass]
var tickThresholds = TW.Clusters[ty][daclass].invIdx
// verifications
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