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 ) {
// passed as arg or prepared in parseCustom
if (!groupedByTicks && (!TW.Clusters[curType] || !TW.Clusters[curType][daclass])) {
console.warn(`no class bins for ${daclass}, displaying no legend`)
$("#legend_for_clusters").hide()
}
else {
var LegendDiv = ""
......@@ -275,27 +277,31 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
// get a sample node color for each bin/class
var nMatchedNodes = legendInfo[l]['nids'].length
var midNid = legendInfo[l]['nids'][Math.floor(3*nMatchedNodes/4)]
var exampleColor = TW.partialGraph.graph.nodes(midNid).color
// create the legend item
var preparedLabel = legendInfo[l]['labl']
// console.log("preparedLabel", preparedLabel)
if (nMatchedNodes) {
var midNid = legendInfo[l]['nids'][Math.floor(3*nMatchedNodes/4)]
var exampleColor = TW.partialGraph.graph.nodes(midNid).color
// create the legend item
var preparedLabel = legendInfo[l]['labl']
// console.log("preparedLabel", preparedLabel)
// all-in-one argument for SomeEffect
var valueclassId = `${curType}::${daclass}::${l}`
// all-in-one argument for SomeEffect
var valueclassId = `${curType}::${daclass}::${l}`
var colorBg = `<span style="background:${exampleColor};"></span>`
var colorBg = `<span style="background:${exampleColor};"></span>`
LegendDiv += `<li onclick='SomeEffect("${valueclassId}")'>`
LegendDiv += colorBg + preparedLabel
LegendDiv += "</li>\n"
LegendDiv += `<li onclick='SomeEffect("${valueclassId}")'>`
LegendDiv += colorBg + preparedLabel
LegendDiv += "</li>\n"
}
}
LegendDiv += ' </ul>'
LegendDiv += ' </div>'
$("#legend_for_clusters").addClass( "my-legend" );
$("#legend_for_clusters").html( LegendDiv )
$("#legend_for_clusters").show()
}
}
......
......@@ -626,7 +626,9 @@ function dictfyGexf( gexf , categories ){
newTick.labl = `${cat}||${at}||[${labLowThres} ; ${labHiThres}]`
// save these bins as the cluster index (aka faceting)
TW.Clusters[cat][at].push(newTick)
if (newTick.nids.length) {
TW.Clusters[cat][at].push(newTick)
}
}
}
}
......
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