I am currently working with Recharts in combination with Next.js and Tailwindcss. I decided to create my own barchart by copying a code snippet from Recharts, but encountered an issue where changing the height to aspect worked fine, however setting the width to 100% did not expand the barchart to cover the entire width of the div as expected. How can I adjust my code to ensure that the barchart spans the full 100% width of the container?
Below is the code snippet I am referring to:
const MyChart = () => {
return (
<div className="flex shadow-md p-4 w-full pb-0 relative text-xs m-4">
<ResponsiveContainer width="100%" aspect={2}>
<AreaChart
width={500}
height={400}
data={data}
margin={{
top: 0,
right: 0,
left: 0,
bottom: 0,
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="name" />
<YAxis />
<Tooltip />
<Area type="monotone" dataKey="uv" stackId="1" stroke="#8884d8" fill="#8884d8" />
<Area type="monotone" dataKey="pv" stackId="1" stroke="#82ca9d" fill="#82ca9d" />
<Area type="monotone" dataKey="amt" stackId="1" stroke="#ffc658" fill="#ffc658" />
</AreaChart>
</ResponsiveContainer>
</div>
);
};