サーブレットからデータを取得しており、サーブレットから送信している json オブジェクトの sysout は {"jsonArray":[{"bugzilla":20,"redmind":14}]} です
今私のJavaスクリプトは
<script type="text/javascript">
var chart;
$(document).ready(
function() {
chart = new Highcharts.Chart({
chart : {
renderTo : 'container',
},
title : {
text : 'Bug chart'
},
tooltip : {
formatter : function() {
var s;
if (this.point.name) { // the pie chart
s = '' + this.point.name + ': ' + this.y
+ ' Bugs';
} else {
s = '' + this.x + ': ' + this.y;
}
return s;
}
},
labels : {
items : [ {
html : 'Total Bugs',
style : {
left : '40px',
top : '8px',
color : 'black'
}
} ]
},
series : [ {
type : 'pie',
name : 'Total Bugs',
data : [],
center : [ 100, 80 ],
size : 100,
showInLegend : false,
dataLabels : {
enabled : false
},
}, ]
}, function getdata(chart) {
var tmp="";
var receivedData="";
$.ajax({
url : 'http://localhost:8080/PRM/GraphServlet',
dataType : 'json',
error : function() {
alert("error occured!!!");
},
success : function(data) {
$.each(data.jsonArray, function(index)
{
$.each(data.jsonArray[index],
function(key,value) {
tmp = "['" + key + "', " + value + "],";
receivedData += tmp;
alert("receivedData: " + receivedData);
});
});
alert(receivedData.substring(0, 34));
chart.series[0].setData([receivedData.toString().substring(0, 34)]);
}
}
);
});
});
</script>
alert は receivedData: ['bugzilla', 20],['redmind', 14] を出力することを期待していますが、問題は私がそれを
chart.series[0].setData([ receivedData .toString().substring(0, 34)]);
その後、円グラフが機能しません。ツールチップなしで 1/4 円のように 1 つの部分のみを表示します