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

自闭症网瘾萝莉.ら 提交于 2019-12-31 03:53:05

问题


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

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

回答1:


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



来源:https://stackoverflow.com/questions/35197744/how-to-show-count-of-data-along-with-percentage-in-chartkicks-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!