Skip to content

Commit

Permalink
feat: [CGC-27] Count Months Like WHO Chart (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
petterav authored Apr 24, 2024
1 parent e4e68d9 commit 49bfb52
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,25 @@ export const GrowthChartBuilder = ({
},
min: datasetMetadata.range.start,
max: datasetMetadata.range.end,
ticks: { stepSize: 1 },
ticks: {
stepSize: 1,
callback: (value: number, index, values) => {
if (datasetMetadata.xAxisLabel === 'Months') {
const isFirstTick = index === 0;
const isLastTick = index === values.length - 1;

if (isFirstTick || isLastTick) {
const years = value / 12;
return `${years} ${years === 1 ? i18n.t('Year') : i18n.t('Years')}`;
}

const modulo = value % 12;
return modulo === 0 ? '' : modulo;
}
return value;
},
},

},
y: {
title: {
Expand Down

0 comments on commit 49bfb52

Please sign in to comment.