Home › Forums › Add-ons › Repeater Field › How to Create donut chart using repeater field data › Reply To: How to Create donut chart using repeater field data
I’m using ACF repeater fields and there are two sub field. One is label and other field has data.
<?php if( have_rows('donut_graph_details') ): ?>
<?php while( have_rows('donut_graph_details') ): the_row() ;
$title = get_sub_field('title');
$percentage = get_sub_field('percentage');
?>
<canvas data-bs-chart=”{"type":"doughnut"
,"data":{"labels":["Direct","Social","Referral"]
,"datasets":[{"label":""
,"backgroundColor":["#4e73df","#1cc88a","#36b9cc"]
,"borderColor":["#ffffff","#ffffff","#ffffff"]
,"data":["50","30","15"]}]}
,"options":{"maintainAspectRatio":false,"legend":{"display":false}
,"title":{}}}”>
</canvas>
<?php endwhile; endif;?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.