我正在使用highcharts插件在codeigniter站點中打印統計信息。Highcharts來自mysql數據庫的數據
現在我從我的數據庫中獲取數據我管理它,但是當我在highcharts中打印它時,沒有打印任何內容。
這是我的PHP代碼:
$arr_point = array();
$check_price = array();
for($i = 1; $i <= 12; $i++){
$sum = 0;
$this->load->model('backend/Notification_model');
$this->db->select('*,');
$this->db->from('booking');
$query = $this->db->get();
foreach ($query->result() as $row){
$sum+=(float)$row->total_with_markup;
}
$arr_point[] = str_replace(',', '.', $sum);
}
$result = array();
array_push($result,$arr_point);
return(json_encode($result));
,這是我highchart配置:
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: $('#riepilogo option:selected').text()
},
subtitle: {
text: ''
},
xAxis: {
categories: [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
]
},
yAxis: {
min: 0,
title: {
text: 'Euro'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.2f} euro</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [ {
name: $('#riepilogo options:selected').text(),
data: "<?php echo json_decode($data_chart); ?>"
}]
});
});
,如果我打印json_decode($data_chart)
我得到這個:
Array
如果我打印($data_chart
我得到這個:
[["0","297.23","74.41","65.57","2167.32","7649.77","2058.05","146.95","92.55","0","1754.72","0"]]
我儘量不要用json_encod
e,要用json_decode
,沒什麼。有人能幫我嗎?由於
我的問題很清楚我認爲「什麼都不打印」高空清空沒有行@AamirAfridi – WebDesigner
刪除「?」<?php echo json_decode($ data_chart); ?>「 – Naruto
如果我刪除它同樣的東西,空圖表,但結果存在於我的變量@Dieter – WebDesigner