如何在Rails的图表中显示数据计数以及百分比 [英] How to show count of data along with percentage in chartkicks in rails
本文介绍了如何在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 %>
推荐答案
Chartkick
gem是 Google图表
的包装。通过使用库选项,您可以指定要在传奇
中显示的值,并设置其他配置选项。
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.
类似这样:
<%= pie_chart visits.group(:country).count, library: {pieSliceText:
'value-and-percentage'} %>
有关更多配置选项,请参见此链接: https://developers.google.com/chart/interactive/docs/gallery/piechart#configuration-options
See this link for more configuration options: https://developers.google.com/chart/interactive/docs/gallery/piechart#configuration-options
这篇关于如何在Rails的图表中显示数据计数以及百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文