Update static/script.js
Browse files- static/script.js +8 -5
static/script.js
CHANGED
|
@@ -78,7 +78,7 @@ async function hienThiDoanhThuPYC() {
|
|
| 78 |
}
|
| 79 |
async function veBieuDoDoanhThuThang() {
|
| 80 |
try {
|
| 81 |
-
const response = await fetch("https://doluong6-qlht.hf.space/doanh_thu_theo_thang");
|
| 82 |
const data = await response.json();
|
| 83 |
|
| 84 |
if (data.error) {
|
|
@@ -86,9 +86,13 @@ async function veBieuDoDoanhThuThang() {
|
|
| 86 |
return;
|
| 87 |
}
|
| 88 |
|
| 89 |
-
const
|
|
|
|
| 90 |
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
| 92 |
type: "bar",
|
| 93 |
data: {
|
| 94 |
labels: data.labels,
|
|
@@ -126,9 +130,8 @@ async function veBieuDoDoanhThuThang() {
|
|
| 126 |
}
|
| 127 |
}
|
| 128 |
});
|
| 129 |
-
|
| 130 |
} catch (error) {
|
| 131 |
-
console.error("Lỗi khi
|
| 132 |
}
|
| 133 |
}
|
| 134 |
|
|
|
|
| 78 |
}
|
| 79 |
async function veBieuDoDoanhThuThang() {
|
| 80 |
try {
|
| 81 |
+
const response = await fetch("https://doluong6-qlht.hf.space/doanh_thu_theo_thang");
|
| 82 |
const data = await response.json();
|
| 83 |
|
| 84 |
if (data.error) {
|
|
|
|
| 86 |
return;
|
| 87 |
}
|
| 88 |
|
| 89 |
+
const canvas = document.getElementById("doanhThuThangChart");
|
| 90 |
+
if (!canvas) return;
|
| 91 |
|
| 92 |
+
const ctx = canvas.getContext("2d");
|
| 93 |
+
if (window.doanhThuChart) window.doanhThuChart.destroy();
|
| 94 |
+
|
| 95 |
+
window.doanhThuChart = new Chart(ctx, {
|
| 96 |
type: "bar",
|
| 97 |
data: {
|
| 98 |
labels: data.labels,
|
|
|
|
| 130 |
}
|
| 131 |
}
|
| 132 |
});
|
|
|
|
| 133 |
} catch (error) {
|
| 134 |
+
console.error("Lỗi khi vẽ biểu đồ:", error);
|
| 135 |
}
|
| 136 |
}
|
| 137 |
|