Page:
======
<apex:page controller="PieChartController1" title="Pie Chart" sidebar="false">
<center> <apex:chart height="350" width="450" data="{!pieData}">
<apex:pieSeries dataField="data" labelField="name"/>
<apex:legend position="right"/>
</apex:chart>
</center>
</apex:page>
Controller
========
public class PieChartController1 {
public List<PieWedgeData> getPieData() {
List<PieWedgeData> data = new List<PieWedgeData>();
integer i=0;
for(Opportunity opp:[select id,name,stagename,amount from Opportunity limit 10]){
data.add(new PieWedgeData(opp.name,i++));
}
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;
}
}
}
Output:
======
No comments:
Post a Comment