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

chin-idean picture chin-idean  路  3Comments

FabioFleitas picture FabioFleitas  路  3Comments

alexandersoto picture alexandersoto  路  3Comments

scottdickerson picture scottdickerson  路  3Comments

adrianmcli picture adrianmcli  路  3Comments