项目中经常会用到Report以及Dashboard来分析汇总数据,Dashboard可以指定view as user,如果针对不同的用户需要显示其允许查看的数据,比如  根据role hierarchy来显示数据,需要指定run as login user.但是dashboards runas the logged-in user是有数量的限制的,针对此种情况,就需要使用自定义实现Dashboard功能。

使用自定义操作可以通过apex class获取数据,在visualforce page上画不同组的chart,点击chart以后跳转到相关详情的report页面,但是这种情况无法处理funnel chart的情况,因为visualforce的api没有提供funnel chart样式的元素。

这种情况下,比较偷懒的操作为在Report上使用Role Hierarchy进行限制来对数据进行获取,然后在Report中配置chart,使用aynalytics:reportChart传递需要显示的report ids进行展示,从而实现dashboard的效果。

功能:实现自定义Dashboard,Dashboard显示两个chart,分别为通过Type对Account进行分组以及通过State/Province对Account分组,每个用户只能看到当前用户以及下级的内容。

准备工作:

1.创建Report,此Report通过Type进行分组,developername为Account_Report_By_Type

2.创建Report,此Report通过State/Province进行分组,developername为Account_By_Billing_State_Province

3.创建Dashboard,包含上面的两个Report,datasource也分别对应上面两个report。

准备工作结束,现在需要通过程序来实现上面的Dashboard。

1.AnalyticsReportChartController:用来获取上述两个report id,并放在reportIds

 public with sharing class AnalyticsReportChartController {
public List<Id> reportIds{get;set;}
public AnalyticsReportChartController() {
reportIds = new List<Id>();
reportIds.add(accountByTypeReportId);
reportIds.add(accountByStateProvinceReportId);
}
public Id accountByTypeReportId{
get {
if(accountByTypeReportId == null) {
Report rt = [select id from Report where DeveloperName = 'Account_Report_By_Type' limit 1];
accountByTypeReportId = rt.Id;
}
return accountByTypeReportId;
}set;
} public Id accountByStateProvinceReportId {
get {
if(accountByStateProvinceReportId == null) {
Report rt = [select id from Report where DeveloperName = 'Account_By_Billing_State_Province' limit 1];
accountByStateProvinceReportId = rt.Id;
}
return accountByStateProvinceReportId;
}set; }
}

2.AnalyticsReportChart.page:实现展示两个report的chart,点击后跳转到相关的report中

 <apex:page controller="AnalyticsReportChartController">
<apex:panelGrid columns="2">
<apex:outputPanel id="reportPanel">
<apex:repeat value="{!reportIds}" var="report">
<div style="display: inline-block;width: 400px;height: 400px;vertical-align: top;">
<analytics:reportChart reportId="{!report}" showRefreshButton="false" size="small" cacheResults="false"></analytics:reportChart>
</div>
</apex:repeat>
</apex:outputPanel>
</apex:panelGrid>
</apex:page>

效果展示:

总结:使用analytics:reportChart可以很方便的实现DashBoard的展示效果,但是此种方式仅限于Dashboard中的一个Chart对应一个Report,而不是一个Chart对应多个Report,如果出现一个Chart对应多个Report,需要创建成一对一的关系才能实现。

