function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sarvesh001sarvesh001 

Show Total value at middle in do nut chart

Hi,
I want to show total value  in middle of do nut chart.
I am using belo code , it is showing value correctly but i want ot show total value in middle.
Please help for this.......................

Regards,
Sarvesh.

vf code:
<div align="center">
        <apex:chart height="350" width="450" data="{!data}" background="#FFFFFF"> 
            <apex:pieSeries tips="true" dataField="data" labelField="name" donut="50" colorSet="#088A08,#FFBF00,#2ECCFA"/> 
            <apex:legend position="bottom"/>
            
Controller code:
public with sharing class Hsbs_ChartController {
     public List<PieWedgeData> getData() 
    {  
    string aid = ApexPages.currentPage().getParameters().get('id');
        List<PieWedgeData> data = new List<PieWedgeData>();
        List<HSBS_Survey_Results__c > memb = new List<HSBS_Survey_Results__c >();  
        
        String sql = 'SELECT Name, Account__c, N_TS_Green__c,N_TS_Safe__c,N_TS_Productive__c FROM HSBS_Survey_Results__c where Account__c=:aid limit 1';
        memb = Database.Query(sql);
        for(HSBS_Survey_Results__c temp:memb)
        {                                          
            data.add(new PieWedgeData('Green'+ ' ' +temp.N_TS_Green__c,temp.N_TS_Green__c));
            data.add(new PieWedgeData('Safe'+' ' +temp.N_TS_Safe__c,temp.N_TS_Safe__c));
            data.add(new PieWedgeData('Productive'+' ' +temp.N_TS_Productive__c,temp.N_TS_Productive__c));
        } 
        return data;  
    }  
    
    // Wrapper class  
    public class PieWedgeData 
    {  
        public String name { get; set; }  
        public Decimal data { get; set; }  
        
        public PieWedgeData(String name, Decimal data) 
        {  
            this.name = name;  
            this.data = data;  
        }  
    }  
   
    
}
        
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,
I think you can use Javascrit hack to show total value in the middle, if possible you can share the page code using developer too (F12), so that I can tell you the exact script.

--
Thanks,
Swayam
@salesforceguy