我正在尝试使用变量“temp”的数据制作饼图。数据显示在控制台上的图片中。我应该如何开始这个请帮助我。
$(function () {
var temp = <?php echo $branch_emp; ?>;
console.log(temp);
$('#pie_chart').highcharts({
chart: {
type: 'pie',
options3d: {
enabled: true,
alpha: 45,
beta: 0
}
},
title: {
text: 'Incident Report'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
depth: 35,
dataLabels: {
enabled: true,
format: '{point.name}'
}
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: [
//this is where i want the data
// temp.foreach(function(){
['a', 50.0],
['b', 25.0],
['c', 25.0],
// })
]
}]
});
});
答案 0 :(得分:0)
您只想使用map
将属性branch_name
和totalemp
的对象数组转换为多维数组
series: [{
type: 'pie',
name: 'Browser share',
data: temp.map(function(e){
return [e.branch_name,e.totalemp];
})
}]