salesforce零基础学习(八十三)analytics:reportChart实现Dashboard(仪表盘)功能效果的更多相关文章

  1. salesforce 零基础学习(六十八)http callout test class写法

    此篇可以参考: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restfu ...

  2. salesforce零基础学习(八十)使用autoComplete 输入内容自动联想结果以及去重实现

    项目中,我们有时候会需要实现自动联想功能,比如我们想输入用户或者联系人名称,去联想出系统中有的相关的用户和联系人,当点击以后获取相关的邮箱或者其他信息等等.这种情况下可以使用jquery ui中的au ...

  3. salesforce零基础学习(八十二)审批邮件获取最终审批人和审批意见

    项目中,审批操作无处不在.配置审批流时,我们有时候会用到queue,related user设置当前步骤的审批人,审批人可以一个或者多个.当审批人有多个时,邮件中获取当前记录的审批人和审批意见就不能随 ...

  4. salesforce零基础学习(八十七)Apex 中Picklist类型通过Control 字段值获取Dependent List 值

    注:本篇解决方案内容实现转自:http://mysalesforceescapade.blogspot.com/2015/03/getting-dependent-picklist-values-fr ...

  5. salesforce零基础学习(八十九)使用 input type=file 以及RemoteAction方式上传附件

    在classic环境中,salesforce提供了<apex:inputFile>标签用来实现附件的上传以及内容获取.salesforce 零基础学习(二十四)解析csv格式内容中有类似的 ...

  6. salesforce零基础学习(一百一十三)Trigger中获取IP地址的过程

    本篇参考: https://developer.salesforce.com/docs/atlas.en-us.228.0.apexcode.meta/apexcode/apex_class_Auth ...

  7. salesforce零基础学习(九十六)Platform Event浅谈

    本篇参考:https://developer.salesforce.com/blogs/2018/07/which-streaming-event-do-i-use.html https://trai ...

  8. salesforce零基础学习(一百零五)Change Data Capture

    本篇参考: https://developer.salesforce.com/docs/atlas.en-us.232.0.api_streaming.meta/api_streaming/using ...

  9. salesforce 零基础学习(五十二)Trigger使用篇(二)

    第十七篇的Trigger用法为通过Handler方式实现Trigger的封装,此种好处是一个Handler对应一个sObject,使本该在Trigger中写的代码分到Handler中,代码更加清晰. ...

随机推荐

  1. Nginx 1.10.1 版本nginx.conf优化配置及详细注释

    Nginx 1.10.1 的nginx.conf文件,是调优后的,可以拿来用,有一些设置无效,我备注上了,不知道是不是版本的问题,回头查一下再更正. #普通配置 #==性能配置 #运行用户 user ...

  2. ubuntu命令查询版本和内核版本

    1.查看ubuntu版本号: 方法一: cat  /etc/issue 返回结果: Ubuntu 6.06.2 LTS \n \l   方法二: sudo lsb_release -a  返回结果: ...

  3. JavaWeb之response响应中文乱码问题

    response向页面响应中文乱码问题  字节流 * 有可能乱码,与中文转换成字节数组.浏览器打开的默认字符编码有关 * 解决方式:将中文转成字节数组的时候和浏览器默认打开的时候采用的字符集一致 re ...

  4. Echarts数据可视化全解注释

    全栈工程师开发手册 (作者:栾鹏) Echarts数据可视化开发代码注释全解 Echarts数据可视化开发参数配置全解 6大公共组件详解(点击进入): title详解. tooltip详解.toolb ...

  5. iOS将自己的框架更新到cocopods上

    第一步 把自己的框架更新到github 上,为了提交地址给他人下载.这里就不详细介绍如何把项目更新到github上了 第二步 这个时候我们的项目已经挂在github上了我们需要给本地的项目新建一个Po ...

  6. memcached+狀態模式+工廠方法使用

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  7. Cosmos OpenSSD架构分析--FSC

    接口速度: type   bw  read 75μs 1s/75μs*8k/1s=104m/s write 1300μs   1s/1300μs*8k/1s=6m/s erase 3.8ms  1s/ ...

  8. ALV添加文字输入框

    一.业务场景 在合同打印中,需要临时添加其他约定事项,在打印程序的ALV中添加其他事项字段,点击之后弹出文字输入窗口,点击确定,文字内容存表,并在ALV中展示,点击打印后,文字内容加载到smartfo ...

  9. 461. Hamming Distance(leetcode)

    The Hamming distance between two integers is the number of positions at which the corresponding bits ...

  10. iOS 之 UITextField

    UITextField 相关细节处理: 1.  设置leftView , rightView let leftView = UIView() // 设置leftView/rightView之后,勿忘设 ...