I'm using recharts to create pie charts. When look at this example, http://recharts.org/#/en-US/examples/PieResponsiveContainer the pie chart can be centered using ResponsiveContainer component.
But my attempt failed : https://codesandbox.io/s/ll68p643xl. Try to change the size of the viewport to a larger width, the pie isn't center anymore. I wonder what's wrong here.
ResponsiveContainer
just makes the pie take the size of its container. If you inspect the html, you will see that the container is in fact the size of its parent. If you want to center it, you can make the container not take the whole parent, and use css. Something like this:
.pie-row .pie-wrap > div {
background: red;
margin: 0 auto;
}
And then the container:
<ResponsiveContainer className="container" height={70} width='30%'>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With