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,51 +49,65 @@ export const RequestDistributionChart = ({
); );
return ( return (
<ResponsiveContainer width="100%" height={200}> <div className="w-full h-[200px] overflow-hidden">
<ChartContainer config={chartConfig}> <ResponsiveContainer
<AreaChart width="100%"
accessibilityLayer height="100%"
data={stats || []} className="overflow-hidden"
margin={{ >
left: 12, <ChartContainer config={chartConfig}>
right: 12, <AreaChart
}} accessibilityLayer
> data={stats || []}
<CartesianGrid vertical={false} /> margin={{
<XAxis top: 10,
dataKey="hour" left: 12,
tickLine={false} right: 12,
axisLine={false} bottom: 0,
tickMargin={8} }}
tickFormatter={(value) => >
new Date(value).toLocaleTimeString([], { <CartesianGrid vertical={false} />
hour: "2-digit", <XAxis
minute: "2-digit", dataKey="hour"
}) tickLine={false}
} axisLine={false}
/> tickMargin={8}
<YAxis tickLine={false} axisLine={false} tickMargin={8} /> tickFormatter={(value) =>
<ChartTooltip new Date(value).toLocaleTimeString([], {
cursor={false} hour: "2-digit",
content={<ChartTooltipContent indicator="line" />} minute: "2-digit",
labelFormatter={(value) => })
new Date(value).toLocaleString([], { }
month: "short", />
day: "numeric", <YAxis
hour: "2-digit", tickLine={false}
minute: "2-digit", axisLine={false}
}) tickMargin={8}
} allowDataOverflow={false}
/> domain={[0, "auto"]}
<Area />
dataKey="count" <ChartTooltip
type="natural" cursor={false}
fill="hsl(var(--chart-1))" content={<ChartTooltipContent indicator="line" />}
fillOpacity={0.4} labelFormatter={(value) =>
stroke="hsl(var(--chart-1))" new Date(value).toLocaleString([], {
/> month: "short",
</AreaChart> day: "numeric",
</ChartContainer> hour: "2-digit",
</ResponsiveContainer> minute: "2-digit",
})
}
/>
<Area
dataKey="count"
type="monotone"
fill="hsl(var(--chart-1))"
fillOpacity={0.4}
stroke="hsl(var(--chart-1))"
/>
</AreaChart>
</ChartContainer>
</ResponsiveContainer>
</div>
); );
}; };