From af970908777420d2a9aac493bec3ea41f34c5227 Mon Sep 17 00:00:00 2001 From: Abderrahmane Smimite Date: Thu, 16 Jan 2025 18:56:47 +0100 Subject: [PATCH] fix labels translation on stackedbar --- .../Chart/StackedBarsNormalized.svelte | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/Chart/StackedBarsNormalized.svelte b/frontend/src/lib/components/Chart/StackedBarsNormalized.svelte index 3dbd9c879..e4efe3133 100644 --- a/frontend/src/lib/components/Chart/StackedBarsNormalized.svelte +++ b/frontend/src/lib/components/Chart/StackedBarsNormalized.svelte @@ -36,6 +36,24 @@ 'not applicable' ]; + // Map the internal names to translated labels + const getSeriesLabel = (name: string) => { + switch (name) { + case 'not assessed': + return m.notAssessed(); + case 'partially compliant': + return m.partiallyCompliant(); + case 'non compliant': + return m.nonCompliant(); + case 'compliant': + return m.compliant(); + case 'not applicable': + return m.notApplicable(); + default: + return name; + } + }; + const series = seriesNames.map((name, categoryIdx) => { return { name, @@ -59,7 +77,8 @@ color: ['#d7dfea', '#74C0DE', '#E66', '#91CC75', '#EAE2D7'], //color: ['#D2D5DB', '#FDE048', '#F87171', '#86EFAC', '#000'], legend: { - selectedMode: false + selectedMode: false, + formatter: (name) => getSeriesLabel(name) }, grid, xAxis: {