Haseeb Ahmad
Haseeb Ahmad

Reputation: 8730

Rails: Pie Charts legend in Chartkicks

In highcharts to show the percentage along with pie_charts, a legend can be customized like this:

legend: {labelFormat: '{name} : {y} ({percentage}%)'}

But in chartkicks I can't find how to do like this?

Upvotes: 4

Views: 1935

Answers (1)

aliibrahim
aliibrahim

Reputation: 1965

If you look at the documentation specified on the ChartKick Gem homepage, it says:

You can pass options directly to the charting library with:

<%= line_chart data, library: {backgroundColor: "#eee"} %>

So in your scenario, you should try something like:

<%= pie_chart data, library: {legend: {labelFormat: '{name} : {y} ({percentage}%)'}} %>

Upvotes: 3

Related Questions