@rcpch/digital-growth-charts-react-component-library
Version:
A React component library for the RCPCH digital growth charts using Rollup, TypeScript and Styled-Components
290 lines (281 loc) • 9.16 kB
TypeScript
import * as React from 'react';
interface Reference {
[name: string]: ISexChoice;
}
interface ICentile {
centile?: number;
data?: IPlottedCentileMeasurement[];
sds?: number;
}
interface IPlottedCentileMeasurement {
l?: string | number;
x?: number;
y?: number;
}
interface ISexChoice {
male?: IMeasurementMethod;
female?: IMeasurementMethod;
}
interface IMeasurementMethod {
height?: ICentile[];
weight?: ICentile[];
bmi?: ICentile[];
ofc?: ICentile[];
}
interface MidParentalHeightObject {
mid_parental_height?: number;
mid_parental_height_sds?: number;
mid_parental_height_centile?: number;
mid_parental_height_centile_data?: Reference[];
mid_parental_height_upper_centile_data?: Reference[];
mid_parental_height_lower_centile_data?: Reference[];
mid_parental_height_lower_value?: number;
mid_parental_height_upper_value?: number;
}
interface ChartStyle {
backgroundColour?: string;
titleStyle?: TextStyle;
subTitleStyle?: TextStyle;
tooltipBackgroundColour?: string;
tooltipStroke?: string;
tooltipBorderRadius?: number;
tooltipTextStyle?: TextStyle;
termFill?: string;
termStroke?: string;
toggleButtonInactiveColour?: string;
toggleButtonActiveColour?: string;
toggleButtonTextStyle?: TextStyle;
toggleButtonTooltipStyle?: ToggleButtonTooltipStyle;
toggleButtonSize?: number;
}
interface MeasurementStyle {
measurementFill?: string;
highlightedMeasurementFill?: string;
eventTextStyle?: TextStyle;
}
interface CentileStyle {
sdsStroke?: string;
centileStroke?: string;
nondisjunctionThresholdLabel?: string;
nondisjunctionThresholdLine?: string;
delayedPubertyAreaFill?: string;
midParentalCentileStroke?: string;
midParentalAreaFill?: string;
centileTextStyle?: Pick<TextStyle, 'name' | 'size' | 'weight'>;
}
interface SDSStyle {
heightStroke?: string;
weightStroke?: string;
ofcStroke?: string;
bmiStroke?: string;
}
interface GridlineStyle {
gridlines?: boolean;
stroke?: string;
strokeWidth?: number;
dashed?: boolean;
}
interface AxisStyle {
axisStroke?: string;
axisThresholdLabelTextStyle?: TextStyle;
axisThresholdLineStyle?: AxisThresholdLineStyle;
axisLabelTextStyle?: TextStyle;
tickLabelTextStyle?: TickLabelTextStyle;
}
interface TickLabelTextStyle extends TextStyle {
padding?: number;
}
interface AxisThresholdLineStyle {
colour?: string;
}
interface ReferenceStyle extends TextStyle {
}
interface ToggleButtonTooltipStyle extends TextStyle {
backgroundColour?: string;
borderRadius?: number;
}
interface TextStyle {
name?: string;
colour?: string;
size?: number;
style?: 'italic' | 'normal';
weight?: number | string;
}
interface Measurement {
birth_data: {
birth_date: string;
estimated_date_delivery: string;
estimated_date_delivery_string: string;
gestation_weeks: number;
gestation_days: number;
sex: 'male' | 'female';
};
child_observation_value: {
measurement_method: 'height' | 'weight' | 'bmi' | 'ofc';
observation_value: number;
observation_value_error?: string;
};
measurement_dates: {
chronological_calendar_age: string;
chronological_decimal_age: number;
corrected_calendar_age: string;
corrected_decimal_age: number;
corrected_gestational_age?: {
corrected_gestation_weeks?: number;
corrected_gestation_days?: number;
};
comments?: {
clinician_corrected_decimal_age_comment?: string;
lay_corrected_decimal_age_comment?: string;
clinician_chronological_decimal_age_comment: string;
lay_chronological_decimal_age_comment: string;
};
observation_date: string;
corrected_decimal_age_error?: string;
chronological_decimal_age_error?: string;
};
measurement_calculated_values: {
chronological_centile: number;
chronological_centile_band: string;
chronological_measurement_error?: string;
chronological_sds: number;
corrected_centile: number;
corrected_centile_band: string;
corrected_measurement_error?: string;
corrected_percentage_median_bmi?: number;
chronological_percentage_median_bmi?: number;
corrected_sds: number;
};
plottable_data: {
centile_data: {
chronological_decimal_age_data: {
age_error?: string;
age_type: 'chronological_age' | 'corrected_age';
calendar_age: string;
centile_band: string;
clinician_comment: string;
lay_comment: string;
observation_error?: string;
observation_value_error?: string;
x: number;
y: number;
b?: number;
centile?: number;
sds?: number;
bone_age_label?: string;
events_text?: string[];
bone_age_type?: string;
bone_age_sds?: number;
bone_age_centile?: number;
};
corrected_decimal_age_data: {
age_error?: string;
age_type: 'chronological_age' | 'corrected_age';
calendar_age: string;
centile_band: string;
clinician_comment: string;
lay_comment: string;
observation_error?: string;
observation_value_error?: string;
x: number;
y: number;
b?: number;
centile?: number;
sds?: number;
bone_age_label?: string;
events_text?: string[];
bone_age_type?: string;
bone_age_sds?: number;
bone_age_centile?: number;
corrected_gestational_age?: string;
};
};
sds_data: {
chronological_decimal_age_data: {
age_error?: string;
age_type: 'chronological_age' | 'corrected_age';
calendar_age: string;
centile_band: string;
clinician_comment: string;
lay_comment: string;
observation_error?: string;
observation_value_error?: string;
x: number;
y: number;
b?: number;
centile: number;
sds?: number;
bone_age_label?: string;
events_text?: string[];
bone_age_sds?: number;
bone_age_type?: string;
bone_age_centile?: number;
};
corrected_decimal_age_data: {
age_error?: string;
age_type: 'chronological_age' | 'corrected_age';
calendar_age: string;
centile_band: string;
clinician_comment: string;
lay_comment: string;
observation_error?: string;
observation_value_error?: string;
x: number;
y: number;
b?: number;
centile: number;
sds?: number;
bone_age_label?: string;
bone_age_type?: string;
events_text?: string[];
bone_age_sds?: number;
bone_age_centile?: number;
corrected_gestational_age?: string;
};
};
};
bone_age: {
bone_age?: number;
bone_age_type?: string;
bone_age_centile?: number;
bone_age_sds?: number;
bone_age_text?: string;
};
events_data: {
events_text?: string[];
};
}
interface ClientMeasurementObject {
height?: Measurement[];
weight?: Measurement[];
bmi?: Measurement[];
ofc?: Measurement[];
}
interface RCPCHChartProps {
title: string;
measurementMethod: 'height' | 'weight' | 'ofc' | 'bmi';
reference: 'uk-who' | 'turner' | 'trisomy-21' | 'cdc' | 'trisomy-21-aap' | 'who';
sex: 'male' | 'female';
measurements: ClientMeasurementObject;
midParentalHeightData?: MidParentalHeightObject | undefined;
enableZoom?: boolean;
chartType?: 'centile' | 'sds';
enableExport?: boolean | undefined;
exportChartCallback(svg?: any): any;
clinicianFocus?: boolean | undefined | null;
theme?: 'monochrome' | 'traditional' | 'tanner1' | 'tanner2' | 'tanner3' | 'custom';
height?: number;
width?: number;
logoVariant?: 'top' | 'bottom' | 'legend';
customThemeStyles?: {
chartStyle?: ChartStyle;
axisStyle?: AxisStyle;
gridlineStyle?: GridlineStyle;
measurementStyle?: MeasurementStyle;
centileStyle?: CentileStyle;
sdsStyle?: SDSStyle;
referenceStyle?: ReferenceStyle;
};
}
declare const RCPCHChart: React.FC<RCPCHChartProps>;
export { RCPCHChart };