Skip to content

Commit c9ac723

Browse files
committed
fix(requests): remove nested ResponsiveContainer breaking chart height
1 parent 6e5ac41 commit c9ac723

1 file changed

Lines changed: 55 additions & 67 deletions

File tree

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
Area,
3-
AreaChart,
4-
CartesianGrid,
5-
ResponsiveContainer,
6-
XAxis,
7-
YAxis,
8-
} from "recharts";
1+
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts";
92
import {
103
type ChartConfig,
114
ChartContainer,
@@ -49,65 +42,60 @@ export const RequestDistributionChart = ({
4942
);
5043

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

0 commit comments

Comments
 (0)