Nivo: Add value in Percentage

Created on 22 Feb 2019  Â·  10Comments  Â·  Source: plouc/nivo

Hello Team,
I need to add % with value like 15% , 20% something but i am not able to find that how can i add percentage with value in bar charts.

Thanks.!

bar question axes

Most helpful comment

@mehuljariwala, you'll have to use the following properties:

  • labelFormat which will format the values displayed on the rects
  • tooltipFormat which will take care of the values displayed in the tooltip
  • axis(Top|Right|Bottom|Left).format which will affect the axes' ticks

Something like:

const format = v => `${v}%`

const MyBarChart = () => (
    <ResponsiveBar
        // …
        labelFormat={format}
        tooltipFormat={format}
        axisLeft={{ format }}
    />
)

All 10 comments

In the x or y parameter just add + " %" after the number.
Example:

id:"Whatever",
color: "#00afd5",
data: {
x: 20
y: 15 + " %"
}

@mehuljariwala, you'll have to use the following properties:

  • labelFormat which will format the values displayed on the rects
  • tooltipFormat which will take care of the values displayed in the tooltip
  • axis(Top|Right|Bottom|Left).format which will affect the axes' ticks

Something like:

const format = v => `${v}%`

const MyBarChart = () => (
    <ResponsiveBar
        // …
        labelFormat={format}
        tooltipFormat={format}
        axisLeft={{ format }}
    />
)

@derviselimovic, thank you for the suggestion however the y axis uses a linear scale, so having string values won't work.

@plouc Oh okay, never actually realised that myself haha. Thanks for the info !

Thanks Plouc/Nivo for making such wonderful charts.
how can i need to add different color on different bar is give only one
color when i add bar.

On Tue, 5 Mar 2019 at 16:45, derviselimovic notifications@github.com
wrote:

@plouc https://github.com/plouc Oh okay, never actually realised that
myself haha. Thanks for the info !

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/plouc/nivo/issues/468#issuecomment-469641885, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AdFh-AkELeTez9FfdFEPJ4t4EWEXz6hEks5vTlHDgaJpZM4bJRho
.

--
Mehul Jariwala (Software* Engineer*)

Stackoverflow : mehul-jariwala
https://stackoverflow.com/users/6774364/mehul-jariwala?tab=profile
Linkedin * *: mjariwala98
https://www.linkedin.com/in/mehul-jariwala-352a01132/
Twitter * *: @mjariwala98 https://twitter.com/mjariwala98
Github * *: git_mehuljariwala
https://github.com/mehuljariwala
Freelancer : mehuljariwala98
https://www.freelancer.in/u/mehuljariwala98

Hello Team,
I need to add % with value like 15% , 20% something but i am not able to find that how can i add percentage with value in pie charts.

Thanks.!

Here you go @zahraghafari1996. https://nivo.rocks/storybook/?path=/story/pie--formatted-tooltip-values

Here you go @zahraghafari1996. https://nivo.rocks/storybook/?path=/story/pie--formatted-tooltip-values

thanks:D

hi again,can i display both value and percentage in tooltip of Pie Chart?

Yes, if you go to the next story you can get full control over the tooltip and display whatever you like in there. https://nivo.rocks/storybook/?path=/story/pie--custom-tooltip

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danpettay picture danpettay  Â·  3Comments

vagnervst picture vagnervst  Â·  4Comments

serendipity1004 picture serendipity1004  Â·  3Comments

tj picture tj  Â·  4Comments

gcloeval picture gcloeval  Â·  3Comments