Haseeb Ahmad
Haseeb Ahmad

Reputation: 8730

How to show count of data along with percentage in chartkicks in rails

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

<%= pie_chart visits.group(:country).count %>

Upvotes: 1

Views: 1985

Answers (1)

aliibrahim
aliibrahim

Reputation: 1965

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

Upvotes: 2

Related Questions