feat: add key values on front
This commit is contained in:
parent
28baab1956
commit
56619b524d
2 changed files with 46 additions and 0 deletions
|
|
@ -28,4 +28,25 @@ async function loadData() {
|
|||
chart.destroy();
|
||||
}
|
||||
chart = renderChart(points);
|
||||
updateKPIs(points);
|
||||
}
|
||||
|
||||
function updateKPIs(points) {
|
||||
const totalDisplay = document.getElementById("kpi-total");
|
||||
const avgDisplay = document.getElementById("kpi-avg");
|
||||
const countDisplay = document.getElementById("kpi-count");
|
||||
|
||||
if (!points || points.length === 0) {
|
||||
total.textContent = "-";
|
||||
avg.textContent = "-";
|
||||
count.textContent = "-";
|
||||
return;
|
||||
}
|
||||
|
||||
const totalValue = points.reduce((acc, p) => acc + p.delta_m3, 0);
|
||||
const avgValue = totalValue / points.length;
|
||||
|
||||
totalDisplay.textContent = totalValue.toFixed(3);
|
||||
avgDisplay.textContent = avgValue.toFixed(3);
|
||||
countDisplay.textContent = points.length;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue