我正在使用 ComdedChart 和 shoing 条形图和线条。通常该线应从 x 轴的 0 处开始。但是当使用组合图表时无法做到这一点
如果您在上图中观察到勾选a应该从 x 轴开始(x 轴和 y 轴开始的 0 点)但事实并非如此
这是我正在使用的代码
<ResponsiveContainer width="100%" height="100%">
<ComposedChart
width={500}
height={400}
data={[{ count: 0, label: 'a' }, { count: 2, label: 'b' }, { count: 3, label: 'c' }]}
>
<CartesianGrid horizontal={false} strokeDasharray="4 4" />
<XAxis ticks={['a', 'b', 'c']} domain={['dataMin', 'dataMax']} dataKey="label" />
<YAxis label={{ value: 'No.Of Employees', angle: -90, position: 'insideLeft' }} tick={false} />
<Tooltip />
<Bar dataKey="count" barSize={20} fill="#AAE5F9" />
<Line dot={false} type="monotone" dataKey="count" stroke="#3080ED" />
{/* <LabelList dataKey="name" position="insideTop" /> */}
</ComposedChart>
</ResponsiveContainer>
无论如何,我可以从 X 轴的起点(我的意思是从 x 轴的 0 点)开始画线吗?
任何帮助将不胜感激
根据这个github https://github.com/recharts/recharts/issues/367问题,需要添加scale="point"
在你的XAxis
<XAxis
ticks={['a', 'b', 'c']}
domain={['dataMin', 'dataMax']}
dataKey="label"
scale="point"
/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)