Skip to content

Commit f96e032

Browse files
authored
Merge pull request #114 from rcpch:eatyourpeas/issue98
nondisjunction-lines
2 parents 507c9fd + e5e7bda commit f96e032

File tree

5 files changed

+91
-2
lines changed

5 files changed

+91
-2
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/CentileChart/CentileChart.tsx

+33
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import tailoredXTickValues from '../functions/tailoredXTickValues';
2222
import defaultToggles from '../functions/defaultToggles';
2323
import { tooltipText } from '../functions/tooltips';
2424
import { delayedPubertyThreshold, makePubertyThresholds, lowerPubertyBorder } from '../functions/DelayedPuberty';
25+
import { nondisjunctionThresholds, makeNonDisjunctionThresholds } from '../functions/nondisjunctionLines';
2526
import { getFilteredMidParentalHeightData } from '../functions/getFilteredMidParentalHeightData';
2627
import { isCrowded } from '../functions/isCrowded';
2728
import { labelAngle } from '../functions/labelAngle';
@@ -154,10 +155,14 @@ function CentileChart({
154155
const isChartCrowded = isCrowded(domains, childMeasurements);
155156

156157
let pubertyThresholds: null | any[] = null;
158+
let nondisjunctionThresholds: null | any[] = null;
157159

158160
if (reference === 'uk-who' && measurementMethod === 'height') {
159161
pubertyThresholds = makePubertyThresholds(domains, sex);
160162
}
163+
if (reference === 'uk-who') {
164+
nondisjunctionThresholds = makeNonDisjunctionThresholds(domains, sex)
165+
}
161166

162167
const filteredMidParentalHeightData = useMemo(() => getFilteredMidParentalHeightData(reference, childMeasurements, midParentalHeightData, sex),[
163168
reference,
@@ -629,6 +634,34 @@ function CentileChart({
629634
})
630635
}
631636

637+
{
638+
// nondisjunction lines uk90->uk-who->uk-who
639+
nondisjunctionThresholds !== null &&
640+
nondisjunctionThresholds.map((dataArray) => {
641+
if (dataArray[0].x > domains.x[0] && dataArray[1].x < domains.x[1]) {
642+
return (
643+
<VictoryLine
644+
key={dataArray[0].x}
645+
name={`nondisjunction-${dataArray[0].x}`}
646+
style={styles.nondisjunctionThresholdLine}
647+
data={dataArray}
648+
labelComponent={
649+
<VictoryLabel
650+
textAnchor="start"
651+
angle={-90}
652+
dx={5}
653+
dy={10}
654+
style={styles.nondisjunctionThresholdLabel}
655+
/>
656+
}
657+
/>
658+
);
659+
} else {
660+
return null;
661+
}
662+
})
663+
}
664+
632665
{/* create a series for each child measurements data point: a circle for chronological age, a cross for corrected */}
633666
{/* If data points are close together, reduce the size of the point */}
634667

src/functions/makeAllStyles.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ import { AxisStyle, CentileStyle, SDSStyle, ChartStyle, GridlineStyle, Measureme
1818

1919
const black = '#000000';
2020
const white = '#FFFFFF';
21+
const darkGrey = '#808080';
2122
const midGrey = '#b3b3b3';
2223
const lightGrey = '#d9d9d9';
2324
const lightLightGrey = "#f3f3f3";
25+
const charcoal = "#4d4d4d";
2426
const aquaGreen ='#00BDAA'
2527
const orange = '#FF8000'
2628
const purple = '#7159AA'
@@ -152,7 +154,7 @@ function makeAllStyles(
152154
},
153155
delayedPubertyThresholdLine: {
154156
data: {
155-
stroke: measurementStyle?.measurementFill ?? black,
157+
stroke: charcoal,
156158
strokeWidth: 1,
157159
},
158160
},
@@ -162,6 +164,12 @@ function makeAllStyles(
162164
fontFamily: axisStyle?.axisLabelTextStyle?.name ?? 'Arial',
163165
textAlign: 'start',
164166
},
167+
nondisjunctionThresholdLine: {
168+
data: {
169+
stroke: charcoal,
170+
strokeWidth: 1,
171+
},
172+
},
165173
sdsLine: { // these are the sds lines on the BMI chart
166174
data: {
167175
stroke: centileStyle?.sdsStroke ?? '#A9A9A9',

src/functions/nondisjunctionLines.ts

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Domains } from '../interfaces/Domains';
2+
3+
export const nondisjunctionThresholds = {
4+
male: [
5+
{
6+
x: 0.038,
7+
label: 'Transition point from UK-WHO to UK90 reference',
8+
},
9+
{
10+
x: 2,
11+
label: "Measure length until 2y. Measure height from 2y. A child's height is usually slightly less than their length.",
12+
},
13+
{
14+
x: 4,
15+
label: 'Transition point from UK-WHO to UK90 reference',
16+
},
17+
],
18+
female: [
19+
{
20+
x: 0.038,
21+
label: 'Transition point from UK-WHO to UK90 reference',
22+
},
23+
{
24+
x: 2,
25+
label: "Measure length until 2y. Measure height from 2y. A child's height is usually slightly less than their length.",
26+
},
27+
{
28+
x: 4,
29+
label: 'Transition point from UK-WHO to UK90 reference',
30+
},
31+
],
32+
};
33+
34+
export function makeNonDisjunctionThresholds(domains: Domains | null, sex: 'male' | 'female') {
35+
if (!domains) {
36+
return [];
37+
}
38+
const newNonDisjunctionThresholds: any[] = [];
39+
for (const element of nondisjunctionThresholds[sex]) {
40+
const dataSubArray = [];
41+
dataSubArray.push({ x: element.x, y: domains.y[0], label: element.label });
42+
dataSubArray.push({ x: element.x, y: domains.y[1], label: element.label });
43+
newNonDisjunctionThresholds.push(dataSubArray);
44+
}
45+
return newNonDisjunctionThresholds;
46+
}

src/interfaces/StyleObjects.ts

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export interface MeasurementStyle {
1919
export interface CentileStyle {
2020
sdsStroke?: string; // sds line colour
2121
centileStroke?: string; // centile line colour
22+
nondisjunctionThresholdLabel ?: string; // label for nondisjunctionThresholdLabel
23+
nondisjunctionThresholdLine ?: string; // colour of nondisjunctionThresholdLine
2224
delayedPubertyAreaFill?: string; // delayed puberty area colour
2325
midParentalCentileStroke?: string; // Midparental height centile line colour
2426
midParentalAreaFill?: string; // Midparental height area colour

0 commit comments

Comments
 (0)