Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct column names for colorBy and scaleBy #266

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading