问题
I've data like
graph_data = {
"Commercial"=>364,
"Residential"=>463,
"Hospitality"=>150,
"Industrial"=>20,
"Laboratory"=>1
}
pie_chart graph_data
when I add this in the pie chart, it displays the chart with percentage of each option, I wan to display the value rather percentage, How i can do this,
I'm using Chartkick gem with ruby on rails 4
回答1:
Chartkick
uses Google Visualization library to draw charts. Here is options description: https://developers.google.com/chart/interactive/docs/gallery/piechart?csw=1#Example
pie_chart graph_data, { pieSliceText: 'value' }
回答2:
Here is the syntax I found that worked:
<%= pie_chart @my_data, library: { pieSliceText: 'value' } %>
I found this answer over at https://stackoverflow.com/a/35199044 and tested it successfully.
来源:https://stackoverflow.com/questions/29965684/chartkick-show-original-value-rather-percentage-in-pie-and-line-chart