From 2719f64abecfc10fbd1f2114c43ee63cb9d246d0 Mon Sep 17 00:00:00 2001 From: petterav Date: Wed, 17 Apr 2024 15:00:45 +0200 Subject: [PATCH] More cognitive age counting --- .../GrowthChartBuilder/GrowthChartBuilder.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/components/GrowthChart/GrowthChartBuilder/GrowthChartBuilder.tsx b/src/components/GrowthChart/GrowthChartBuilder/GrowthChartBuilder.tsx index 67acbde..aa34a6a 100644 --- a/src/components/GrowthChart/GrowthChartBuilder/GrowthChartBuilder.tsx +++ b/src/components/GrowthChart/GrowthChartBuilder/GrowthChartBuilder.tsx @@ -59,7 +59,23 @@ 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) return '0'; + if (isLastTick) return '12'; + + const modulo = value % 12; + return modulo === 0 ? '' : modulo; + } + return value; + }, + }, + }, y: { title: {