- Deleted unused components: GoalsSnapshotWidget, ReferenceValuesSummaryWidget, WeightKpiWidget, and PilotVizAdminCard. - Removed associated layout storage and widget registry logic to streamline the pilot visualization module. - Updated PilotVizPage to integrate new components for improved user experience and functionality.
17 lines
484 B
JavaScript
17 lines
484 B
JavaScript
import dayjs from 'dayjs'
|
|
|
|
/** Gleiche Logik wie History.jsx für rollierende Mittel */
|
|
export function rollingAvg(arr, key, window = 7) {
|
|
return arr.map((d, i) => {
|
|
const s = arr
|
|
.slice(Math.max(0, i - window + 1), i + 1)
|
|
.map((x) => x[key])
|
|
.filter((v) => v != null)
|
|
return s.length
|
|
? { ...d, [`${key}_avg`]: Math.round((s.reduce((a, b) => a + b, 0) / s.length) * 10) / 10 }
|
|
: d
|
|
})
|
|
}
|
|
|
|
export const fmtDate = (d) => dayjs(d).format('DD.MM')
|