Skip to content

Commit

Permalink
Merge pull request #266 from Renumics/fix/broken-colorby-and-scaleby-…
Browse files Browse the repository at this point in the history
…selects

fix: use correct column names for colorBy and scaleBy
  • Loading branch information
neindochoh authored Oct 11, 2023
2 parents 017bb9c + 864341d commit 7d1c1aa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
48 changes: 28 additions & 20 deletions src/widgets/SimilarityMap/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,24 @@ const SettingsMenu = ({
);

const colorableColumns = useMemo(
() =>
Object.values(columnType)
.filter((type) =>
() => [
'',
...Object.entries(columnType)
.filter(([, type]) =>
['int', 'float', 'str', 'bool', 'Category'].includes(type.kind)
)
.map((type) => type.kind),
.map(([col]) => col),
],
[columnType]
);

const scaleableColumns = useMemo(
() =>
Object.values(columnType)
.filter((type) => ['int', 'float', 'bool'].includes(type.kind))
.map((type) => type.kind),
() => [
'',
...Object.entries(columnType)
.filter(([, type]) => ['int', 'float', 'bool'].includes(type.kind))
.map(([col]) => col),
],
[columnType]
);

Expand Down Expand Up @@ -133,18 +137,22 @@ const SettingsMenu = ({
</Menu.Item>
{reductionParameterMenu}
<Menu.HorizontalDivider />
<Menu.ColumnSelect
title="Color By"
onChangeColumn={onChangeColorBy}
selectableColumns={colorableColumns}
selected={colorBy}
/>
<Menu.ColumnSelect
title="Scale By"
onChangeColumn={onChangeSizeBy}
selectableColumns={scaleableColumns}
selected={sizeBy}
/>
<Menu.Item>
<Menu.Title>Color By</Menu.Title>
<Select
onChange={onChangeColorBy}
options={colorableColumns}
value={colorBy}
/>
</Menu.Item>
<Menu.Item>
<Menu.Title>Scale By</Menu.Title>
<Select
onChange={onChangeSizeBy}
options={scaleableColumns}
value={sizeBy}
/>
</Menu.Item>
</Menu>
);
};
Expand Down
5 changes: 4 additions & 1 deletion src/widgets/SimilarityMap/SimilarityMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ const SimilarityMap: Widget = () => {
)
.map((c) => c.key);

if (storedColorByKey && availableColumns.includes(storedColorByKey)) {
if (
storedColorByKey !== undefined &&
(storedColorByKey === '' || availableColumns.includes(storedColorByKey))
) {
return storedColorByKey;
}
return availableColumns[0];
Expand Down

0 comments on commit 7d1c1aa

Please sign in to comment.