Nivo HeatMap 不显示尾随零

Nivo HeatMap not showing trailing zeros

我正在使用 Nivo HeatMap,我注意到对于 y 值,它始终接受一个数字,即使我强制传递 .00 位,它仍会截断并显示没有尾随零的值。它期望的数据格式如下:

{
    id: string
    data: {
        x: string | number
        y: number | null
    }[]
}[]

有没有人能够找到显示 1.00 而不是 1 的解决方法(见下面的屏幕截图? Nivo sample graph

您应该使用定点表示法格式化您的数据。 在您的组件中,您应该添加具有以下值的 valueFormat 属性:

<ResponsiveHeatMap
    data={data}
    // Indicates fix point notation (f) with a precision of 2 (.2), 
    // right aligning the field (>) and a minus sign if negative (-)
    valueFormat="0>-.2f" />