我是HighCharts的新手。我正在制作一个饼图,数据(JSON)来自多个php文件。所以我使用了嵌套的ajax调用。但我仍然坚持如何将其整合到图表数据中。
$.getJSON("php/footprint1.php", function(data1) {
$.getJSON("php/footprint2.php", function(data2) {
$.getJSON("php/footprint3.php", function(data3) {
$.getJSON("php/footprint4.php", function(data4) {
$.getJSON("php/footprint5.php", function(data5) {
$.getJSON("php/footprint6.php", function(data6) {
chart.series[0].data[0][1] = data1.reponse.numFound;
});
});
});
});
});
});
图表是这样的。
chart = new Highcharts.Chart({
chart: {
renderTo: 'place2',
type: 'pie'
},
title: { align: 'center', text: 'Foot-Prints Detected' },
plotOptions: {
pie: {
shadow: false,
center: ['50%', '50%']
}
},
legend: {
enabled: true,
layout: 'vertical',
align: 'right',
width: 250,
verticalAlign: 'middle',
useHTML: true,
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.y +' %';
}
},
series: [{
name: 'Browsers',
data: [["BLOG",4],["PAID",4],["DIRECTORY",9],["WORDPRESS",7],["ADULT",7],["PHARMACEUTICALS",8]],
size: '100%',
innerSize: '75%',
showInLegend:true,
dataLabels: {
enabled: true,
formatter: function() {
return Math.round(this.percentage*100)/100 + ' %';
},
distance: -25,
color:'black'
}
}],