Skip to content

Instantly share code, notes, and snippets.

Created October 29, 2015 11:56
Show Gist options
  • Save anonymous/b8e8c8dce29f9bdbdcc8 to your computer and use it in GitHub Desktop.
Save anonymous/b8e8c8dce29f9bdbdcc8 to your computer and use it in GitHub Desktop.
public class vfc_pieSeries{
public vfc_pieSeries(){
}
public List<PieWedgeData> getPieData() {
List<PieWedgeData> data = new List<PieWedgeData>();
List<AggregateResult> opps = [SELECT SUM(Amount) monthlyRevenue, COUNT(Name) numOppsClosedWon,
CALENDAR_MONTH(CloseDate) theMonth
FROM Opportunity
GROUP BY CALENDAR_MONTH(CloseDate)];
for(AggregateResult ar : opps){
String month = String.valueOf(ar.get('theMonth')); //this comes out as a number, not a word value
Integer revenue = Integer.valueOf(ar.get('monthlyRevenue'));
data.add(new PieWedgeData(month, revenue));
}
return data;
}
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;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment