图表中的小数转换为 toFixed()

Ayu*_*mar 3 reactjs recharts

<YAxis
          orientation="right"
          // YAxis={{
          //   tickFormatter: (Estimated_minutes) =>
          //     parseFloat(Estimated_minutes).toFixed(0),
          // }}
          formatter={formatYAxis}
          type="number"
          yAxisId="2"
          dataKey="Estimated_minutes"
          fill="#000000"
        />
Run Code Online (Sandbox Code Playgroud)

如何格式化 中的整数值Yaxis?我已经尝试过toFixed,但它仍然给我错误。我还有其他方法可以实现这个吗?

小智 6

这可能有帮助

<YAxis
   type="number"
   tickFormatter={(value) => value.toFixed(2)}
   domain={["dataMin", "auto"]}
   allowDecimals={true}
/>
Run Code Online (Sandbox Code Playgroud)