recharts 中的 decimal 到 toFixed()
decimal to toFixed() in recharts
<YAxis
orientation="right"
// YAxis={{
// tickFormatter: (Estimated_minutes) =>
// parseFloat(Estimated_minutes).toFixed(0),
// }}
formatter={formatYAxis}
type="number"
yAxisId="2"
dataKey="Estimated_minutes"
fill="#000000"
/>
如何格式化Yaxis
中的整数值?我试过 toFixed
但它仍然给我错误。还有其他方法可以实现吗?
您可以尝试这样的操作:
<YAxis
orientation="right"
YAxis={{
tickFormatter: (Estimated_minutes) =>
parseFloat(Number(Estimated_minutes).toFixed(0)),
}}
formatter={formatYAxis}
type="number"
yAxisId="2"
dataKey="Estimated_minutes"
fill="#000000"
/>
这可能有帮助
<YAxis
type="number"
tickFormatter={(value) => value.toFixed(2)}
domain={["dataMin", "auto"]}
allowDecimals={true}
/>
<YAxis
orientation="right"
// YAxis={{
// tickFormatter: (Estimated_minutes) =>
// parseFloat(Estimated_minutes).toFixed(0),
// }}
formatter={formatYAxis}
type="number"
yAxisId="2"
dataKey="Estimated_minutes"
fill="#000000"
/>
如何格式化Yaxis
中的整数值?我试过 toFixed
但它仍然给我错误。还有其他方法可以实现吗?
您可以尝试这样的操作:
<YAxis
orientation="right"
YAxis={{
tickFormatter: (Estimated_minutes) =>
parseFloat(Number(Estimated_minutes).toFixed(0)),
}}
formatter={formatYAxis}
type="number"
yAxisId="2"
dataKey="Estimated_minutes"
fill="#000000"
/>
这可能有帮助
<YAxis
type="number"
tickFormatter={(value) => value.toFixed(2)}
domain={["dataMin", "auto"]}
allowDecimals={true}
/>