Skip to content

Commit

Permalink
Use separate variable for array and set of legend values
Browse files Browse the repository at this point in the history
This is easier for the compiler to understand.
  • Loading branch information
victorlin committed Oct 29, 2024
1 parent 16524ee commit 0523c8f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/util/colorScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export function createVisibleLegendValues({
// filter according to scaleType, e.g. continuous is different to categorical which is different to boolean
// filtering will involve looping over reduxState.tree.nodes and comparing with reduxState.tree.visibility
if (scaleType === "ordinal" || scaleType === "categorical") {
let legendValuesObserved: string[] | Set<string> = treeNodes
let legendValuesObserved: string[] = treeNodes
.filter((n, i) => (!n.hasChildren && visibility[i]===NODE_VISIBLE))
.map((n) => genotype ? n.currentGt : getTraitFromNode(n, colorBy));
// if the 2nd tree is enabled, compute visible legend values and merge the values.
Expand All @@ -428,8 +428,8 @@ export function createVisibleLegendValues({
.map((n) => genotype ? n.currentGt : getTraitFromNode(n, colorBy));
legendValuesObserved = [...legendValuesObserved, ...legendValuesObservedToo];
}
legendValuesObserved = new Set(legendValuesObserved);
const visibleLegendValues = legendValues.filter((v) => legendValuesObserved.has(v));
const legendValuesObservedSet = new Set(legendValuesObserved);
const visibleLegendValues = legendValues.filter((v) => legendValuesObservedSet.has(v));
return visibleLegendValues;
}
}
Expand Down

0 comments on commit 0523c8f

Please sign in to comment.