feat: enhance recovery dashboard with vital signs analytics and visualization improvements
Deploy Development / deploy (push) Successful in 1m1s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 18s

- Updated the `build_vital_signs_matrix_chart_payload` function to accept optional keys for omitting specific snapshot data, improving flexibility in data presentation.
- Enhanced the `build_recovery_dashboard_kpi_tiles` function to conditionally merge heart and autonomic tiles based on new parameters, refining the dashboard's insights.
- Integrated new analytics features in the `RecoveryDashboardOverview` component, including consolidated paragraphs for better narrative context and visual representation of trends.
- Improved the handling of vital signs data in the frontend, ensuring clearer messaging and enhanced user experience when displaying vital metrics.
This commit is contained in:
Lars committed 2026-04-20 10:29:43 +02:00
1 parent e7bcdc3228
commit 8cb5ad992f
7 files changed
+299 -166

No files matched your search

@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react'
import { useNavigate } from 'react-router-dom'
import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianGrid } from 'recharts'
import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianGrid, Legend } from 'recharts'
import { api } from '../utils/api'
import KpiTilesOverview from './KpiTilesOverview'
import { getStatusColor, getStatusBg } from '../utils/interpret'
@@ -311,13 +311,39 @@ export default function RecoveryDashboardOverview({
}
const series = vh.series || {}
const keys = Object.keys(series)
const paragraphs = vh.analytics?.consolidated_paragraphs || []
const bullets = vh.analytics?.bullets || []
const corrNote = vh.metadata?.load_rhr_correlation
const pairsN = vh.metadata?.load_rhr_pairs_n
const showParagraphs = paragraphs.length > 0
const showBulletsFallback = !showParagraphs && bullets.length > 0
return (
<div style={{ width: '100%', minWidth: 0 }}>
{bullets.length > 0 ? (
{showParagraphs ? (
<div style={{ marginBottom: 14 }}>
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--text3)', marginBottom: 8 }}>
Einordnung (Vital & Belastung)
</div>
<div
style={{
borderRadius: 8,
padding: '12px 14px',
border: '1px solid var(--border)',
background: 'var(--surface2)',
fontSize: 12,
color: 'var(--text2)',
lineHeight: 1.55,
}}
>
{paragraphs.map((text, i) => (
<p key={i} style={{ margin: i === 0 ? 0 : '10px 0 0' }}>
{text}
</p>
))}
</div>
</div>
) : null}
{showBulletsFallback ? (
<div style={{ marginBottom: 14 }}>
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--text3)', marginBottom: 8 }}>
Einordnung (Vital & Belastung)
@@ -339,31 +365,34 @@ export default function RecoveryDashboardOverview({
</div>
))}
</div>
{corrNote != null && pairsN != null ? (
<div style={{ marginTop: 8, fontSize: 10, color: 'var(--text3)' }}>
Korrelation Trainingsminuten (Tag) ↔ Ruhepuls (Folgetag): r ≈ {corrNote} (n = {pairsN} Paare)
</div>
) : null}
</div>
) : null}
<div style={{ fontSize: 11, color: 'var(--text3)', marginBottom: 8 }}>
Je Kennzahl eigene Skala (physische Einheit). Verlauf sinnvoll ab ca. 2–3 Messpunkten.
Je Kennzahl eigene Skala (physische Einheit). Gestrichelt: gleitender Mittelwert (max. 7 aufeinanderfolgende
Messungen), glättet starke Einzelschwankungen.
</div>
{keys.map((k) => {
const m = series[k]
const pts = m.points || []
const maPts = m.points_ma7 || []
if (pts.length === 0) return null
const chartData = pts.map((p) => ({
const chartData = pts.map((p, i) => ({
...p,
d: fmtDate(p.date),
value_ma: maPts[i]?.value != null ? maPts[i].value : null,
}))
const vals = pts.map((p) => p.value)
const vals = []
pts.forEach((p, i) => {
vals.push(p.value)
if (maPts[i]?.value != null) vals.push(maPts[i].value)
})
const mn = Math.min(...vals)
const mx = Math.max(...vals)
const span = mx - mn
const pad = span < 1e-9 ? Math.max(Math.abs(mn) * 0.05, 0.5) : span * 0.12
const hasMa = maPts.length > 0 && maPts.some((x) => x?.value != null)
return (
<div key={k} style={{ marginBottom: 16, width: '100%' }}>
@@ -381,7 +410,7 @@ export default function RecoveryDashboardOverview({
Ein Messpunkt ({m.last}) — weiter erfassen, um einen Verlauf zu sehen.
</div>
) : (
<div style={{ width: '100%', height: 200, minHeight: 200 }}>
<div style={{ width: '100%', height: hasMa ? 220 : 200, minHeight: hasMa ? 220 : 200 }}>
<ResponsiveContainer width="100%" height="100%">
<LineChart data={chartData} margin={{ top: 4, right: 12, bottom: 0, left: 0 }}>
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
@@ -399,14 +428,28 @@ export default function RecoveryDashboardOverview({
fontSize: 11,
}}
/>
{hasMa ? <Legend wrapperStyle={{ fontSize: 10, paddingTop: 4 }} /> : null}
<Line
type="monotone"
dataKey="value"
stroke={m.color || '#1D9E75'}
strokeWidth={2}
dot={{ r: 3 }}
name={m.label_de}
name="Messwert"
/>
{hasMa ? (
<Line
type="monotone"
dataKey="value_ma"
stroke={m.color || '#1D9E75'}
strokeOpacity={0.55}
strokeWidth={2}
strokeDasharray="5 5"
dot={false}
name="Ø (max. 7 Messungen)"
connectNulls
/>
) : null}
</LineChart>
</ResponsiveContainer>
</div>
@@ -444,9 +487,17 @@ export default function RecoveryDashboardOverview({
const vitDate = meta.vitals_measured_at
const bpDate = meta.blood_pressure_measured_at
const disclaimer = meta.disclaimer_de
const hasRhrCard = items.some((it) => it.key === 'resting_hr')
const hasHrvCard = items.some((it) => it.key === 'hrv')
return (
<>
{items.length > 0 && !hasRhrCard && !hasHrvCard ? (
<p style={{ fontSize: 11, color: 'var(--text3)', lineHeight: 1.45, marginBottom: 10 }}>
Ruhepuls und HRV sind in diesem Bereich bewusst nicht noch einmal als Zonen-Karten geführt — die Einordnung
steht oben im Vital-Verlauf und in der KPI-Kachel „Herz & autonomes System“.
</p>
) : null}
{items.length > 0 ? (
<div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginBottom: 14 }}>
{items.map((it) => {