I have manged to collect all required data but not able to parse it into the list so that i can pass my data into a chart. for now i have added debug data in to chart as static to relate this chart with debug, but i wants to pass these value dynamically and for that i should have map/wrapper class but i am not able to assign the data into it which method i need to use to collect the required data to show in below chart code.can anyone please help me to do this.
Please find my code,debug, chart code.
Controller:
Reports.reportResults results = Reports.ReportManager.runReport(reportId,false);
Reports.ReportMetadata rm = results.getReportMetadata();
//get report name
reportName1 = rm.getName();
system.debug('*****reportName:'+reportName);
//get factMap
Map<String,Reports.ReportFact> factMap = new Map<String,Reports.ReportFact>();
Map<String,Reports.ReportFactWithSummaries> summaryMap = new Map<String,Reports.ReportFactWithSummaries>();
factMap = results.getfactMap();
System.debug('***getfactMap:'+factMap);
List<Reports.ReportFact> countList = new List<Reports.ReportFact>();
for(Reports.ReportFact data:factMap.values())
{
System.debug('--->'+data);
}
Reports.Dimension dim = results.getGroupingsDown();
List<Reports.GroupingValue> groupingValList = dim.getGroupings();
for(Reports.GroupingValue grp1 : groupingValList)
{
System.debug('**dim**'+grp1);
}
Debug:
DEBUG|[56]|DEBUG|--->Reports.ReportFactWithSummaries[aggregates=(Reports.SummaryValue[label=28, value=28]), key=0!T]
DEBUG|[56]|DEBUG|--->Reports.ReportFactWithSummaries[aggregates=(Reports.SummaryValue[label=10, value=10]), key=0_0!T]
DEBUG|[56]|DEBUG|--->Reports.ReportFactWithSummaries[aggregates=(Reports.SummaryValue[label=4, value=4]), key=1!T]
DEBUG|[56]|DEBUG|--->Reports.ReportFactWithSummaries[aggregates=(Reports.SummaryValue[label=18, value=18]), key=0_1!T]
DEBUG|[56]|DEBUG|--->Reports.ReportFactWithSummaries[aggregates=(Reports.SummaryValue[label=20, value=20]), key=2!T]
DEBUG|[56]|DEBUG|--->Reports.ReportFactWithSummaries[aggregates=(Reports.SummaryValue[label=60, value=60]), key=T!T]
DEBUG|[56]|DEBUG|--->Reports.ReportFactWithSummaries[aggregates=(Reports.SummaryValue[label=8, value=8]), key=3!T]
DEBUG|[56]|DEBUG|--->Reports.ReportFactWithSummaries[aggregates=(Reports.SummaryValue[label=20, value=20]), key=2_0!T]
DEBUG|[56]|DEBUG|--->Reports.ReportFactWithSummaries[aggregates=(Reports.SummaryValue[label=4, value=4]), key=1_0!T]
DEBUG|[56]|DEBUG|--->Reports.ReportFactWithSummaries[aggregates=(Reports.SummaryValue[label=8, value=8]), key=3_0!T]
DEBUG|[65]|DEBUG|**dim**Reports.GroupingValue[groupings=(Reports.GroupingValue[groupings=null, key=0_0, label=Bristol, value=Bristol], Reports.GroupingValue[groupings=null, key=0_1, label=London, value=London]), key=0, label=Dep1, value=Dep1]
DEBUG|[65]|DEBUG|**dim**Reports.GroupingValue[groupings=(Reports.GroupingValue[groupings=null, key=1_0, label=Bristol, value=Bristol]), key=1, label=Dep2, value=Dep2]
DEBUG|[65]|DEBUG|**dim**Reports.GroupingValue[groupings=(Reports.GroupingValue[groupings=null, key=2_0, label=Cambridge, value=Cambridge]), key=2, label=Dep3, value=Dep3]
DEBUG|[65]|DEBUG|**dim**Reports.GroupingValue[groupings=(Reports.GroupingValue[groupings=null, key=3_0, label=London, value=London]), key=3, label=Dep4, value=Dep4]
Chart Code:
var config1 = {
type: 'line',
data: {
labels: ["","Dep1", "Dep2", "Dep3", "Dep4"],
datasets: [{
label: "Bristol",
borderColor: window.chartColors.red,
backgroundColor: window.chartColors.red,
data: [ 0,10,4,0,0],
fill: false,
}, {
label: "London",
borderColor: window.chartColors.blue,
backgroundColor: window.chartColors.blue,
data: [ 0,18,0,0,8],
fill: false,
},{
label: "Cambridge",
borderColor: window.chartColors.yellow,
backgroundColor: window.chartColors.yellow,
data: [0,0,0,20,0],
fill: false,
}]
},