Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide data label of Chartkick Piechart

Dears, I am new to Rails development, and now try to use Chartkick to show a pie chart.

I uses Highchart by adding require highchart in application.js. Everything goes well except the data labels. I try to hide them but they are always there.

The original code is like:

new Chartkick.PieChart("changepie", {"WithoutChange":<%=@count_noChange%>,"WithChange":<%=@count_change%>}, {"colors":["#FF9900","#3366CC"]});

As answered in this post, I added

new Chartkick.PieChart("changepie", {"WithoutChange":<%=@count_noChange%>,"WithChange":<%=@count_change%>}, {"colors":["#FF9900","#3366CC"]}, {"library": { "plotOptions": { "pie": { "allowPointSelect": true, "cursor": "pointer", "dataLabels": { "enabled": false}, "showInLegend": true}}}} );

But the data label is still there? Could you please advise how to specify the options when creating a pie chart to hide data label?

Thanks!

like image 631
JohnZhang Avatar asked Feb 03 '26 18:02

JohnZhang


1 Answers

pie_chart data, library: {plotOptions: { pie: { dataLabels: { enabled: false }}}}
like image 102
Jose Hidalgo Avatar answered Feb 06 '26 06:02

Jose Hidalgo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!