Mục tiêu ngày 13 🎯

Sau hôm nay bạn sẽ:

✔ Hiển thị tổng số nhân sự (KPI)

✔ Thống kê theo phòng ban

✔ Vẽ biểu đồ (chart)

✔ Dashboard giống phần mềm thật


1. Dashboard là gì?

Dashboard là màn hình:

📊 Tổng quan hệ thống

Ví dụ:

Tổng nhân sự: 120
Phòng ban: 5
IT: 30 người
Kế toán: 20 người

2. Lấy dữ liệu thống kê từ Apps Script

Hàm thống kê

functiongetStats(){

constsheet=SpreadsheetApp
.getActive()
.getSheetByName("HR")

constdata=sheet.getDataRange().getValues()

data.shift()

lettotal=data.length

letdeptCount= {}

data.forEach(row=>{

constdept=row[2]

if(!deptCount[dept]){
deptCount[dept]=0
}

deptCount[dept]++

})

return {
total:total,
dept:deptCount
}

}

3. Gọi dữ liệu từ HTML

<script>

functionloadStats(){

google.script.run
.withSuccessHandler(showStats)
.getStats()

}

</script>