|
 |
|
ปกติแล้วทำหน้า Report Dashboard สรุปข้อมูล Query ยังไงไม่ให้ช้าครับ |
|
 |
|
|
 |
 |
|
พอดีผมกำหน้า Dashboard มีกราฟ มีข้อมูล Count จำนวน ต่างๆ
มีการ Loop เพื่อ Count จำนวนในแต่ละประเภท
Code (PHP)
$chart_budget = collect([]);
$chart_budget_year = collect([]);
$year=date('Y')+543;
$year10 =$year-10;
//dd($year10);
for ($i= 1; $i <= 6; $i++) {
$chart_budget->push(Car::where('car_budgets_id',$i)->count());
$chart_budget_year->push(Car::where('car_budgets_id',$i)
->where('car_year','<=',$year10)->count());
}
$chartBudget = new SampleChart;
$chartBudget->labels(['เงินประเภท 1', 'เงินประเภท 2', 'เงินประเภท 3', 'เงินประเภท 4','เงินประเภท 5','เงินอื่นๆ ']);
$chartBudget->dataset('ข้อมูลทั้งหมด', 'bar', $chart_budget)
->backgroundColor('#81B71A');
$chartBudget->dataset('ข้อมูล 10 ปีย้อนหลัง', 'bar', $chart_budget_year)
->backgroundColor('#36a2eb');
ข้อมูลประมาณ 5 หมื่น Record กว่าจะปมวลผลเสร็จช้ามากเลยครับ
จึงอยากจะมาแลกเปลี่ยนว่า ถ้าทำ Dashboard ใช้วิธีไหนกัน
ที่มันจะ Count ไว้แล้ว เราดึงตัวเลขมาเลย หรือใช้วิธีการไหนครับ
ขอบคุณครับ
Tag : PHP, HTML5, Laravel Framework

|
|
 |
 |
 |
 |
Date :
2018-12-17 10:04:18 |
By :
the_cop |
View :
1587 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าไม่ realtime ควรมี service count ลง table ไว้ล่วงหน้าครับ
|
 |
 |
 |
 |
Date :
2018-12-17 11:42:23 |
By :
mongkon.k |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองดูพวก Web Socket ครับ
|
 |
 |
 |
 |
Date :
2018-12-20 17:27:06 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|