Skip to content

Commit

Permalink
Merge pull request #1944 from visualize-admin/fix/chart-sizing
Browse files Browse the repository at this point in the history
fix: Chart sizing
  • Loading branch information
bprusinowski authored Jan 7, 2025
2 parents 6b6f9a5 + 71879fd commit e330c65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ You can also check the
chart and the cube has been updated in the meantime and contains new values
in the color dimension
- Fixed preview via API (iframe)
- Fixed cut table scroll-bars and unnecessary scroll of bar charts when
switching between chart types

# [5.0.2] - 2024-11-28

Expand Down
8 changes: 8 additions & 0 deletions app/charts/shared/containers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useChartState } from "@/charts/shared/chart-state";
import { CalculationToggle } from "@/charts/shared/interactive-filter-calculation-toggle";
import { useObserverRef } from "@/charts/shared/use-size";
import {
getChartConfig,
hasChartConfigs,
isLayoutingFreeCanvas,
useConfiguratorState,
Expand All @@ -18,19 +19,26 @@ export const useStyles = makeStyles<{}, {}, "chartContainer">(() => ({
chartContainer: {
overflow: "hidden",
position: "relative",
display: "flex",
flexDirection: "column",
width: "100%",
flexGrow: 1,
},
}));

export const ChartContainer = ({ children }: { children: ReactNode }) => {
const [state] = useConfiguratorState(hasChartConfigs);
const chartConfig = getChartConfig(state);
const isFreeCanvas = isLayoutingFreeCanvas(state);
const ref = useObserverRef();
const { bounds } = useChartState();
const classes = useStyles();

return (
<div
// Re-mount to prevent issues with useSize hook when switching between
// chart types (that might have different sizes).
key={chartConfig.chartType}
ref={ref}
aria-hidden="true"
className={classes.chartContainer}
Expand Down

0 comments on commit e330c65

Please sign in to comment.