在我的代码下面:
$(document).ready(function() {
for(var j = 0; j < productsSize; j++) {
//tmStringToDisplay.push(name[j], parseInt(percent[j]));
var tmStringToDisplay = [name[j], parseInt(percent[j])];
tmStringToDisplay.push(temp);
}
console.log(tmStringToDisplay);
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'The best selling products :'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage}%</b>',
percentageDecimals: 1
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Product share',
data: tmStringToDisplay
}]
});
我必须制作“tmStringToDisplay”选项卡,将其放入系列数组的数据变量中。在静态中,它是这样的:
series: [{
type: 'pie',
name: 'Browser share',
data: [
['Firefox', 45.0],
['IE', 26.8],
{
name: 'Chrome',
y: 12.8,
sliced: true,
selected: true
},
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
}]
这是在循环中,一切都在工作:
for(var j = 0; j < productsSize; j++) {
//tmStringToDisplay.push(name[j], parseInt(percent[j]));
var tmStringToDisplay = [name[j], parseInt(percent[j])];
tmStringToDisplay.push(temp);
}
我必须创建和准备需要像静态示例一样的“tmStringToDisplay”......
谢谢 !