1

Using chartkicks for showing charts. It show percentage only . I want to show count/amount along with percentage.

<%= pie_chart visits.group(:country).count %>
Sebastian Bochan
  • 37,348
  • 3
  • 49
  • 75
Haseeb Ahmad
  • 7,914
  • 12
  • 55
  • 133

1 Answers1

2

Chartkick gem is a wrapper on top of Google Charts. By using library option you can specify what value to show in the legend and set other configuration options.

So something like:

<%= pie_chart visits.group(:country).count, library: {pieSliceText:
'value-and-percentage'} %>

See this link for more configuration options: https://developers.google.com/chart/interactive/docs/gallery/piechart#configuration-options

aliibrahim
  • 1,695
  • 1
  • 12
  • 18
  • From where you get this ", library: {pieSliceText: 'value-and-percentage'}". – Haseeb Ahmad Feb 04 '16 at 10:57
  • This is currently undocumented but if you look at the library code you will find this option as i also had to use it in one of my projects before. So use it at your own discretion. – aliibrahim Feb 04 '16 at 10:58