Last active
October 29, 2015 12:08
-
-
Save atulgupta31/50bbae56865f02dbf106 to your computer and use it in GitHub Desktop.
apex:chart
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