ads

Wednesday, 17 August 2016

Pie Chart In Salesforce



Controller Code :-


public class PicChart{
    public List<PieWedgeData> getPieData() {
        List<PieWedgeData> data = new List<PieWedgeData>();
        data.add(new PieWedgeData('SUNDAY', 30));
        data.add(new PieWedgeData('MONDAY', 55));
        data.add(new PieWedgeData('TUESDAY', 15));
        data.add(new PieWedgeData('WEDNESDAY', 10));
        data.add(new PieWedgeData('tHURSDAY', 20));
        data.add(new PieWedgeData('FRIDAY', 20));
        data.add(new PieWedgeData('SATURDAY', 5));
        return data;
    }

    // Wrapper class
    public class PieWedgeData {

        public String name { get; set; }
        public Integer data { get; set; }

        public PieWedgeData(String name, Integer data) {
            this.name = name;
            this.data = data;
        }
    }
}


Visualfore Page :-



<apex:page controller="PicChart" title="Pie Chart">
    <apex:chart height="350" width="450" data="{!pieData}">
        <apex:pieSeries dataField="data" labelField="name"/>
        <apex:legend position="right"/>
    </apex:chart>
</apex:page>

OutPut Screen 1 :-


No comments:

Post a Comment