我在将 VictoryAxis 安装到 VictoryChart 时遇到问题。轴似乎从我的 X 轴上的第二个值开始。
这就是它应该看起来的样子(第一个小节下 0,最后一个小节下 22 个)
但是,当我将标签添加为tickValues
ortickFormat
时,我得到了这个
这是我的代码
const dataX = ["0", "2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22"];
<VictoryChart width={Metrics.width - Metrics.gridSize * 4}
padding={{ left: 20, top: 10, right: 10, bottom: 30 }}
height={height}
containerComponent={<VictoryContainer responsive={false} />}
domain={{ x: [0, dataX.length] }}
>
<VictoryGroup offset={10}>
{data.map((chartData, index) => (
<VictoryBar
cornerRadius={3}
barWidth={10}
data={chartData.data}
key={index}
y="value"
/>
))}
</VictoryGroup>
{/* X-AXIS */}
<VictoryAxis tickValues={dataX} />
</VictoryChart>
欢迎任何帮助解决我的问题!
[编辑]
不向domain
VictoryChart 提供 a 并将tickValues
结果删除到此: