<BarChart
isAnimationActive={false}
width={400}
height={200}
data={value}
margin={{
top: 5, right: 30, left: 20,
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="x"
/>
<YAxis label={{ value: `no.`, angle: -90, position: 'insideBottomLeft' }} />
<Tooltip
content={<CustomTooltip />}
/>
<Bar dataKey="y" /* fill={colors[0]} */ >
</BarChart>我在x轴上的数据是数字0,1,2,3...但我希望我的记号是A1,A2,A3...
发布于 2020-11-05 15:51:50
您可以使用格式化程序属性,下面是一个示例
<XAxis dataKey="x" tickFormatter={(t) => `A${t+1}`} />发布于 2020-11-05 16:27:33
更改您的value键
const value = [
{
x: 'A1', ......
},
{
x: 'A2', .....
},
]或者,您可以使用以下命令:
<XAxis
dataKey="x"
tickFormatter={(t) => {
const count = parseInt(t) + 1
return 'A'+ count;
}
}
/>https://stackoverflow.com/questions/64692408
复制相似问题