Skip to content

Commit c21988d

Browse files
committed
fix label angle, limit labelIndexInterval to 1 in T21AAP
1 parent 287f1ed commit c21988d

File tree

9 files changed

+21745
-594
lines changed

9 files changed

+21745
-594
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rcpch/digital-growth-charts-react-component-library",
3-
"version": "7.2.0",
3+
"version": "7.2.1",
44
"description": "A React component library for the RCPCH digital growth charts using Rollup, TypeScript and Styled-Components",
55
"main": "build/index.js",
66
"module": "build/esm.index.js",

src/CentileChart/CentileChart.tsx

+24-4
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ function CentileChart({
161161
pubertyThresholds = makePubertyThresholds(domains, sex);
162162
}
163163
if (reference === 'uk-who' || reference === 'cdc') {
164-
nondisjunctionThresholds = makeNonDisjunctionThresholds(domains, sex, reference);
164+
if (reference === 'cdc' && measurementMethod === 'ofc') {
165+
// no nondisjunction lines for CDC OFC
166+
nondisjunctionThresholds = null;
167+
} else {
168+
nondisjunctionThresholds = makeNonDisjunctionThresholds(domains, sex, reference);
169+
}
165170
}
166171

167172
const filteredMidParentalHeightData = useMemo(
@@ -537,7 +542,12 @@ function CentileChart({
537542
style={{ ...styles.dashedCentile }}
538543
labels={(props: { index: number }) =>
539544
centileLabels &&
540-
labelIndexInterval(chartScaleType, props.index) &&
545+
labelIndexInterval(
546+
chartScaleType,
547+
props.index,
548+
reference,
549+
measurementMethod,
550+
) &&
541551
props.index > 0
542552
? [addOrdinalSuffix(centile.centile)]
543553
: null
@@ -583,7 +593,12 @@ function CentileChart({
583593
style={{ ...styles.continuousCentile }}
584594
labels={(props: { index: number }) =>
585595
centileLabels &&
586-
labelIndexInterval(chartScaleType, props.index) &&
596+
labelIndexInterval(
597+
chartScaleType,
598+
props.index,
599+
reference,
600+
measurementMethod,
601+
) &&
587602
props.index > 0
588603
? [addOrdinalSuffix(centile.centile)]
589604
: null
@@ -650,7 +665,12 @@ function CentileChart({
650665
style={styles.sdsLine}
651666
labels={(props: { index: number }) =>
652667
centileLabels &&
653-
labelIndexInterval(chartScaleType, props.index) &&
668+
labelIndexInterval(
669+
chartScaleType,
670+
props.index,
671+
reference,
672+
measurementMethod,
673+
) &&
654674
props.index > 0
655675
? [sdsLine.sds]
656676
: null

src/RCPCHChart/RCPCHChart.stories.tsx

+65
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { girlMidparentalheightCDC } from '../testParameters/measurements/girlMid
1313
import { girlMidparentalHeightUKWHO } from '../testParameters/measurements/girlMidparentalheightUKWHO.ts';
1414
import { prematureGirlBMI } from '../testParameters/measurements/prematureGirlBMI.ts';
1515
import { cdcOFCGirl } from '../testParameters/measurements/cdcOFCGirls.ts';
16+
import { maleCDCBMIExcess } from '../testParameters/measurements/maleCDCBMIExcess.ts';
17+
import { childTrisomyAAPData } from '../testParameters/measurements/childTrisomyAAPData.ts';
18+
import { maleWeightT21AAPData } from '../testParameters/measurements/maleWeightT21AAP.ts';
1619
// import { cdcFentonGirlLength } from '../testParameters/measurements/fenton/cdcFentonGirlLength';
1720
// import { cdcFentonGirlWeight } from '../testParameters/measurements/fenton/cdcFentonGirlWeight.ts';
1821

@@ -388,6 +391,26 @@ export const CentileChartCDCBoysBMI: Story = {
388391
},
389392
};
390393

394+
export const CentileChartCDCBoysBMIExcess: Story = {
395+
args: {
396+
title: 'Patient Name - Hospital Number',
397+
measurementMethod: 'bmi',
398+
reference: 'cdc',
399+
sex: 'male',
400+
measurements: {
401+
bmi: maleCDCBMIExcess,
402+
},
403+
midParentalHeightData: {},
404+
enableZoom: true,
405+
chartType: 'centile',
406+
enableExport: false,
407+
exportChartCallback: () => {},
408+
theme: 'tanner2',
409+
customThemeStyles: {},
410+
clinicianFocus: true,
411+
},
412+
};
413+
391414
export const CentileChartCDCGirlsHeadCircumference: Story = {
392415
args: {
393416
title: 'Patient Name - Hospital Number',
@@ -530,6 +553,48 @@ export const CentileChartTrisomy21AAPGirlsHeight: Story = {
530553
},
531554
};
532555

556+
export const CentileChartTrisomy21AAPBoysHeightData: Story = {
557+
args: {
558+
title: 'Patient Name - Hospital Number',
559+
measurementMethod: 'height',
560+
reference: 'trisomy-21-aap',
561+
sex: 'male',
562+
measurements: {
563+
height: childTrisomyAAPData,
564+
},
565+
midParentalHeightData: {},
566+
enableZoom: true,
567+
chartType: 'centile',
568+
enableExport: false,
569+
exportChartCallback: () => {},
570+
theme: 'tanner3',
571+
customThemeStyles: {},
572+
clinicianFocus: true,
573+
logoVariant: 'bottom',
574+
},
575+
};
576+
577+
export const CentileChartTrisomy21AAPBoysWeightData: Story = {
578+
args: {
579+
title: 'Patient Name - Hospital Number',
580+
measurementMethod: 'weight',
581+
reference: 'trisomy-21-aap',
582+
sex: 'male',
583+
measurements: {
584+
weight: maleWeightT21AAPData,
585+
},
586+
midParentalHeightData: {},
587+
enableZoom: true,
588+
chartType: 'centile',
589+
enableExport: false,
590+
exportChartCallback: () => {},
591+
theme: 'tanner3',
592+
customThemeStyles: {},
593+
clinicianFocus: true,
594+
logoVariant: 'bottom',
595+
},
596+
};
597+
533598
export const CentileChartTrisomy21AAPGirlsWeight: Story = {
534599
args: {
535600
title: 'Patient Name - Hospital Number',

src/functions/labelAngle.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function labelAngle(
1616
Also accepts chart domains as parameter, as x magnification depends on visible extremes of chart (eg a 3 year old seen close up, or 3 year old in life course view)
1717
*/
1818

19-
if (data.length < 1) {
19+
if (data === null || data.length < 1) {
2020
return;
2121
}
2222

@@ -79,11 +79,18 @@ export function labelAngle(
7979
}
8080
}
8181
if (measurementMethod === 'bmi') {
82-
ageDiff = xDiff * 2;
82+
if (chartScaleType === 'smallChild' || chartScaleType === 'biggerChild') {
83+
ageDiff = xDiff * 5;
84+
} else {
85+
ageDiff = xDiff * 9;
86+
}
8387
}
8488
if (measurementMethod === 'ofc') {
85-
ageDiff = xDiff * 2.5;
86-
if (chartScaleType === 'infant' || chartScaleType === 'smallChild') {
89+
ageDiff = xDiff * 10;
90+
if (chartScaleType === 'smallChild') {
91+
ageDiff = xDiff * 5;
92+
}
93+
if (chartScaleType === 'infant') {
8794
ageDiff = xDiff * 25;
8895
}
8996
if (chartScaleType === 'prem') {

src/functions/labelIndexInterval.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
export function labelIndexInterval(
22
chartScaleType: 'prem' | 'infant' | 'smallChild' | 'biggerChild' = 'biggerChild',
33
index: number,
4+
reference: 'uk-who' | 'cdc' | 'trisomy-21' | 'trisomy-21-aap' | 'turner',
5+
measurementMethod: 'height' | 'weight' | 'bmi' | 'ofc',
46
): boolean {
57
// returns true if index of data point in centile data array should be rendered
68

79
switch (chartScaleType) {
810
case 'prem':
911
return index % 5 == 0;
1012
case 'infant':
11-
return index % 10 == 0;
13+
return index % 5 == 0;
1214
case 'smallChild':
1315
return index % 30 == 0;
1416
case 'biggerChild':
17+
if (reference === 'trisomy-21-aap') {
18+
if (measurementMethod === 'height' || measurementMethod === 'ofc') {
19+
return index % 5 == 0;
20+
}
21+
return index % 20 == 0;
22+
}
1523
return index % 40 == 0;
1624
default:
1725
return index % 50 == 0;

0 commit comments

Comments
 (0)