这是我的 sql 查询
SELECT WEEKDAY(C.created_date) as date_label, COUNT(C.consignment_id) as deliveries, C.service_id, CS.display_name
FROM (`consignments` as C)
LEFT JOIN `courier_service` as CS ON `CS`.`id`=`C`.`service_id`
WHERE `C`.`org_id` = 165
AND (created_date >= '2017-06-25' AND created_date <= '2017-12-13')
AND `C`.`is_deleted` = 0
AND `C`.`is_service_assigned` = 1
GROUP BY `date_label`, `C`.`service_id`
我正在使用 echarts 创建折线图。我应该怎么做才能匹配我的 php 控制器中的数据,以便星期一的 [0] 有 3 次交付?
我的php代码
$label = array();
$weektrendlist = array();
foreach($services as $service) {
$listname = array("0" => 0, "1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0, "6" => 0);
$weektrendinfobyservice = $this->overall_reports_model-> overall_performance_week_trend_per_service($service->service_id, $start_date, $end_date, $org_id);
foreach($weektrendinfobyservice as $row) {
$listname[$row->date_label] = $row->deliveries;
}
$dataset = array();
$dataset['name'] = $service->display_name;
$hash = md5($service->service_id.$service->service_name);
$dataset['data'] = array_values($listname);
$weektrendlist[] = $dataset;
}
$result['weektrend'] = array(
"label" => array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"),
"datasets" => $weektrendlist
);