尝试使用SharePoint列表和Highcharts在图表上放置点
Trying to put points on a chart using a SharePoint list and Highcharts
此屏幕截图-https://i.stack.imgur.com/mmYHi.jpg-显示以下项目
a) 我目前得到的(没有数据点)
b) 我希望我的结果看起来像
c) 我的SharePoint列表看起来像
(对不起,我没有足够的堆叠溢出点来发布图片)
以下是我目前拥有的代码
$(document).ready(function() {
var yearmontharray = [];
var valuesarray = [];
$().SPServices({
operation: "GetListItems",
async: false,
listName: "List",
CAMLViewFields: "<viewfields><fieldref Name='Title' /><fieldref Name='values' /></ViewFields>",
CAMLQuery: "<query><orderby><fieldref Name='Title' Ascending='True' /></OrderBy></Query>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var yearmonth = ($(this).attr("ows_Title"));
var values = Math.round($(this).attr("ows_values"));
yearmontharray.push(yearmonth);
valuesarray.push(values);
});
}
});
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Total values',
x: -20
},
subtitle: {
text: 'This chart shows value from SharePoint',
x: -20
},
xAxis: {
categories: yearmontharray
},
yAxis: {
title: {
text: 'values'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: 'values',
data: valuesarray
}]
});
});
如有任何帮助,我们将不胜感激!
您必须在完整的函数中包含图表的收缩。否则,在获取数据之前调用Hightchart。
$(document).ready(function () {
var yearmontharray = [];
var valuesarray = [];
$().SPServices({
operation: "GetListItems",
async: false,
listName: "List",
CAMLViewFields: "<viewfields><fieldref Name='Title' /><fieldref Name='values' /></ViewFields>",
CAMLQuery: "<query><orderby><fieldref Name='Title' Ascending='True' /></OrderBy></Query>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var yearmonth = ($(this).attr("ows_Title"));
var values = Math.round($(this).attr("ows_values"));
yearmontharray.push(yearmonth);
valuesarray.push(values);
});
// Inside complete func <-----
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Total values',
x: -20
},
subtitle: {
text: 'This chart shows value from SharePoint',
x: -20
},
xAxis: {
categories: yearmontharray
},
yAxis: {
title: {
text: 'values'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: 'values',
data: valuesarray
}]
});
}
});
});
相关文章:
- 在Web应用程序中使用Highcharts javascript
- 在Highcharts中,我们可以通过任何方式在渲染图表之前获得plotWidth和plotHeight
- HighCharts长标题文本在某些元素上重叠
- Highcharts colorsByPoint与系列中的线性渐变一起使用时不起作用
- Highcharts-如何在自定义格式化程序中获得默认的y轴标签格式化程序
- Highcharts仪表未显示
- Highcharts-图表外的图例定位
- Highcharts动态烛台
- 在highcharts.js中向点弹出窗口动态添加文本
- Highcharts 3d调整zindex错误
- 如何在一页上显示多个Highcharts图表
- Highcharts可以从服务器加载数据,但不能更新
- 如何使用webview在React Native中使用Highcharts
- Highcharts热图上的多个轴
- Highcharts-显示noData覆盖和x轴标签
- HighCharts:3D柱形图在选择时更改边框颜色
- 如何使用队列呈现多个HighCharts以防止加载时间过长
- Highcharts动态更改标签
- 柱状图上的Highcharts工具提示
- Highcharts热图显示不正确