reactjs - 无法使仪表图表(使用 Recharts Pie)适合容器
问题描述
我有一个基本的仪表图(见下文)组件,它使用 startAngle={180} 和 endAngle={0} 呈现 PieChart,但我无法使其适合容器...
现在的样子:
它应该是什么样子:
这是一个基本版本的演示:https ://codesandbox.io/s/recharts-playground-3zibx
解决方案
使用 cy 道具并按百分比分配值。前任。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>
推荐阅读
- paypal - 我可以在 paypal api 的帮助下向我的 paypal 帐户付款吗
- android - 如何从解析服务器获取应用程序 ID?我找不到文件“Server.js”
- c++ - 计算二叉搜索树中的唯一值
- ios - 如何在 App Store 中构建、提交和添加 macOS 版本到 iOS 应用程序?
- assembly - 部分与段?
- python - 取消所有异步任务/不和谐 py 循环
- fortran - 使用 LAPACK 的 DORMQR 和非方形 Q
- java - 为什么 toLowerCase 不将字符串元素转换为小写?
- javascript - javascript: css 没有解决,为什么?
- python - 如何找到离线最近的点?