diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index 1f6a0d23ba..f391533382 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -98,7 +98,7 @@ export class EducationalMaterialComponent implements OnInit { updateSummary() { const summary = new Map(); const average = new Map(); - + // Initialize summary and average maps in a single loop for (const m of this.records) { if (m.materialType) { @@ -119,9 +119,9 @@ export class EducationalMaterialComponent implements OnInit { const avgSummaryArray: string[] = []; for (const [label, labelData] of summary.entries()) { - const avg = labelData.sum / labelData.count; + const avg = parseFloat((labelData.sum / labelData.count).toPrecision(2)); average.set(label, avg); - + summaryArray.push(`${label}: ${labelData.sum}`); avgSummaryArray.push(`${label}: ${avg}`); }