refactor: enhance RequestDistributionChart layout and responsiveness

- Updated the chart container to improve layout with a fixed height and overflow handling.
- Adjusted margin settings for better spacing and added support for data overflow in the Y-axis.
- Changed the Area chart type to 'monotone' for smoother transitions in the data representation.
This commit is contained in:
Mauricio Siu
2025-11-30 12:31:27 -06:00
parent 25aecab062
commit ea83406f6f
@@ -49,14 +49,21 @@ export const RequestDistributionChart = ({
); );
return ( return (
<ResponsiveContainer width="100%" height={200}> <div className="w-full h-[200px] overflow-hidden">
<ResponsiveContainer
width="100%"
height="100%"
className="overflow-hidden"
>
<ChartContainer config={chartConfig}> <ChartContainer config={chartConfig}>
<AreaChart <AreaChart
accessibilityLayer accessibilityLayer
data={stats || []} data={stats || []}
margin={{ margin={{
top: 10,
left: 12, left: 12,
right: 12, right: 12,
bottom: 0,
}} }}
> >
<CartesianGrid vertical={false} /> <CartesianGrid vertical={false} />
@@ -72,7 +79,13 @@ export const RequestDistributionChart = ({
}) })
} }
/> />
<YAxis tickLine={false} axisLine={false} tickMargin={8} /> <YAxis
tickLine={false}
axisLine={false}
tickMargin={8}
allowDataOverflow={false}
domain={[0, "auto"]}
/>
<ChartTooltip <ChartTooltip
cursor={false} cursor={false}
content={<ChartTooltipContent indicator="line" />} content={<ChartTooltipContent indicator="line" />}
@@ -87,7 +100,7 @@ export const RequestDistributionChart = ({
/> />
<Area <Area
dataKey="count" dataKey="count"
type="natural" type="monotone"
fill="hsl(var(--chart-1))" fill="hsl(var(--chart-1))"
fillOpacity={0.4} fillOpacity={0.4}
stroke="hsl(var(--chart-1))" stroke="hsl(var(--chart-1))"
@@ -95,5 +108,6 @@ export const RequestDistributionChart = ({
</AreaChart> </AreaChart>
</ChartContainer> </ChartContainer>
</ResponsiveContainer> </ResponsiveContainer>
</div>
); );
}; };