Update static/script.js
Browse files- static/script.js +16 -8
static/script.js
CHANGED
|
@@ -215,12 +215,18 @@ async function veBieuDoDoanhThuThang() {
|
|
| 215 |
|
| 216 |
|
| 217 |
async function veBieuDoDichVu() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
try {
|
| 219 |
-
const res = await fetch("/ty_le_dich_vu");
|
| 220 |
const data = await res.json();
|
| 221 |
|
| 222 |
-
const ctx = document.getElementById("chartDichVu").getContext("2d");
|
| 223 |
-
|
| 224 |
const chartData = {
|
| 225 |
labels: ["Kiểm định", "Hiệu chuẩn", "Đo thử nghiệm"],
|
| 226 |
datasets: [{
|
|
@@ -230,7 +236,9 @@ async function veBieuDoDichVu() {
|
|
| 230 |
data.Hieu_chuan || 0,
|
| 231 |
data.Do_thu_nghiem || 0
|
| 232 |
],
|
| 233 |
-
backgroundColor: [
|
|
|
|
|
|
|
| 234 |
hoverOffset: 10
|
| 235 |
}]
|
| 236 |
};
|
|
@@ -244,15 +252,15 @@ async function veBieuDoDichVu() {
|
|
| 244 |
legend: { position: 'bottom' },
|
| 245 |
tooltip: {
|
| 246 |
callbacks: {
|
| 247 |
-
label: context =>
|
| 248 |
-
`${context.label}: ${context.raw.toFixed(2)}%`
|
| 249 |
}
|
| 250 |
}
|
| 251 |
}
|
| 252 |
}
|
| 253 |
});
|
| 254 |
|
| 255 |
-
} catch (
|
| 256 |
-
console.error("Lỗi
|
| 257 |
}
|
| 258 |
}
|
|
|
|
|
|
| 215 |
|
| 216 |
|
| 217 |
async function veBieuDoDichVu() {
|
| 218 |
+
const canvas = document.getElementById("chartDichVu");
|
| 219 |
+
if (!canvas) {
|
| 220 |
+
console.error("Không tìm thấy canvas chartDichVu");
|
| 221 |
+
return;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
const ctx = canvas.getContext("2d");
|
| 225 |
+
|
| 226 |
try {
|
| 227 |
+
const res = await fetch("/ty_le_dich_vu");
|
| 228 |
const data = await res.json();
|
| 229 |
|
|
|
|
|
|
|
| 230 |
const chartData = {
|
| 231 |
labels: ["Kiểm định", "Hiệu chuẩn", "Đo thử nghiệm"],
|
| 232 |
datasets: [{
|
|
|
|
| 236 |
data.Hieu_chuan || 0,
|
| 237 |
data.Do_thu_nghiem || 0
|
| 238 |
],
|
| 239 |
+
backgroundColor: [
|
| 240 |
+
"#4CAF50", "#2196F3", "#FFC107"
|
| 241 |
+
],
|
| 242 |
hoverOffset: 10
|
| 243 |
}]
|
| 244 |
};
|
|
|
|
| 252 |
legend: { position: 'bottom' },
|
| 253 |
tooltip: {
|
| 254 |
callbacks: {
|
| 255 |
+
label: (context) => `${context.label}: ${context.raw.toFixed(2)}%`
|
|
|
|
| 256 |
}
|
| 257 |
}
|
| 258 |
}
|
| 259 |
}
|
| 260 |
});
|
| 261 |
|
| 262 |
+
} catch (error) {
|
| 263 |
+
console.error("Lỗi API /ty_le_dich_vu:", error);
|
| 264 |
}
|
| 265 |
}
|
| 266 |
+
|