Skip to content

Commit 72ca41b

Browse files
authored
Merge pull request #96 from rcpch:mbarton/trisomy-21-bmi-rendering-issue
trisomy-21-bmi-rendering-issue-fix
2 parents 07f1af8 + 417036f commit 72ca41b

File tree

6 files changed

+182
-3
lines changed

6 files changed

+182
-3
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.0.7",
3+
"version": "7.0.8",
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.stories.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { termToOverFourYearsGirlHeight } from '../testParameters/measurements/te
2626
import { turnerHeightOneYearToEleven } from '../testParameters/measurements/turnerHeightOneYearToEleven';
2727
import { beforeDueDateError } from '../testParameters/measurements/beforeDueDateError';
2828
import { termBabyGirlWeight } from '../testParameters/measurements/termBabyGirlWeight';
29+
import { trisomy21HighBMI } from '../testParameters/measurements/trisomy21HighBMI';
2930

3031
export default {
3132
title: 'CentileChart',
@@ -463,6 +464,24 @@ export const WithTermBabyGirlWeight = () => (
463464
/>
464465
);
465466

467+
export const WithTrisomy21HighBMI = () => (
468+
<CentileChart
469+
chartsVersion="7.0.0"
470+
reference="trisomy-21"
471+
title="Trisomy 21 Child"
472+
subtitle="High BMI Boy"
473+
measurementMethod="bmi"
474+
sex="male"
475+
childMeasurements={trisomy21HighBMI}
476+
midParentalHeightData={midParentalHeights}
477+
enableZoom={true}
478+
styles={Tanner3Styles}
479+
enableExport={true}
480+
exportChartCallback={() => null}
481+
clinicianFocus={true}
482+
/>
483+
);
484+
466485
// props
467486

468487
const midParentalHeights = {};

src/chartdata/reference-data.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export { ukwhoBMIFemaleCentileData }
5151
export { ukwhoBMIMaleSDSData }
5252
export { ukwhoBMIFemaleSDSData }
5353

54-
export { ukwhoCustomData }
54+
// export { ukwhoCustomData }
5555

5656
export { trisomy21HeightMaleCentileData }
5757
export { trisomy21HeightFemaleCentileData }

src/functions/getDomainsAndData.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { trisomy21WeightFemaleCentileData } from '../chartdata/trisomy21_weight_
3131
import { trisomy21OFCMaleCentileData } from '../chartdata/trisomy21_ofc_male_centile_data';
3232
import { trisomy21OFCFemaleCentileData } from '../chartdata/trisomy21_ofc_female_centile_data';
3333
import { turnerHeightFemaleCentileData } from '../chartdata/turner_height_female_centile_data';
34+
import { LineSegment } from 'victory';
3435

3536
type CentileLabelValues = {
3637
0.4: { value: number; workingX: number };
@@ -302,7 +303,7 @@ function childMeasurementRanges(
302303
console.warn('Measurements considered invalid by the API given to the chart. The chart will ignore them.');
303304
}
304305
}
305-
306+
306307
return { lowestChildX, highestChildX, lowestChildY, highestChildY };
307308
}
308309

