0

I'm using Haml.

So the code is this:

 = pie_chart @chart_ratings, donut: true, suffix: "%", loading: "Generating charts...", download: true, width: "350px", library: {plotOptions: { pie: { dataLabels: { enabled: true }}}}

But the library doesn't include the labels.

Is there anything missing?

Thanks for all the fish
  • 1,671
  • 3
  • 17
  • 31

1 Answers1

0

I found the solution.

Chart.js doesn't support labels inside of the chart. So instead, I'm using Highcharts.

  1. Install the highchart. You can have both libraries in the Chartkick installation.

    yarn add highchart

  2. Then you add the following into the application.js file.

    import "chartkick/highcharts"

  3. Then in the view for the pie chart, you append this.

    = pie_chart @data, donut: true, library: { pieSliceText: 'value-and-percentage', plotOptions: {pie: {dataLabels: {enabled: true,format: '{point.name}:
    {point.percentage:.1f} %',}}}}

Thanks for all the fish
  • 1,671
  • 3
  • 17
  • 31