Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recharts - add commas to number on tooltip on bar chart

Is it possible to add a comma to large numbers on the tooltip?

for example 57,574 instead of 57574

enter image description here

Thanks!

like image 344
Gearóid Avatar asked Jul 17 '18 13:07

Gearóid


1 Answers

Yes, you can pass any formatter function to the Tooltip component, using the formatter prop e.g.

<BarChart>
  <Tooltip formatter={(value) => new Intl.NumberFormat('en').format(value)} />
</BarChart>

Check out the documentation here: http://recharts.org/en-US/api/Tooltip#formatter

like image 124
eronisko Avatar answered Sep 16 '22 15:09

eronisko