Skip to content
Merged
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
3 changes: 2 additions & 1 deletion packages/charts/src/hooks/useObserveXAxisHeights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const defaultAxisHeight = 30;
function measure(container: Element | null, axisCount: number, prevHeightsRef: MutableRefObject<number[]>) {
const heights = Array(axisCount).fill(defaultAxisHeight);
container?.querySelectorAll<SVGGraphicsElement>('.xAxis').forEach((xAxis, index) => {
const height = xAxis?.getBBox()?.height;
const height = Math.ceil(xAxis?.getBBox()?.height ?? 0);
if (height > defaultAxisHeight) {
heights[index] = height;
}
Expand All @@ -31,6 +31,7 @@ export const useObserveXAxisHeights = (chartRef: RefObject<SVGElement>, axisCoun
const [xAxisHeights, setXAxisHeights] = useState(Array(axisCount).fill(defaultAxisHeight));
const prevHeightsRef = useRef(xAxisHeights);

// TODO (v3): evaluate if ResizeObserver is better here for measuring, so it doesn't run on every component update
// check on every render if height changed
useIsomorphicLayoutEffect(() => {
const result = measure(chartRef.current, axisCount, prevHeightsRef);
Expand Down
Loading