From 8d6ab968860d06f8b965351f22b811f02e836b93 Mon Sep 17 00:00:00 2001 From: Tomasz Stalka Date: Fri, 3 Mar 2017 08:43:15 +0100 Subject: [PATCH 1/2] Added sample 2 axis --- src/classes/CorporateDashboardController.cls | 84 ++++++++++++++++++++ src/pages/CorporateDashboardPage.page | 14 ++++ 2 files changed, 98 insertions(+) diff --git a/src/classes/CorporateDashboardController.cls b/src/classes/CorporateDashboardController.cls index 27cf8439..cb867107 100644 --- a/src/classes/CorporateDashboardController.cls +++ b/src/classes/CorporateDashboardController.cls @@ -27,4 +27,88 @@ public without sharing class CorporateDashboardController { public void resetRefreshFlag() { this.refreshing = false; } + + public List getPerformanceData() { + List performanceData = new List(); + performanceData.add(new DoubleLineChartData('Jan', 3000.0, 9.0)); + performanceData.add(new DoubleLineChartData('Feb', 4400.0, 1.5)); + performanceData.add(new DoubleLineChartData('Mar', 2500.0, 3.2)); + performanceData.add(new DoubleLineChartData('Apr', 7400.0, 2.8)); + performanceData.add(new DoubleLineChartData('May', 6500.0, 5.1)); + performanceData.add(new DoubleLineChartData('Jun', 3300.0, 4.5)); + performanceData.add(new DoubleLineChartData('Jul', 9200.0, 8.2)); + performanceData.add(new DoubleLineChartData('Aug', 8700.0, 7.3)); + performanceData.add(new DoubleLineChartData('Sep', 3400.0, 6.5)); + performanceData.add(new DoubleLineChartData('Oct', 7800.0, 6.6)); + performanceData.add(new DoubleLineChartData('Nov', 8000.0, 6.7)); + performanceData.add(new DoubleLineChartData('Dec', 1700.0, 7.0)); + return performanceData; + } + + + public List getData() { + try { + Reports.reportResults results = Reports.ReportManager.runReport('00Ob00000047rxW', true); + Reports.Dimension dim = results.getGroupingsDown(); + Map columnsInfo = results.getReportExtendedMetadata().getAggregateColumnInfo(); + Reports.GroupingValue groupingVal = dim.getGroupings()[0]; + Integer columnNumber = 0; + + Map labelIdx = new Map(); + for (Reports.AggregateColumn agColumn : columnsInfo.values()) { + labelIdx.put(agColumn.getLabel(), columnNumber); + columnNumber++; + } + + Integer avgPageLoadId = 0; + Integer avgSubmissionsId = 0; + Integer avgServerApdexId = 0; + if (labelIdx.containsKey('Avg Page Load') && labelIdx.containsKey('Avg # of Submissions') && labelIdx.containsKey('Avg Server Apdex')) { + Integer avgPageLoadId = labelIdx.get('Avg Page Load'); + Integer avgSubmissionsId = labelIdx.get('Avg # of Submissions'); + Integer avgServerApdexId = labelIdx.get('Avg Server Apdex'); + } else { + break; + //TODO send email + } + + for (Reports.GroupingValue gValue : dim.getGroupings()) { + String monthName = gValue.getLabel(); + String factMapKey = gValue.getKey() + '!T'; + + Reports.ReportFactWithDetails factDetails = (Reports.ReportFactWithDetails)results.getFactMap().get(factMapKey); + system.debug(monthName + ' ' + (Decimal) factDetails.getAggregates()[avgPageLoadId].getValue() + ' ' +(Decimal) factDetails.getAggregates()[avgSubmissionsId].getValue(), + (Decimal) factDetails.getAggregates()[avgServerApdexId].getValue()); + performanceData.add(new DoubleLineChartData(monthName, (Decimal) factDetails.getAggregates()[avgPageLoadId].getValue(), (Decimal) factDetails.getAggregates()[avgSubmissionsId].getValue(), + (Decimal) factDetails.getAggregates()[avgServerApdexId].getValue())); + } + } catch(Exception e) { + break; + } + } + + public class DoubleLineChartData { + + public String name { get; set; } + public String name2 { get; set; } + public Decimal valueLeftY { get; set; } + public Decimal valueRightY { get; set; } + + public Decimal avgPageLoad { get; set; } + public Decimal avgSubmissions { get; set; } + public Decimal avgServerApdex { get; set; } + + public DoubleLineChartData(String name, Decimal avgPageLoad, Decimal avgSubmissions, Decimal avgServerApdex) { + this.name = name; + this.avgPageLoad = avgPageLoad; + this.avgSubmissions = avgSubmissions; + this.avgServerApdex = avgServerApdex; + } + + public DoubleLineChartData(String name, Decimal valueLeftY, Decimal valueRightY) { + this.name = name; + this.valueLeftY = valueLeftY; + this.valueRightY = valueRightY; + } + } } \ No newline at end of file diff --git a/src/pages/CorporateDashboardPage.page b/src/pages/CorporateDashboardPage.page index 9be77477..7b61a83f 100644 --- a/src/pages/CorporateDashboardPage.page +++ b/src/pages/CorporateDashboardPage.page @@ -63,6 +63,20 @@ + + + + + + + + + + + + + + From bf3271d3ed85824c675e073cb0e8da029ae6264e Mon Sep 17 00:00:00 2001 From: Tomasz Stalka Date: Tue, 7 Mar 2017 13:10:09 +0100 Subject: [PATCH 2/2] Added 2 axis graphs --- src/classes/CorporateDashboardController.cls | 86 ++++++++------------ src/pages/CorporateDashboardPage.page | 84 +++++++++++++------ 2 files changed, 93 insertions(+), 77 deletions(-) diff --git a/src/classes/CorporateDashboardController.cls b/src/classes/CorporateDashboardController.cls index cb867107..5fb2530b 100644 --- a/src/classes/CorporateDashboardController.cls +++ b/src/classes/CorporateDashboardController.cls @@ -4,6 +4,7 @@ public without sharing class CorporateDashboardController { public Boolean refreshing { get; set;} + public List performanceData { get; set;} public CorporateDashboardController() { this.refreshing = false; @@ -28,72 +29,57 @@ public without sharing class CorporateDashboardController { this.refreshing = false; } - public List getPerformanceData() { - List performanceData = new List(); - performanceData.add(new DoubleLineChartData('Jan', 3000.0, 9.0)); - performanceData.add(new DoubleLineChartData('Feb', 4400.0, 1.5)); - performanceData.add(new DoubleLineChartData('Mar', 2500.0, 3.2)); - performanceData.add(new DoubleLineChartData('Apr', 7400.0, 2.8)); - performanceData.add(new DoubleLineChartData('May', 6500.0, 5.1)); - performanceData.add(new DoubleLineChartData('Jun', 3300.0, 4.5)); - performanceData.add(new DoubleLineChartData('Jul', 9200.0, 8.2)); - performanceData.add(new DoubleLineChartData('Aug', 8700.0, 7.3)); - performanceData.add(new DoubleLineChartData('Sep', 3400.0, 6.5)); - performanceData.add(new DoubleLineChartData('Oct', 7800.0, 6.6)); - performanceData.add(new DoubleLineChartData('Nov', 8000.0, 6.7)); - performanceData.add(new DoubleLineChartData('Dec', 1700.0, 7.0)); - return performanceData; - } - - public List getData() { + this.performanceData = new List(); + Boolean error = false; + String message = ''; try { Reports.reportResults results = Reports.ReportManager.runReport('00Ob00000047rxW', true); Reports.Dimension dim = results.getGroupingsDown(); Map columnsInfo = results.getReportExtendedMetadata().getAggregateColumnInfo(); Reports.GroupingValue groupingVal = dim.getGroupings()[0]; - Integer columnNumber = 0; - Map labelIdx = new Map(); + Set labelIdx = new Set(); for (Reports.AggregateColumn agColumn : columnsInfo.values()) { - labelIdx.put(agColumn.getLabel(), columnNumber); - columnNumber++; + labelIdx.add(agColumn.getLabel()); } - Integer avgPageLoadId = 0; - Integer avgSubmissionsId = 0; - Integer avgServerApdexId = 0; - if (labelIdx.containsKey('Avg Page Load') && labelIdx.containsKey('Avg # of Submissions') && labelIdx.containsKey('Avg Server Apdex')) { - Integer avgPageLoadId = labelIdx.get('Avg Page Load'); - Integer avgSubmissionsId = labelIdx.get('Avg # of Submissions'); - Integer avgServerApdexId = labelIdx.get('Avg Server Apdex'); - } else { - break; - //TODO send email + if (!labelIdx.contains('Avg Page Load') || !labelIdx.contains('Avg # of Submissions') || !labelIdx.contains('Avg Server Apdex')) { + error = true; + message = 'Cannot find Aggregates'; } - for (Reports.GroupingValue gValue : dim.getGroupings()) { - String monthName = gValue.getLabel(); - String factMapKey = gValue.getKey() + '!T'; - - Reports.ReportFactWithDetails factDetails = (Reports.ReportFactWithDetails)results.getFactMap().get(factMapKey); - system.debug(monthName + ' ' + (Decimal) factDetails.getAggregates()[avgPageLoadId].getValue() + ' ' +(Decimal) factDetails.getAggregates()[avgSubmissionsId].getValue(), - (Decimal) factDetails.getAggregates()[avgServerApdexId].getValue()); - performanceData.add(new DoubleLineChartData(monthName, (Decimal) factDetails.getAggregates()[avgPageLoadId].getValue(), (Decimal) factDetails.getAggregates()[avgSubmissionsId].getValue(), - (Decimal) factDetails.getAggregates()[avgServerApdexId].getValue())); + if (error == false) { + for (Reports.GroupingValue gValue : dim.getGroupings()) { + String monthName = gValue.getLabel(); + String factMapKey = gValue.getKey() + '!T'; + + Reports.ReportFactWithDetails factDetails = (Reports.ReportFactWithDetails)results.getFactMap().get(factMapKey); + System.debug(monthName + ' ' + (Decimal) factDetails.getAggregates()[0].getValue() + ' ' +(Decimal) factDetails.getAggregates()[1].getValue() + + ' ' + (Decimal) factDetails.getAggregates()[2].getValue()); + this.performanceData.add(new DoubleLineChartData(monthName, (Decimal) factDetails.getAggregates()[0].getValue(), (Decimal) factDetails.getAggregates()[1].getValue(), + (Decimal) factDetails.getAggregates()[2].getValue())); + } } } catch(Exception e) { - break; + message = e.getMessage(); + error = true; + } + + if (error == true) { + System.debug('Cannot load performance data'); + if (!Test.isRunningTest()) { + EmailHelper.sendEmail(BatchDefaultSettings__c.getOrgDefaults().Error_Emails__c.split(','), 'Cannot load performance data for Corporate Dashboard', + 'report Id : 00Ob00000047rxW ' + message); + } } + + return this.performanceData; } public class DoubleLineChartData { public String name { get; set; } - public String name2 { get; set; } - public Decimal valueLeftY { get; set; } - public Decimal valueRightY { get; set; } - public Decimal avgPageLoad { get; set; } public Decimal avgSubmissions { get; set; } public Decimal avgServerApdex { get; set; } @@ -101,14 +87,8 @@ public without sharing class CorporateDashboardController { public DoubleLineChartData(String name, Decimal avgPageLoad, Decimal avgSubmissions, Decimal avgServerApdex) { this.name = name; this.avgPageLoad = avgPageLoad; - this.avgSubmissions = avgSubmissions; + this.avgSubmissions = avgSubmissions / 1000.00; this.avgServerApdex = avgServerApdex; } - - public DoubleLineChartData(String name, Decimal valueLeftY, Decimal valueRightY) { - this.name = name; - this.valueLeftY = valueLeftY; - this.valueRightY = valueRightY; - } } } \ No newline at end of file diff --git a/src/pages/CorporateDashboardPage.page b/src/pages/CorporateDashboardPage.page index 7b61a83f..aec7c1ce 100644 --- a/src/pages/CorporateDashboardPage.page +++ b/src/pages/CorporateDashboardPage.page @@ -12,6 +12,9 @@ body .secondaryPalette.bPageBlock { background-color: white; } + .graph { + height: 270px + }