Recharts: how can I add string to Pie Chart Tooltip

Created on 26 Jun 2017  路  3Comments  路  Source: recharts/recharts

my data is look like this
{name: "xxxx", percentage:30}
and I use nameKey="name" and dataKey="percentage"

and tooltip in pie chart show "xxxx : 30"

I want to add % to the Tooltip so it should be "xxxx : 30%"

how can I do that?

Thanks in advance

Most helpful comment

@nuugut Use the props formatter of Tooltip;

<Tooltip formatter={someFormatterFunction} />

All 3 comments

@nuugut Use the props formatter of Tooltip;

<Tooltip formatter={someFormatterFunction} />

@xile611

do you have any example of {someFormatterFunction}?

Thanks

@nuugut

I have this simple example of the formatter:

const formatTooltip = value =>${value} ${unit};

Then into my chart component:

<Tooltip formatter={formatTooltip} ... />

(I used the "..." for the other props)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

patrick-lewandowski picture patrick-lewandowski  路  3Comments

amitava82 picture amitava82  路  3Comments

jetpack3331 picture jetpack3331  路  3Comments

abhayjeetgupta picture abhayjeetgupta  路  3Comments

Eric24 picture Eric24  路  3Comments