At the first render, I think the dimensions (width + height) are initial zerors, with padding, we would have negative values. We need to clamp the dimensions on calc.
Reproduction steps
const chartDimensions: Dimensions = useMemo(() => {
const { top, right, bottom, left } = chartPadding;
const legendHeight = legendRef.current
? Math.floor(legendRef.current.clientHeight)
: 0;
// It take the container dimensions and subsctract padding and legend height
// @todo : clamp to min = zero to avoid negative values
return {
width: containerDimensions.width - left - right,
height: containerDimensions.height - top - bottom - legendHeight,
};
}, [containerDimensions, chartPadding]);
Description
At the first render, I think the dimensions (width + height) are initial zerors, with padding, we would have negative values. We need to clamp the dimensions on calc.
Reproduction steps