reactjs - recharts 中的 decimal 到 toFixed()

标签 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"
        />

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

最佳答案

这可能有帮助

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

关于reactjs - recharts 中的 decimal 到 toFixed(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65033974/

相关文章:

reactjs - 有没有办法将泛型类型传递给react useReducer hook 中使用的reducer?

Rechart - 由三个条组成的条形图中每个条的工具提示

javascript - React Recharts——从不同对象获取数据

reactjs - 为条形图中的条形指定半径

javascript - 无法读取 null 的属性(读取 'store' )

javascript - window.innerWidth 实时

reactjs - 每次鼠标悬停时重新绘制自定义标签渲染图

reactjs - 为什么在条形图中不显示 Y 轴,也不显示图表中 X 轴的所有标签?

javascript - Electron 打包后不支持 ES6

reactjs - 对象类型中缺少流属性