From 1995a2a0097de3e622272a855cffc2722a6381dd Mon Sep 17 00:00:00 2001 From: Manuel Dublanc <19774382+manud99@users.noreply.github.com> Date: Sat, 3 Feb 2024 17:20:19 +0100 Subject: [PATCH] Add table overview to statistics page. --- src/pages/Statistics.vue | 59 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/src/pages/Statistics.vue b/src/pages/Statistics.vue index cd73abf..1cb0b62 100644 --- a/src/pages/Statistics.vue +++ b/src/pages/Statistics.vue @@ -105,9 +105,6 @@ ChartJS.register(CategoryScale, LinearScale, LineElement, BarElement, PointEleme const chartHoursPerWeek = computed(() => { const labels = Object.keys(minutesPerWeek.value); - const totalData = labels.map((label) => { - return minutesPerWeek.value[label].total / 60; - }); const subjects = getSubjects().value.filter((subject) => subject.isActive); const subjectDatasets = subjects.map((subject) => { @@ -124,6 +121,22 @@ const chartHoursPerWeek = computed(() => { }; }); +const totalMinutes = computed(() => { + const total = Object.values(minutesPerWeek.value).reduce((carry, week) => { + return carry + week.total; + }, 0) + + const subjects: { [subject: string]: number } = {}; + for (const week in minutesPerWeek.value) { + for (const subject in minutesPerWeek.value[week]) { + if (subject === "total") continue; + subjects[subject] = (subjects[subject] || 0) + minutesPerWeek.value[week][subject]; + } + } + + return {subjects, total}; +}); + function toHoursAndMin(value: number) { const hours = Math.floor(value); const minutes = (value - hours) * 60; @@ -196,5 +209,45 @@ const lineChartOptions: ChartOptions<"line"> = {

Line-Chart

+
+

Tabelle Übersicht

+ + + + + + + + + + + + + + + + + + + + + + + + +
Woche + {{ subject.name }} + Total
{{ new CustomDate(week).getDate() }} + - + + {{ toHoursAndMin(minutesPerWeek[week].total / 60) }}
Insgesamt + - + + {{ toHoursAndMin(totalMinutes.total / 60) }}
ECTS (25h pro Punkt) + - + + +
+