无法使量规图(使用Recharts Pie)适合容器

问题描述 投票:0回答:1

我有一个基本的仪表图图表(见下文)组件,该组件使用startAngle = {180}和endAngle = {0}渲染PieChart,但我无法使其适合容器...

[现在看起来如何:

enter image description here

应该看起来像:

enter image description here

这里是基本版本的演示:https://codesandbox.io/s/recharts-playground-3zibx

reactjs pie-chart recharts
1个回答
0
投票

您可以使用顶部和底部边距(顶部:760,底部:560):

<div style={{ width: 500, height: 260, border: "1px solid black" }}>
      <PieChart height={260} width={500} margin={{ top: 760, bottom: 560 }}>
        <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>
© www.soinside.com 2019 - 2024. All rights reserved.