I have developed an apex pie chart. I want to display "percentage value" on the pie chart like below
But am getting the chart Like this:
How to do this ?
My apex class:
public class PieChartController {
public Decimal result{get;set;}
public Decimal result1{get;set;}
public Decimal totalRecords {get;set;}
public decimal yesVal{get;set;}
public Decimal noVal{get;set;}
public List<PieWedgeData> getPieData() {
List<PieWedgeData> data = new List<PieWedgeData>();
totalRecords = [select count() from Case];
result = [select count() from case where Spam__c != TRUE AND Type ='Complaint' AND StopSurvey__c = 'Yes' AND RecordType.ID != '012b0000000cVxi' AND ClosedDate <= THIS_MONTH AND ClosedDate >= LAST_N_MONTHS:12 AND (SubType__c !='GARANTIA-ORIGINAL' OR SubType__c !='GARANTIA-TRANSFERIDO' OR SubType__c !='Warranty')];
result1 = [select count() from case where Spam__c != TRUE AND Type ='Complaint' AND StopSurvey__c = 'No' AND RecordType.ID != '012b0000000cVxi' AND ClosedDate <= THIS_MONTH AND ClosedDate >= LAST_N_MONTHS:12 AND (SubType__c !='GARANTIA-ORIGINAL' OR SubType__c !='GARANTIA-TRANSFERIDO' OR SubType__c !='Warranty')];
yesVal=(result/totalrecords)*100;
noVal=(result1/totalRecords) * 100;
data.add(new PieWedgeData('% of StopSurvey Yes', yesVal));
data.add(new PieWedgeData('% of StopSurvey No', noVal));
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;
}
}
}
My VF page:
<apex:page controller="PieChartController" title="Pie Chart">
<apex:chart height="350" width="450" data="{!pieData}">
<apex:pieSeries dataField="data" labelField="name">
</apex:pieSeries>
<apex:legend position="right">
</apex:legend>
</apex:chart>
</apex:page>