2

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

Sebastian Bochan
  • 37,348
  • 3
  • 49
  • 75

2 Answers2

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' }
Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160
1

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.

Community
  • 1
  • 1
CyDharttha
  • 59
  • 7