Spaces:
Running
Running
Download stats.html from Ecolens-app/web: direct link, hf CLI and curl.
- Browser
- Download file 6.26 kB
-
https://huggingface.co/spaces/Ecolens-app/web/resolve/main/stats.html
- Command line
-
hf download hf://spaces/Ecolens-app/web/stats.html
-
curl -L -o stats.html https://huggingface.co/spaces/Ecolens-app/web/resolve/main/stats.html
6.26 kB
| <html lang="vi"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> | |
| <meta name="theme-color" content="#0e9f6e"> | |
| <title>EcoLens — Thống kê quét rác</title> | |
| <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📊</text></svg>"> | |
| <link rel="stylesheet" href="style.css"> | |
| <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.9/dist/chart.umd.min.js"></script> | |
| <script src="data.js"></script> | |
| </head> | |
| <body> | |
| <header class="topbar"> | |
| <div class="brand"> | |
| <span class="brand-logo">📊</span> | |
| <div> | |
| <div class="brand-name">Thống kê EcoLens</div> | |
| <div class="brand-sub">Dữ liệu quét rác trên máy này</div> | |
| </div> | |
| </div> | |
| <a class="stats-link" href="index.html" title="Về trang chụp">📷</a> | |
| </header> | |
| <main id="app"> | |
| <section class="screen"> | |
| <div class="ai-status">ℹ️ Thống kê này tính riêng cho máy bạn đang dùng (dữ liệu lưu ngay trên máy, không gửi đi đâu).</div> | |
| <div class="stats-grid"> | |
| <div class="card stat-tile"><div class="stat-num" id="tile-total">–</div><div class="stat-cap">Tổng lượt quét</div></div> | |
| <div class="card stat-tile"><div class="stat-num" id="tile-none">–</div><div class="stat-cap">Lượt chưa nhận ra</div></div> | |
| </div> | |
| <div class="card chart-card"> | |
| <h2>🗑️ Loại rác được quét nhiều nhất</h2> | |
| <div class="bins-mini-legend" id="bin-legend"></div> | |
| <div class="chart-box"><canvas id="chart-class" height="300"></canvas></div> | |
| <details class="table-view"><summary>Xem dạng bảng</summary><table id="table-class"></table></details> | |
| </div> | |
| <div class="card chart-card"> | |
| <h2>📅 Lượt quét theo ngày</h2> | |
| <div class="chart-box"><canvas id="chart-day" height="220"></canvas></div> | |
| </div> | |
| <div class="card empty-card" id="no-data" hidden> | |
| <div class="hero-emoji">🌱</div> | |
| <h2>Chưa có dữ liệu</h2> | |
| <p>Hãy quét vài món rác ở trang chính, thống kê sẽ hiện ở đây!</p> | |
| <a class="btn-capture" href="index.html" style="text-decoration:none">📸 Bắt đầu quét</a> | |
| </div> | |
| <div class="card" style="text-align:center"> | |
| <button id="btn-reset" class="btn-gallery" style="border:none;background:none">🗑️ Xóa thống kê trên máy này</button> | |
| </div> | |
| </section> | |
| </main> | |
| <footer class="footer">EcoLens 🌱 Dự án AI bảo vệ môi trường học đường</footer> | |
| <style> | |
| .chart-card h2 { font-size:16px; margin-bottom:10px; } | |
| .chart-box { position:relative; width:100%; } | |
| .stats-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:14px; } | |
| .stat-tile { text-align:center; padding:18px 10px; } | |
| .stat-num { font-size:32px; font-weight:800; color:var(--green-dark); } | |
| .stat-cap { font-size:13px; color:var(--ink-soft); font-weight:600; } | |
| </style> | |
| <script> | |
| const INK = "#14332a", INK_SOFT = "#4b6b5e", GRID = "rgba(20,51,42,.08)", GREEN = "#0e9f6e"; | |
| Chart.defaults.font.family = getComputedStyle(document.body).fontFamily; | |
| Chart.defaults.color = INK_SOFT; | |
| const INFO = {}; EL_CLASSES.forEach((c) => (INFO[c.class_name] = c)); | |
| const s = JSON.parse(localStorage.getItem("ecolens_stats") || '{"total":0,"none":0,"byClass":{},"byDay":{}}'); | |
| document.getElementById("tile-total").textContent = s.total; | |
| document.getElementById("tile-none").textContent = s.none; | |
| document.getElementById("btn-reset").addEventListener("click", () => { | |
| if (confirm("Xóa toàn bộ thống kê trên máy này?")) { localStorage.removeItem("ecolens_stats"); location.reload(); } | |
| }); | |
| const classRows = Object.entries(s.byClass) | |
| .map(([c, n]) => ({ c, n, info: INFO[c] })).filter((r) => r.info) | |
| .sort((a, b) => b.n - a.n); | |
| if (!classRows.length) { | |
| document.getElementById("no-data").hidden = false; | |
| } else { | |
| const bins = [...new Map(classRows.map((r) => [EL_BINS[r.info.bin].label, EL_BINS[r.info.bin].color]))]; | |
| document.getElementById("bin-legend").innerHTML = | |
| bins.map(([b, col]) => `<span><i style="background:${col}"></i>${b}</span>`).join(""); | |
| new Chart(document.getElementById("chart-class"), { | |
| type: "bar", | |
| data: { labels: classRows.map((r) => r.info.name_vi), | |
| datasets: [{ data: classRows.map((r) => r.n), | |
| backgroundColor: classRows.map((r) => EL_BINS[r.info.bin].color), borderRadius: 4, barThickness: 18 }] }, | |
| options: { indexAxis: "y", maintainAspectRatio: false, | |
| plugins: { legend: { display: false }, | |
| tooltip: { callbacks: { label: (ctx) => ` ${ctx.parsed.x} lượt · Thùng ${EL_BINS[classRows[ctx.dataIndex].info.bin].label}` } } }, | |
| scales: { x: { grid: { color: GRID }, ticks: { precision: 0 }, border: { display: false } }, | |
| y: { grid: { display: false }, ticks: { color: INK, font: { weight: 600 } }, border: { display: false } } } }, | |
| }); | |
| document.getElementById("table-class").innerHTML = | |
| "<tr><th>Loại rác</th><th>Thùng</th><th>Lượt</th></tr>" + | |
| classRows.map((r) => `<tr><td>${r.info.name_vi}</td><td>${EL_BINS[r.info.bin].label}</td><td>${r.n}</td></tr>`).join(""); | |
| const days = Object.keys(s.byDay).sort().slice(-30); | |
| new Chart(document.getElementById("chart-day"), { | |
| type: "line", | |
| data: { labels: days.map((d) => d.slice(5)), | |
| datasets: [{ data: days.map((d) => s.byDay[d]), borderColor: GREEN, borderWidth: 2, | |
| pointRadius: 3, pointHoverRadius: 6, pointBackgroundColor: GREEN, | |
| fill: { target: "origin" }, backgroundColor: "rgba(14,159,110,.08)", tension: .3 }] }, | |
| options: { maintainAspectRatio: false, interaction: { mode: "index", intersect: false }, | |
| plugins: { legend: { display: false } }, | |
| scales: { x: { grid: { display: false }, border: { display: false } }, | |
| y: { grid: { color: GRID }, ticks: { precision: 0 }, border: { display: false }, beginAtZero: true } } }, | |
| }); | |
| } | |
| </script> | |
| </body> | |
| </html> | |