user2261694
user2261694

Reputation: 41

ChartKick Show original value rather percentage in PIE and line chart

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

Upvotes: 2

Views: 1691

Answers (2)

CyDharttha
CyDharttha

Reputation: 69

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.

Upvotes: 2

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121000

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' }

Upvotes: 1

Related Questions