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中进行选 ...
随机推荐
- excel单元格内换行
强制换行:将光标置于拟换行处,按ALT+Enter键,即可强行换行.
- XPath使用实例
实例 1基本的XPath语法类似于在一个文件系统中定位文件,如果路径以斜线 / 开始, 那么该路径就表示到一个元素的绝对路径 //BBB 选择所有BBB元素 /AAA/CCC 选择 ...
- 23.mysql集群(master-master)
参考: http://blog.csdn.net/mr__fang/article/details/8692480 http://www.2cto.com/database/201201/116756 ...
- Javascript中的队列
队列遵循FIFO (First In First Out)原则. 普通队列 function Queue() { var items=[]; //向队列尾部添加一个或者多个元素 this.enqueu ...
- jQuery 查找父元素
function deletesec1Div5(obj){ $(obj).closest(".sec1-div5").remove();}自己写的一段代码,实现了table中的全选 ...
- Linux下LVM
http://www.cnblogs.com/xiaoluo501395377/archive/2013/05/22/3093405.html
- static修饰的静态内部类
Java里面static一般用来修饰成员变量或函数.但有一种特殊用法是用static修饰内部类,普通类是不允许声明为静态的,只有内部类才可以.被static修饰的内部类可以直接作为一个普通类来使用,而 ...
- aspx页面常用代码
Response.Redirect(Request.Url.ToString());//刷新页面 Response.Write("<script>alert('有数据尚未添加') ...
- ROS学习笔记(二)——ubantu 14.04 安装
0.采用双系统安装(U盘安装) 1.安装文件在ubantu官网下载: ubantu官网 :https://www.ubuntu.com/ ubuntu的server版和desktop版有什么区? (来 ...
- RANSAC 剔除错误匹配 估计模型
随机抽样一致,这个算法,我以前一直都没有理解透彻.只知道可以用来直线拟合,网上大多数中文博客也都是写直线拟合的,但是用来匹配二维特征的时候,总还是没弄明白. 基本概念参考 http://www.cnb ...