Support

Account

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;?>