SharePoint中报表选择
Office 365中制作报表的方式很多。
这里介绍下使用js获取SharePoint List实现报表的一种方法
资源
- Jquery 1.8.2 http://blog.jquery.com/2012/09/20/jquery-1-8-2-released/
- SPServices http://spservices.codeplex.com/
- Highcharts http://www.highcharts.com/
- underscore.js http://underscorejs.org/
先看效果, 要实现一个饼图

看代码
详细代码解释见原文(原文中的代码有点小问题,修复后的代码如下) http://www.sharepointdeveloperhq.com/2013/05/utilizing-spservices-for-sharepoint-2010-to-create-charts-with-high-charts/
<script src="/sites/target3/Theme/jquery.min.js" type="text/javascript"></script>
<script src="/sites/target3/Theme/highcharts.js" type="text/javascript"></script>
<script src="/sites/target3/Theme/jquery.SPServices-2013.01.js" type="text/javascript"></script>
<script src="/sites/target3/Theme/underscore.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$().SPServices({
operation: "GetListItems",
CAMLQuery: "<Query><OrderBy><FieldRef Name='Location'/></OrderBy></Query>",
CAMLViewFields: "<ViewFields><FieldRef Name='Title'/><FieldRef Name='Date_x0020_of_x0020_Sighting'/><FieldRef Name='Action'/><FieldRef Name='Location'/></ViewFields>",
listName: "owl seen",
completefunc: processData
});
});
function processData (xData, status) {
var owlData = [];
$(xData.responseXML).SPFilterNode("z:row").each(function () {
owlData.push({
owl: $(this).attr('ows_Title'),
date: $(this).attr('ows_Date_x0020_of_x0020_Sighting'),
action: $(this).attr('ows_Action'),
location: $(this).attr('ows_Location')
});
}); var chartData = [];
var locationData = _.groupBy(owlData, 'location'); $.each(locationData, function(row) {
var locCount = row.length; chartData.push( {
name: row[0].location,
y: locCount
});
}); renderChart (chartData);
}
function renderChart (data) {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'owlchart',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
credits: {
enabled: true
},
title: {
text: 'Owl Sightings by Location'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage}%</b> {point.y} Times',
percentageDecimals: 1
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.y +' Times';
}
},
}
},
series: [{
type: 'pie',
name: 'Location Count',
data: data
}]
});
}
</script>
<div id="owlchart"></div>
Thanks,
Ivan
SharePoint中报表选择的更多相关文章
- 在SharePoint中创建可自定义属性的文件夹
概况 阅读时间:约5分钟 适用版本:SharePoint Server 2010及以上 面向用户:普通用户.管理员.开发人员 难度指数:★★★☆☆ SharePoint中的文件夹分为2种,一种是文档库 ...
- 如何:在 SharePoint 中创建外部列表
在创建外部内容类型后创建外部列表是一项非常简单的任务,有如下4种方式进行: 可使用 Microsoft SharePoint Designer 2010 浏览器来完成 VS2010的列表实例 采用代码 ...
- 自定义SharePoint 2013 元数据选择控件
元数据在Sharepoint中是一个很常用的功能,他提供一个方法来管理企业中常用的关键词,可以更加统一的使用和更新.默认情况下,绑定在列表或库中的元数据字段可以设置是否允许为多个值.但是无法控制在弹出 ...
- No-Touch Integration 在SharePoint中使用社区支持的Silverlight应用程序
No-Touch Integration 在SharePoint中使用社区支持的Silverlight应用程序 No-Touch Integration应该是最简单的方法了.将Silv ...
- 彻底抛弃PeopleEditor,SharePoint中利用Jquery Chosen创建新的人员选择器
彻底抛弃PeopleEditor,SharePoint中利用Jquery Chosen创建新的人员选择器 基于SharePoint平台开发时,人员选择器使用频率是非常高的,但是原生的人员选择器使用太麻 ...
- “认证发布”和“获取展示”,如何在 SharePoint 中正确使用 RSS Feed。
在我们进行的日常工作中,是由一部分信息需要 Share 给其他人或者组织的.SharePoint 虽然支持在某个 Site Collection 中互通信息,但是跨 Site Collection 的 ...
- SharePoint中使用Visio Service展示业务数据
SharePoint中可以通过Visio Service可以在浏览器中查看Visio图,功能部署到系统中,一切安好. 而现实总是很折磨人,使用该功能后,相关使用者随后提出,Visio图能否与我的业务数 ...
- Visual Studio工具栏中无法选择调试设备
Visual Studio工具栏中无法选择调试设备 在Visual Studio工具栏中,默认显示已经识别的设备.用户可以从中选择对应的设备,进行调试和部署App.但是由于误操作,可能导致该选项丢失. ...
- VIM 中鼠标选择不选中行号
VIM 中鼠标选择不选中行号 在Vim中,我们一般会使用 :set nu 打开行号开关. 但是打开行号后,有个弊端,那就是在用鼠标进行选择的时候,会将前面的行号也一起进行拷贝了.但是在gVim中进行选 ...
随机推荐
- msys2安装
最近在研究编译linux下的软件到windows环境中. 发现了一个比cygwin更好玩的东西,那就是msys2 其实之前也在试玩mingw和mingw64,2016-08-12,当时的最新版本,mi ...
- 【leetcode❤python】 165. Compare Version Numbers
#-*- coding: UTF-8 -*-class Solution(object): def compareVersion(self, version1, version2): ...
- node.js + expres 的安装
一 windows下安装 首先去官网下载msi安装包. 两篇很有参考价值的文章: http://cnodejs.org/topic/4fae80c02e8fb5bc650a8360 http://bl ...
- docker tomcat7 dubbo-admin monitor
docker run --name=dubbo_admin9201 -tid -p : -v /home/dubbo/admin:/usr/local/tomcat7/webapps/ROOT cen ...
- 1005. Spell It Right (20)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...
- django部署
部署教程 阿里云django部署教程 注意备份Apache2的siteconf文件 细节 环境迁移 如果是修改了注意些requirement文件
- Java准确地获取本地IP地址
问题 用Java获取本机IP地址,需要处理: 1. 多块网卡. 2. 排除loopback设备.虚拟网卡 看似简单的代码,写起来还是要小心一些的. 方案 HBase客户端获取本机IP的代码提供了一个很 ...
- linux下添加环境变量
我安装完 RedHat Linux 5 之后,在终端使用一些命令,如: ifcinfig 查看本机的IP,发现不能使用此命令,提示说“command not found”,这该怎么办呢 想想肯定是环境 ...
- zend studio 10破解/汉化
http://blog.csdn.net/qq1355541448/article/details/16807429
- 解决redhat 没注册的情况下yum无法使用的问题
官网下载的rhel,安装后是没有配置yum源的,需要自己配置yum源.网络上的很难找到rhel的yum源,但是在ISO镜像里面有很多redhat提供的软件包,也是正版软件,我们可以把这个拷贝出来 ...