需要帮助使用SharePoint列表和PSServices将其他系列添加到Highcharts图中
Need assistance adding an additional series to a Highcharts graph using a SharePoint list and PSServices
我有一个SharePoint列表,其中包含日期列、RedTeamScore列和BlueTeamScore栏(请参阅屏幕截图)
我的Highcharts图表目前由一个系列组成-RedTeamScore(见屏幕截图)
我想从BlueTeamScore列中添加一个额外的系列到我的图表中。
下面是我的代码片段
<script type="text/javascript" src="/sites/Test/highcharts/SiteAssets/jquery.min.js"></script>
<script type="text/javascript" src="/sites/Test/highcharts/SiteAssets/SPServices.min.js"></script>
<script type="text/javascript" src="/sites/Test/highcharts/SiteAssets/highcharts.js"></script>
<script type="text/javascript" src="/sites/Test/highcharts/SiteAssets/moment.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
var yearmontharray = [];
var valuesarray = [];
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Scores",
CAMLViewFields: "<ViewFields><FieldRef Name='Date' /><FieldRef Name='RedTeamScore' /></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var yearmonth = ($(this).attr("ows_Date"));
var values = Math.round($(this).attr("ows_RedTeamScore"));
var newyearmonth = moment(yearmonth).format("MMM-DD");
yearmontharray.push(newyearmonth);
valuesarray.push(values);
});
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line',
marginRight: 130,
marginBottom: 80
},
title: {
text: 'Team Scores',
x: -20
},
subtitle: {
text: 'Red and Blue Teams',
x: -20
},
xAxis: {
categories: yearmontharray,
labels: {
rotation: -90
}
},
yAxis: {
title: {
text: 'Score'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: 'RedTeam',
data: valuesarray
}]
});
}
});
});
</script>
<div id="container">
</div>
您可以将您的系列扩展到:
series: [{
name: 'RedTeam',
data: valuesarray
},{
name: 'BlueTeam',
data: valuesarray2
}]
并导入蓝色团队数据(3个新的和1个编辑行):
...
$(document).ready(function() {
var yearmontharray = [];
var valuesarray = [];
var valuesarray2 = []; //new line
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Scores",
CAMLViewFields: "<ViewFields><FieldRef Name='Date' /><FieldRef Name='RedTeamScore' /><FieldRef Name='BlueTeamScore' /></ViewFields>", //edited line
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var yearmonth = ($(this).attr("ows_Date"));
var values = Math.round($(this).attr("ows_RedTeamScore"));
var values2 = Math.round($(this).attr("ows_BlueTeamScore")); //new line
var newyearmonth = moment(yearmonth).format("MMM-DD");
yearmontharray.push(newyearmonth);
valuesarray.push(values);
valuesarray2.push(values2); //new line
});
...
相关文章:
- 如何添加浮动和非浮动,其他
- chart.series[id].remove()无法刷新高位图表/高位股票中其他系列的图例属性
- 高图表 - 是否可以为每个系列添加工具提示格式化程序
- highcharts-点击后将系列添加到图表中
- 下拉以在选择“其他”时添加输入
- 如何将外部 API 中的其他数据添加到集合中的现有模型
- 单击一个项目,从其他项目添加和删除类
- 将另一个系列添加到行高图表
- 为某些特定类别的新系列添加点
- 将新系列添加到类别高点
- HighCharts.正在将id为的系列添加到yAxis
- 需要帮助使用SharePoint列表和PSServices将其他系列添加到Highcharts图中
- 仅将特定系列添加到Shield UI图表图例中
- 在beforeCreate上的安全问题,即使我删除了这些参数,sails也会向其他模型添加关系
- 如何向一些jQuery对象添加函数,而不是向其他对象添加函数
- 高图:向倒排柱范围图系列添加符号
- 为不同的系列添加不同格式的工具提示
- 为等效的其他ID添加类
- 将其他类添加到 Pinterest 固定按钮 iframe
- 3D Highchart动态系列添加问题