谷歌 chart 问题官方文件 https://google-developers.app...
$.getJSON('XXX&m=' + m, function(json) {
var data = new google.visualization.DataTable(json);
data.addColumn('string', '');
data.addColumn('number', '');
data.addRows(json);
console.log(json);
php
$chartData = $pdo->query(
"SELECT DISTINCT
FROM_UNIXTIME(add_time, '%m/%d') as add_time,
count(view_id) as viewTime
FROM `view`
GROUP BY `add_time` "
);
foreach ($chartData as $key) {
if (substr($key['add_time'] ,0 ,2) == $_GET['m']) {
$data[] = array(
$key['add_time'], (int) $key['viewTime']
);
}
}
echo json_encode($data ,JSON_UNESCAPED_SLASHES);
我每一笔 view 都有一个 add_time 时间戳我上面是把时间戳转换为 mm/dd 格式,然后再透过 $_GET['m'] 带来的日期,例如 05
output [["11/01",1],["11/02",1],["11/03",1],["11/05",1]]
但其实 11/01 ,11/02, 11/03, 11/05 都是多笔的
透过 count(view_id) as viewTime 算出来都是一笔~
所以我想不到怎么算出每个日期共有几笔?
添加回答
举报
0/150
提交
取消