Skip to content

Commit

Permalink
Merge pull request #114 from rcpch:eatyourpeas/issue98
Browse files Browse the repository at this point in the history
nondisjunction-lines
  • Loading branch information
eatyourpeas authored Oct 18, 2024
2 parents 507c9fd + e5e7bda commit f96e032
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions src/CentileChart/CentileChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import tailoredXTickValues from '../functions/tailoredXTickValues';
import defaultToggles from '../functions/defaultToggles';
import { tooltipText } from '../functions/tooltips';
import { delayedPubertyThreshold, makePubertyThresholds, lowerPubertyBorder } from '../functions/DelayedPuberty';
import { nondisjunctionThresholds, makeNonDisjunctionThresholds } from '../functions/nondisjunctionLines';
import { getFilteredMidParentalHeightData } from '../functions/getFilteredMidParentalHeightData';
import { isCrowded } from '../functions/isCrowded';
import { labelAngle } from '../functions/labelAngle';
Expand Down Expand Up @@ -154,10 +155,14 @@ function CentileChart({
const isChartCrowded = isCrowded(domains, childMeasurements);

let pubertyThresholds: null | any[] = null;
let nondisjunctionThresholds: null | any[] = null;

if (reference === 'uk-who' && measurementMethod === 'height') {
pubertyThresholds = makePubertyThresholds(domains, sex);
}
if (reference === 'uk-who') {
nondisjunctionThresholds = makeNonDisjunctionThresholds(domains, sex)
}

const filteredMidParentalHeightData = useMemo(() => getFilteredMidParentalHeightData(reference, childMeasurements, midParentalHeightData, sex),[
reference,
Expand Down Expand Up @@ -629,6 +634,34 @@ function CentileChart({
})
}

{
// nondisjunction lines uk90->uk-who->uk-who
nondisjunctionThresholds !== null &&
nondisjunctionThresholds.map((dataArray) => {
if (dataArray[0].x > domains.x[0] && dataArray[1].x < domains.x[1]) {
return (
<VictoryLine
key={dataArray[0].x}
name={`nondisjunction-${dataArray[0].x}`}
style={styles.nondisjunctionThresholdLine}
data={dataArray}
labelComponent={
<VictoryLabel
textAnchor="start"
angle={-90}
dx={5}
dy={10}
style={styles.nondisjunctionThresholdLabel}
/>
}
/>
);
} else {
return null;
}
})
}

{/* create a series for each child measurements data point: a circle for chronological age, a cross for corrected */}
{/* If data points are close together, reduce the size of the point */}

Expand Down
10 changes: 9 additions & 1 deletion src/functions/makeAllStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import { AxisStyle, CentileStyle, SDSStyle, ChartStyle, GridlineStyle, Measureme

const black = '#000000';
const white = '#FFFFFF';
const darkGrey = '#808080';
const midGrey = '#b3b3b3';
const lightGrey = '#d9d9d9';
const lightLightGrey = "#f3f3f3";
const charcoal = "#4d4d4d";
const aquaGreen ='#00BDAA'
const orange = '#FF8000'
const purple = '#7159AA'
Expand Down Expand Up @@ -152,7 +154,7 @@ function makeAllStyles(
},
delayedPubertyThresholdLine: {
data: {
stroke: measurementStyle?.measurementFill ?? black,
stroke: charcoal,
strokeWidth: 1,
},
},
Expand All @@ -162,6 +164,12 @@ function makeAllStyles(
fontFamily: axisStyle?.axisLabelTextStyle?.name ?? 'Arial',
textAlign: 'start',
},
nondisjunctionThresholdLine: {
data: {
stroke: charcoal,
strokeWidth: 1,
},
},
sdsLine: { // these are the sds lines on the BMI chart
data: {
stroke: centileStyle?.sdsStroke ?? '#A9A9A9',
Expand Down
46 changes: 46 additions & 0 deletions src/functions/nondisjunctionLines.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Domains } from '../interfaces/Domains';

export const nondisjunctionThresholds = {
male: [
{
x: 0.038,
label: 'Transition point from UK-WHO to UK90 reference',
},
{
x: 2,
label: "Measure length until 2y. Measure height from 2y. A child's height is usually slightly less than their length.",
},
{
x: 4,
label: 'Transition point from UK-WHO to UK90 reference',
},
],
female: [
{
x: 0.038,
label: 'Transition point from UK-WHO to UK90 reference',
},
{
x: 2,
label: "Measure length until 2y. Measure height from 2y. A child's height is usually slightly less than their length.",
},
{
x: 4,
label: 'Transition point from UK-WHO to UK90 reference',
},
],
};

export function makeNonDisjunctionThresholds(domains: Domains | null, sex: 'male' | 'female') {
if (!domains) {
return [];
}
const newNonDisjunctionThresholds: any[] = [];
for (const element of nondisjunctionThresholds[sex]) {
const dataSubArray = [];
dataSubArray.push({ x: element.x, y: domains.y[0], label: element.label });
dataSubArray.push({ x: element.x, y: domains.y[1], label: element.label });
newNonDisjunctionThresholds.push(dataSubArray);
}
return newNonDisjunctionThresholds;
}
2 changes: 2 additions & 0 deletions src/interfaces/StyleObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface MeasurementStyle {
export interface CentileStyle {
sdsStroke?: string; // sds line colour
centileStroke?: string; // centile line colour
nondisjunctionThresholdLabel ?: string; // label for nondisjunctionThresholdLabel
nondisjunctionThresholdLine ?: string; // colour of nondisjunctionThresholdLine
delayedPubertyAreaFill?: string; // delayed puberty area colour
midParentalCentileStroke?: string; // Midparental height centile line colour
midParentalAreaFill?: string; // Midparental height area colour
Expand Down

0 comments on commit f96e032

Please sign in to comment.