Skip to content

Commit

Permalink
Grouped bar totals - fix for %s (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjkmarshall authored Jan 17, 2025
1 parent 894c5a6 commit d0c3b8b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/util/getBarChartOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export default function getBarChartOptions({
}
return displayHorizontally ? 'right' : 'top';
},
display: showTotals ? 'true' : false,
display: showTotals && stackBars ? 'true' : false,
font: {
weight: 'bold',
},
Expand All @@ -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,
Expand Down

0 comments on commit d0c3b8b

Please sign in to comment.