Skip to content

Commit

Permalink
Update filter badges for multiple trees
Browse files Browse the repository at this point in the history
The previous implementation only reflected counts in the LHS tree,
irregardless of any occurrences which may or may not be present in the
RHS tree. We now communicate both. This also fixes a bug introduced in
the previous commit where filtering to a traitName not present in the
LHS tree would cause an uncaught exception.
  • Loading branch information
jameshadfield committed Jun 17, 2024
1 parent 6094ba2 commit 5d29e97
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/info/filtersSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const closeBracketSmall = <span style={{fontSize: "1.8rem", fontWeight: 300, pad
metadata: state.metadata,
nodes: state.tree.nodes,
totalStateCounts: state.tree.totalStateCounts,
totalStateCountsSecondTree: state.treeToo?.totalStateCounts,
visibility: state.tree.visibility,
selectedClade: state.tree.selectedClade,
dateMin: state.controls.dateMin,
Expand Down Expand Up @@ -86,7 +87,19 @@ class FiltersSummary extends React.Component {
.sort((a, b) => a.value < b.value ? -1 : a.value > b.value ? 1 : 0)
.map((item) => {
let label = `${item.value}`;
if (filterName!==strainSymbol) label+= ` (${this.props.totalStateCounts[filterName].get(item.value)})`;
if (filterName!==strainSymbol) {
/* Add the _total_ occurrences in parentheses. We don't compute the intersections / visible values here -
e.g. we can have "England (5)" "North America (100)" even though such an intersection will deselect everything.
If we have two trees shown we show both values.
*/
const tree1count = this.props.totalStateCounts[filterName]?.get(item.value) ?? 0;
if (this.props.totalStateCountsSecondTree) {
const tree2count = this.props.totalStateCountsSecondTree[filterName]?.get(item.value) ?? 0;
label+=` (L: ${tree1count}, R: ${tree2count})`;
} else {
label+=` (${tree1count})`;
}
}
return this.createIndividualBadge({filterName, item, label, onHoverMessage});
});
}
Expand Down

0 comments on commit 5d29e97

Please sign in to comment.