Skip to content

Commit 1aac5c1

Browse files
authored
Merge pull request #3144 from Dokploy/3141-requests-chart-overflowing
refactor: enhance RequestDistributionChart layout and responsiveness
2 parents 25aecab + ea83406 commit 1aac5c1

File tree

1 file changed

+60
-46
lines changed

1 file changed

+60
-46
lines changed

apps/dokploy/components/dashboard/requests/request-distribution-chart.tsx

Lines changed: 60 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -49,51 +49,65 @@ export const RequestDistributionChart = ({
4949
);
5050

5151
return (
52-
<ResponsiveContainer width="100%" height={200}>
53-
<ChartContainer config={chartConfig}>
54-
<AreaChart
55-
accessibilityLayer
56-
data={stats || []}
57-
margin={{
58-
left: 12,
59-
right: 12,
60-
}}
61-
>
62-
<CartesianGrid vertical={false} />
63-
<XAxis
64-
dataKey="hour"
65-
tickLine={false}
66-
axisLine={false}
67-
tickMargin={8}
68-
tickFormatter={(value) =>
69-
new Date(value).toLocaleTimeString([], {
70-
hour: "2-digit",
71-
minute: "2-digit",
72-
})
73-
}
74-
/>
75-
<YAxis tickLine={false} axisLine={false} tickMargin={8} />
76-
<ChartTooltip
77-
cursor={false}
78-
content={<ChartTooltipContent indicator="line" />}
79-
labelFormatter={(value) =>
80-
new Date(value).toLocaleString([], {
81-
month: "short",
82-
day: "numeric",
83-
hour: "2-digit",
84-
minute: "2-digit",
85-
})
86-
}
87-
/>
88-
<Area
89-
dataKey="count"
90-
type="natural"
91-
fill="hsl(var(--chart-1))"
92-
fillOpacity={0.4}
93-
stroke="hsl(var(--chart-1))"
94-
/>
95-
</AreaChart>
96-
</ChartContainer>
97-
</ResponsiveContainer>
52+
<div className="w-full h-[200px] overflow-hidden">
53+
<ResponsiveContainer
54+
width="100%"
55+
height="100%"
56+
className="overflow-hidden"
57+
>
58+
<ChartContainer config={chartConfig}>
59+
<AreaChart
60+
accessibilityLayer
61+
data={stats || []}
62+
margin={{
63+
top: 10,
64+
left: 12,
65+
right: 12,
66+
bottom: 0,
67+
}}
68+
>
69+
<CartesianGrid vertical={false} />
70+
<XAxis
71+
dataKey="hour"
72+
tickLine={false}
73+
axisLine={false}
74+
tickMargin={8}
75+
tickFormatter={(value) =>
76+
new Date(value).toLocaleTimeString([], {
77+
hour: "2-digit",
78+
minute: "2-digit",
79+
})
80+
}
81+
/>
82+
<YAxis
83+
tickLine={false}
84+
axisLine={false}
85+
tickMargin={8}
86+
allowDataOverflow={false}
87+
domain={[0, "auto"]}
88+
/>
89+
<ChartTooltip
90+
cursor={false}
91+
content={<ChartTooltipContent indicator="line" />}
92+
labelFormatter={(value) =>
93+
new Date(value).toLocaleString([], {
94+
month: "short",
95+
day: "numeric",
96+
hour: "2-digit",
97+
minute: "2-digit",
98+
})
99+
}
100+
/>
101+
<Area
102+
dataKey="count"
103+
type="monotone"
104+
fill="hsl(var(--chart-1))"
105+
fillOpacity={0.4}
106+
stroke="hsl(var(--chart-1))"
107+
/>
108+
</AreaChart>
109+
</ChartContainer>
110+
</ResponsiveContainer>
111+
</div>
98112
);
99113
};

0 commit comments

Comments
 (0)