好吧,开始我曾经创建我的JSON函数,但是当我想要添加数据时我不能。那么我的json功能怎么样呢?我正在使用getJSON,但我无法添加像ajax这样的数据,那么我怎样才能将其更改为ajax样式。这是hightchart
$(function() {
var processed_json = new Array();
$.getJSON('../controllers/chart_controller.php', function(data){
for (i = 0; i < data.length; i++){
processed_json.push([data[i].key,data[i].value]);
}
//draw chart
$('#salesChart').highcharts({
chart: {
type: "column"
},
title: {
text: "Best selling product"
},
xAxis: {
type: 'category',
allowDecimals: false,
title: {
text: ""
}
},
yAxis: {
title: {
text: "Scores"
}
},
series: [{
name: 'Sales',
data: processed_json
}]
});
});
});