Skip to content

Commit

Permalink
Merge pull request #440 from Renumics/fix/no-colors-on-filtered-simmap
Browse files Browse the repository at this point in the history
fix computation of filtered values in color tf factory
  • Loading branch information
neindochoh committed Feb 27, 2024
2 parents 4a78a95 + 75be158 commit 53c03aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
10 changes: 8 additions & 2 deletions src/stores/dataset/colorTransferFunctionFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@ export const makeColumnsColorTransferFunctions = (
const colors = useColors.getState();

return columns.reduce((a, column) => {
const values = data[column.key];
const filteredValues = new Array(filteredIndices.length);
for (let i = 0; i < filteredIndices.length; ++i) {
filteredValues[i] = data[column.key][filteredIndices[i]];
}

a[column.key] = {
full: createColorTransferFunction(
data[column.key],
values,
column.type,
colors.robust,
colors.continuousInts,
colors.continuousCategories
),
filtered: createColorTransferFunction(
filteredIndices.map((i) => data[column.key][i]),
filteredValues,
column.type,
colors.robust,
colors.continuousInts,
Expand Down
24 changes: 12 additions & 12 deletions src/stores/dataset/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,19 +472,19 @@ export const useDataset = create(

set({ columnRelevance, isComputingRelevance: false });
},
recomputeColorTransferFunctions: async () => {
const columnsToCompute = get()
.columns.filter((c) => isScalar(c.type) || isCategorical(c.type))
.map((c) => c.key);

const newTransferFunctions = makeColumnsColorTransferFunctions(
get().columns.filter(({ key }) => columnsToCompute.includes(key)),
get().columnData,
get().filteredIndices
);
recomputeColorTransferFunctions: () => {
set(({ columns, columnData, filteredIndices }) => {
const columnsToCompute = columns
.filter((c) => isScalar(c.type) || isCategorical(c.type))
.map((c) => c.key);

set({
colorTransferFunctions: newTransferFunctions,
return {
colorTransferFunctions: makeColumnsColorTransferFunctions(
columns.filter(({ key }) => columnsToCompute.includes(key)),
columnData,
filteredIndices
),
};
});
},
clearLoadingError: () => {
Expand Down

0 comments on commit 53c03aa

Please sign in to comment.