【发布时间】:2014-03-31 15:09:48
【问题描述】:
我正在使用 highcharts 插件在 codeigniter 站点中打印统计信息。
现在我从我的数据库中获取数据并对其进行管理,但是当我在 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_encode,使用json_decode,什么都没有。有人能帮我吗?谢谢
【问题讨论】:
-
我的问题很清楚,我认为“没有打印任何内容”highchart 空无行@AamirAfridi
-
去掉""
-
如果我删除它相同的东西,空图表但结果出现在我的变量@Dieter
-
尝试打印 $data_chart[0] 似乎您的数组中有一个数组,因为您的数组周围有双 [[ ]] 的数组
-
它打印“[”,你说得对,如何解决? @迪特
标签: php jquery mysql codeigniter highcharts