decimal to toFixed() in recharts

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

How to format the integer value in Yaxis? I have tried toFixed but it's still giving me the error. Is there any other way I can implement this?

2 Answers

This might help

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

You could try something like this:

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