fix: metric chart total count

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-11-12 22:40:52 +01:00
parent 447b7668fd
commit 84fd5ce22f
16 changed files with 190 additions and 175 deletions

View File

@@ -4,12 +4,14 @@ export interface ISerieDataItem {
label_2?: string | null | undefined;
label_3?: string | null | undefined;
count: number;
total_count?: number;
date: string;
}
interface GroupedDataPoint {
date: string;
count: number;
total_count?: number;
}
interface GroupedResult {
@@ -45,6 +47,7 @@ export function groupByLabels(data: ISerieDataItem[]): GroupedResult[] {
group.data.push({
date: row.date,
count: row.count,
total_count: row.total_count,
});
});
@@ -63,7 +66,7 @@ export function groupByLabels(data: ISerieDataItem[]): GroupedResult[] {
// This will ensure that all dates are present in the data array
data: Array.from(timestamps).map((date) => {
const dataPoint = group.data.find((dp) => dp.date === date);
return dataPoint || { date, count: 0 };
return dataPoint || { date, count: 0, total_count: 0 };
}),
};
});