Reputation: 56
I have a basic Gauge chart (see below) component that renders a PieChart with startAngle={180} and endAngle={0}, but I'm unable to make it fit the container...
How it looks like right now:
How it's supposed to look like:
Here is a demo of a basic version: https://codesandbox.io/s/recharts-playground-3zibx
Upvotes: 1
Views: 4426
Reputation: 11
Use the cy props and assign value in percentage. Ex. cy={'70%'}.
<div style={{ width: 500, height: 260, border: "1px solid black" }}>
<PieChart height={260} width={500}>
<Pie startAngle={180}
endAngle={0}
innerRadius="55%"
data={data}
dataKey="value"
labelLine={false}
blendStroke
isAnimationActive={false}
cy={"70%"}>
<Cell fill="#000" />
<Cell fill="#eaeaea" />
</Pie>
</PieChart>
</div>
Upvotes: 1
Reputation: 1211
You can use margin top and bottom. For example for (width:500, height: 260) you should set (top:760, bottom: 500):
To use full width and stick to bottom:
Top = Width + Height, Bottom = Width
<div style={{ width: 500, height: 260, border: "1px solid black" }}>
<PieChart height={260} width={500} margin={{ top: 760, bottom: 500 }}>
<Pie
startAngle={180}
endAngle={0}
innerRadius="56%"
data={data}
dataKey="value"
labelLine={false}
blendStroke
isAnimationActive={false}
>
<Cell fill="#000" />
<Cell fill="#eaeaea" />
</Pie>
</PieChart>
</div>
Upvotes: 0