ChartKick Show original value rather percentage in PIE and line chart

梦想与她 提交于 2019-12-11 02:28:21

问题


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

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