From d0c3b8b47e9b1570bbcf6914483c0bc67b87b6ab Mon Sep 17 00:00:00 2001 From: Henry Marshall Date: Fri, 17 Jan 2025 17:51:53 +0100 Subject: [PATCH] Grouped bar totals - fix for %s (#204) --- src/components/util/getBarChartOptions.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/util/getBarChartOptions.ts b/src/components/util/getBarChartOptions.ts index a2f3d43..1c776d3 100644 --- a/src/components/util/getBarChartOptions.ts +++ b/src/components/util/getBarChartOptions.ts @@ -240,7 +240,7 @@ export default function getBarChartOptions({ } return displayHorizontally ? 'right' : 'top'; }, - display: showTotals ? 'true' : false, + display: showTotals && stackBars ? 'true' : false, font: { weight: 'bold', }, @@ -254,7 +254,10 @@ export default function getBarChartOptions({ const currxAxisName = xAxisNames[context.dataIndex]; const currDatasetIndex = context.datasetIndex; if (currDatasetIndex === totals[currxAxisName].lastSegment && v !== null) { - let val = formatValue(totals[currxAxisName].total.toString(), { + const barTotal = displayAsPercentage + ? '100' + : totals[currxAxisName].total.toString(); + let val = formatValue(barTotal, { type: 'number', dps: dps, meta: displayAsPercentage ? undefined : metric?.meta,