Commit aebf89e8 authored by Romain Loth's avatar Romain Loth

more safeguards for empty bins

parent e9ba8fa8
...@@ -261,6 +261,8 @@ function set_ClustersLegend ( daclass, groupedByTicks ) { ...@@ -261,6 +261,8 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
// passed as arg or prepared in parseCustom // passed as arg or prepared in parseCustom
if (!groupedByTicks && (!TW.Clusters[curType] || !TW.Clusters[curType][daclass])) { if (!groupedByTicks && (!TW.Clusters[curType] || !TW.Clusters[curType][daclass])) {
console.warn(`no class bins for ${daclass}, displaying no legend`) console.warn(`no class bins for ${daclass}, displaying no legend`)
$("#legend_for_clusters").hide()
} }
else { else {
var LegendDiv = "" var LegendDiv = ""
...@@ -275,6 +277,8 @@ function set_ClustersLegend ( daclass, groupedByTicks ) { ...@@ -275,6 +277,8 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
// get a sample node color for each bin/class // get a sample node color for each bin/class
var nMatchedNodes = legendInfo[l]['nids'].length var nMatchedNodes = legendInfo[l]['nids'].length
if (nMatchedNodes) {
var midNid = legendInfo[l]['nids'][Math.floor(3*nMatchedNodes/4)] var midNid = legendInfo[l]['nids'][Math.floor(3*nMatchedNodes/4)]
var exampleColor = TW.partialGraph.graph.nodes(midNid).color var exampleColor = TW.partialGraph.graph.nodes(midNid).color
...@@ -291,11 +295,13 @@ function set_ClustersLegend ( daclass, groupedByTicks ) { ...@@ -291,11 +295,13 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
LegendDiv += colorBg + preparedLabel LegendDiv += colorBg + preparedLabel
LegendDiv += "</li>\n" LegendDiv += "</li>\n"
} }
}
LegendDiv += ' </ul>' LegendDiv += ' </ul>'
LegendDiv += ' </div>' LegendDiv += ' </div>'
$("#legend_for_clusters").addClass( "my-legend" ); $("#legend_for_clusters").addClass( "my-legend" );
$("#legend_for_clusters").html( LegendDiv ) $("#legend_for_clusters").html( LegendDiv )
$("#legend_for_clusters").show()
} }
} }
......
...@@ -626,11 +626,13 @@ function dictfyGexf( gexf , categories ){ ...@@ -626,11 +626,13 @@ function dictfyGexf( gexf , categories ){
newTick.labl = `${cat}||${at}||[${labLowThres} ; ${labHiThres}]` newTick.labl = `${cat}||${at}||[${labLowThres} ; ${labHiThres}]`
// save these bins as the cluster index (aka faceting) // save these bins as the cluster index (aka faceting)
if (newTick.nids.length) {
TW.Clusters[cat][at].push(newTick) TW.Clusters[cat][at].push(newTick)
} }
} }
} }
} }
}
var classvalues_fin = performance.now() var classvalues_fin = performance.now()
console.log('dictfyGexf: end TW.Clusters, own time:', classvalues_fin-classvalues_deb) console.log('dictfyGexf: end TW.Clusters, own time:', classvalues_fin-classvalues_deb)
......
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