Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Nivo HeatMap not showing trailing zeros

I am working with Nivo HeatMap and I notice that for the y value, it always accepts a number and even if I force pass the .00 digits, it will still truncate and display the value without the trailing zeros. The format of the data it expects is the following:

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

Has anyone been able to find a workaround to display 1.00 instead of just 1 (see screenshot below?
Nivo sample graph

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You should format your data using fixed point notation.
In your component you should add the valueFormat prop with the following value:

<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" />
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading