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: vis is rendered with an invalid config #172

Merged
merged 7 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 3 additions & 1 deletion src/vis/EagerVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ export function EagerVis({

const setExternalConfigRef = useSyncedRef(setExternalConfig);
useEffect(() => {
setExternalConfigRef.current?.(visConfig);
if (visConfig) {
setExternalConfigRef.current?.(visConfig);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [JSON.stringify(visConfig), setExternalConfigRef]);

Expand Down
10 changes: 5 additions & 5 deletions src/vis/heatmap/HeatmapGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ export function HeatmapGrid({

return (
<Stack align="center" justify="center" sx={{ width: '100%', height: '100%' }} p="sm">
{status === 'pending' ? (
<Loader />
) : !hasAtLeast2CatCols ? (
<InvalidCols headerMessage="Invalid settings" bodyMessage="To create a heatmap chart, select at least 2 categorical columns." />
) : (
{status === 'pending' && <Loader />}
Copy link
Contributor Author

@oltionchampari oltionchampari Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Invalid settings message is shown shortly while the state is idle. This change fixes that. The other visualizations account for the idle state already.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this issue and the mention.

{status === 'success' && hasAtLeast2CatCols && (
<Heatmap
column1={allColumns.catColumn[0]}
column2={allColumns.catColumn[1]}
Expand All @@ -50,6 +47,9 @@ export function HeatmapGrid({
selectionCallback={selectionCallback}
/>
)}
{status === 'success' && !hasAtLeast2CatCols && (
<InvalidCols headerMessage="Invalid settings" bodyMessage="To create a heatmap chart, select at least 2 categorical columns." />
)}
</Stack>
);
}
2 changes: 1 addition & 1 deletion src/vis/heatmap/HeatmapText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function HeatmapText({
isImmediate: boolean;
}) {
const labelSpacing = useMemo(() => {
const maxLabelLength = d3.max(yScale.domain().map((m) => m.length));
const maxLabelLength = d3.max(yScale.domain().map((m) => m?.length));
Copy link
Contributor Author

@oltionchampari oltionchampari Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accounts for null categories. They are still shown in the visualization but at least the application does not crash.
I have created an issue to discuss possible better solutions


return maxLabelLength > 5 ? 35 : maxLabelLength * 7;
}, [yScale]);
Expand Down
Loading