diff --git a/src/app.js b/src/app.js index b45f7e0..f2f7701 100644 --- a/src/app.js +++ b/src/app.js @@ -124,6 +124,22 @@ function showChart(selectedMonth) { }, }, }); + + updateStats(data.poppersData[year][month]); +} + +function updateStats(breaths) { + const breathMonth = document.getElementById('breathMonth'); + const breathAverage = document.getElementById('breathAverage'); + + let totalBreathInMonth = 0; + let daysCount = 0; + for (const [key, value] of Object.entries(breaths)) { + totalBreathInMonth += value.length; + daysCount += 1; + } + breathMonth.value = totalBreathInMonth; + breathAverage.value = Math.round(totalBreathInMonth / daysCount); } /* Внешний HTML Tooltip | Потом изменить */ diff --git a/src/index.html b/src/index.html index 5affebc..2160802 100644 --- a/src/index.html +++ b/src/index.html @@ -19,7 +19,7 @@
-

График

+

Дата

+
+
+ Среднее количество вдыханий за сутки + +
+