【发布时间】:2016-07-13 04:27:33
【问题描述】:
您好,我正在尝试创建图表。图表value 来自ajax return。
我得到了这个数据
"tgl":["2016-07-12 00:00:00.000","2016-07-01 00:00:00.000"],"total":[1283947,1234618514]}
这是我处理hightchart的js
xAxis: {
categories: [
$.each(data.tgl, function(k, v) {
data.tgl
})
]
},
series: [{
name: 'Outlet' +$("#outlet").val(),
data: [
$.each(data.total, function(k, v) {
data.total
})
]
}]
我不知道怎么foreach ajax 所以我点击这个链接jQuery loop over JSON result from AJAX Success?
这是我的 php
function getajax()
{
extract(populateform());
$explode = explode('-',$date_search);
$start_date = inggris_date($explode[0]);
$end_date = inggris_date($explode[1]);
$hasil = $this->modelmodel->showdata("select tanggal,(cash + cc + dc + flash + piutang + reject + disc50)
total from transaksi
where tanggal between '$start_date' and '$end_date' and
outlet = '".$outlets."' order by tanggal desc");
$data = array();
foreach($hasil as $hsl)
{
$data['tgl'][] = $hsl->tanggal;
$data['total'][] = $hsl->total;
}
echo json_encode($data);
}
我上面的脚本的结果是这样的。
从我上面的数据可以看出。我的图表没有显示正确的值。应该是这样的2016-07-12 00:00:00.000 => 1283947 and 2016-07-01 00:00:00.000 => 1234618514
【问题讨论】:
标签: php jquery json ajax highcharts