これは私の最初のHighChartsプロジェクトであり、SPservicesを使用してフェッチしているデータを表示する際に問題が発生しています。このチュートリアル ( SharePoint から Highcharts へ) を見つけて、とても役に立ちましたが、グラフと凡例の列の名前を表示する際に問題があり、「スライス」しか表示されません。これは私の JavaScript です。
$(document).ready(function() {
var namesArray = [];
var valuesArray = [];
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Test",
CAMLQuery: "<Query><OrderBy><FieldRef Name='Person'/></OrderBy></Query>",
CAMLViewFields: "<ViewFields><FieldRef Name='Person' /><FieldRef Name='Age' /><FieldRef Name='Earnings' /><FieldRef Name='Names' /></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var names = $(this).attr("ows_Names");
var values = Math.round($(this).attr("ows_Earnings"));
namesArray.push(names);
valuesArray.push(values);
}); } });
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Total values',
x: -20, //center
},
plotOptions:{ pie: {
allowPointSelect: true,
showInLegend: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: $'+ this.y;} }, }},
subtitle: {
text: 'This chart shows value from a SharePoint list using SPServices',
x: -20
},
tooltip:{shared: true,pointFormat: '{series.name}: <b>{point.values}$</b>{point.y}',valueDecimals: 2,shared: true,
useHTML: true,},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -300,
y: 100,
borderWidth: 0
},
series: [{
showInLegend:true,
type: 'pie',
name: 'Earnings',
data: valuesArray
}]
});});
これは私がブラウザに表示するものです:
ご提案いただきありがとうございます。