Har*_*ani 1 css charts pie-chart reactjs recharts
我正在使用PieCharts 的recharts库。
能够paddingAngle={0}删除填充角度,但想要删除单元格分隔符(白色)。
代码:
const data = [
{ id: "1", name: "L1", value: 75 },
{ id: "2", name: "L2", value: 25 }
];
<PieChart width={50} height={50}>
<text
x={25}
y={25}
textAnchor="middle"
dominantBaseline="middle"
>
25
</text>
<Pie
data={data}
dataKey="value"
innerRadius="80%"
outerRadius="100%"
fill="#82ca9d"
startAngle={90}
endAngle={-270}
paddingAngle={0}
cornerRadius={5}
>
<Cell
key="test"
fill="#CCC"
/>
</Pie>
</PieChart>Run Code Online (Sandbox Code Playgroud)
目前的样子:
想要这样实现:
如何实现这一目标?
谢谢
终于得到了解决方案。PieChart建议使用而不是使用 解决方法RadialBarChart
解决方案:
const data = [
{ name: 'L1', value: 25 }
];
const circleSize = 30;
<RadialBarChart
width={circleSize}
height={circleSize}
cx={circleSize / 2}
cy={circleSize / 2}
innerRadius={12}
outerRadius={18}
barSize={2}
data={data}
startAngle={90}
endAngle={-270}
>
<PolarAngleAxis
type="number"
domain={[0, 100]}
angleAxisId={0}
tick={false}
/>
<RadialBar
background
clockWise
dataKey="value"
cornerRadius={circleSize / 2}
fill="#82ca9d"
/>
<text
x={circleSize / 2}
y={circleSize / 2}
textAnchor="middle"
dominantBaseline="middle"
className="progress-label"
>
25
</text>
</RadialBarChart>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7844 次 |
| 最近记录: |