Created
October 29, 2015 11:56
-
-
Save anonymous/b8e8c8dce29f9bdbdcc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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