@@ -351,6 +352,7 @@ function updateCoordsOfExtremeValues(
351352
d: IPlottedCentileMeasurement,
352353
native = false,
353354
): void {
355+
354356
// transition points can lead to inaccurate coords for centile labels, therefore don't include 2 or 4 years old
355357
if (!native || (d.x !== 4 && d.x !== 2)) {
356358
if (extremeValues.lowestY > d.y) {
@@ -360,6 +362,11 @@ function updateCoordsOfExtremeValues(
360362
if (extremeValues.highestY < d.y) {
361363
extremeValues.highestY = d.y;
362364
}
365+
// this is necessary because in the BMI dataset (esp Trisomy-21), the values for Y ramp up to infinitity towards the end of the dataset
366+
// this is a hack to prevent the chart from scaling to infinity - see discussion in #93 about the nature of SDS calculation when L is 0 or negative
367+
if (extremeValues.highestY > 500){
368+
extremeValues.highestY = d.y;
369+
}
363370

364371
if (native) {
365372
if (extremeValues.highestYForX[centileString].workingX < d.x) {

src/functions/tooltips.ts

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ export function tooltipText(
4040
chronological_percentage_median_bmi
4141
} = datum;
4242

43+
if (datum.y === null) {
44+
return
45+
}
46+
47+
4348
// flag passed in from user - if clinician, show clinician age advice strings, else show child/family advice
4449
const comment = clinicianFocus ? clinician_comment : lay_comment;
4550

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
import type { Measurement } from "../../interfaces/RCPCHMeasurementObject";
2+
3+
export const trisomy21HighBMI: Measurement[] = [
4+
{
5+
"birth_data": {
6+
"birth_date": "2006-05-08",
7+
"gestation_weeks": 40,
8+
"gestation_days": 0,
9+
"estimated_date_delivery": "2006-05-08",
10+
"estimated_date_delivery_string": "Mon 08 May, 2006",
11+
"sex": "male"
12+
},
13+
"measurement_dates": {
14+
"observation_date": "2022-11-01",
15+
"chronological_decimal_age": 16.484599589322382,
16+
"corrected_decimal_age": 16.484599589322382,
17+
"chronological_calendar_age": "16 years, 5 months, 3 weeks and 3 days",
18+
"corrected_calendar_age": "16 years, 5 months, 3 weeks and 3 days",
19+
"corrected_gestational_age": {
20+
"corrected_gestation_weeks": null,
21+
"corrected_gestation_days": null
22+
},
23+
"comments": {
24+
"clinician_corrected_decimal_age_comment": "Born at term. No correction has been made for gestation.",
25+
"lay_corrected_decimal_age_comment": "Your child was born on their due date.",
26+
"clinician_chronological_decimal_age_comment": "Born Term. No correction has been made for gestation.",
27+
"lay_chronological_decimal_age_comment": "Your child was born on their due date."
28+
},
29+
"corrected_decimal_age_error": null,
30+
"chronological_decimal_age_error": null
31+
},
32+
"child_observation_value": {
33+
"measurement_method": "bmi",
34+
"observation_value": 36.3,
35+
"observation_value_error": null
36+
},
37+
"measurement_calculated_values": {
38+
"corrected_sds": 1.9929195642473767,
39+
"corrected_centile": 97.7,
40+
"corrected_centile_band": "This body mass index measurement is on or near the 98th centile.",
41+
"chronological_sds": 1.9929195642473767,
42+
"chronological_centile": 97.7,
43+
"chronological_centile_band": "This body mass index measurement is on or near the 98th centile.",
44+
"corrected_measurement_error": null,
45+
"chronological_measurement_error": null,
46+
"corrected_percentage_median_bmi": 163.3208998549931,
47+
"chronological_percentage_median_bmi": 163.3208998549931
48+
},
49+
"plottable_data": {
50+
"centile_data": {
51+
"chronological_decimal_age_data": {
52+
"x": 16.484599589322382,
53+
"y": 36.3,
54+
"b": null,
55+
"centile": 97.7,
56+
"sds": 1.9929195642473767,
57+
"bone_age_label": null,
58+
"events_text": null,
59+
"bone_age_type": null,
60+
"bone_age_sds": null,
61+
"bone_age_centile": null,
62+
"observation_error": null,
63+
"age_type": "chronological_age",
64+
"calendar_age": "16 years, 5 months, 3 weeks and 3 days",
65+
"lay_comment": "Your child was born on their due date.",
66+
"clinician_comment": "Born Term. No correction has been made for gestation.",
67+
"age_error": null,
68+
"centile_band": "This body mass index measurement is on or near the 98th centile.",
69+
"observation_value_error": null
70+
},
71+
"corrected_decimal_age_data": {
72+
"x": 16.484599589322382,
73+
"y": 36.3,
74+
"b": null,
75+
"centile": 97.7,
76+
"sds": 1.9929195642473767,
77+
"bone_age_label": null,
78+
"events_text": null,
79+
"bone_age_type": null,
80+
"bone_age_sds": null,
81+
"bone_age_centile": null,
82+
"observation_error": null,
83+
"age_type": "corrected_age",
84+
"calendar_age": "16 years, 5 months, 3 weeks and 3 days",
85+
"corrected_gestational_age": "",
86+
"lay_comment": "Your child was born on their due date.",
87+
"clinician_comment": "Born at term. No correction has been made for gestation.",
88+
"age_error": null,
89+
"centile_band": "This body mass index measurement is on or near the 98th centile.",
90+
"observation_value_error": null
91+
}
92+
},
93+
"sds_data": {
94+
"chronological_decimal_age_data": {
95+
"x": 16.484599589322382,
96+
"y": 1.9929195642473767,
97+
"b": null,
98+
"centile": 97.7,
99+
"sds": null,
100+
"bone_age_label": null,
101+
"events_text": null,
102+
"bone_age_type": null,
103+
"bone_age_sds": null,
104+
"bone_age_centile": null,
105+
"observation_error": null,
106+
"age_type": "chronological_age",
107+
"calendar_age": "16 years, 5 months, 3 weeks and 3 days",
108+
"lay_comment": "Your child was born on their due date.",
109+
"clinician_comment": "Born Term. No correction has been made for gestation.",
110+
"age_error": null,
111+
"centile_band": "This body mass index measurement is on or near the 98th centile.",
112+
"observation_value_error": null
113+
},
114+
"corrected_decimal_age_data": {
115+
"x": 16.484599589322382,
116+
"y": 1.9929195642473767,
117+
"b": null,
118+
"centile": 97.7,
119+
"sds": null,
120+
"bone_age_label": null,
121+
"events_text": null,
122+
"bone_age_type": null,
123+
"bone_age_sds": null,
124+
"bone_age_centile": null,
125+
"observation_error": null,
126+
"age_type": "corrected_age",
127+
"calendar_age": "16 years, 5 months, 3 weeks and 3 days",
128+
"corrected_gestational_age": "",
129+
"lay_comment": "Your child was born on their due date.",
130+
"clinician_comment": "Born at term. No correction has been made for gestation.",
131+
"age_error": null,
132+
"centile_band": "This body mass index measurement is on or near the 98th centile.",
133+
"observation_value_error": null
134+
}
135+
}
136+
},
137+
"bone_age": {
138+
"bone_age": null,
139+
"bone_age_type": null,
140+
"bone_age_sds": null,
141+
"bone_age_centile": null,
142+
"bone_age_text": null
143+
},
144+
"events_data": {
145+
"events_text": null
146+
}
147+
}
148+
]

0 commit comments

Comments
 (0)