@@ -42,7 +42,7 @@ import RenderTickLabel from '../SubComponents/RenderTickLabel';
42
42
import { TitleContainer } from '../SubComponents/TitleContainer' ;
43
43
import { StyledRadioButtonGroup } from '../SubComponents/StyledRadioButtonGroup' ;
44
44
import { StyledResetZoomButton } from '../SubComponents/StyledResetZoomButton' ;
45
- import { StyledGradientLabelsButton } from '../SubComponents/StyledGradientLabelsButton' ;
45
+ import { StyledGradientLabelsButton } from '../SubComponents/StyledGradientLabelsButton'
46
46
import { StyledButtonTooltip } from '../SubComponents/StyledButtonTooltip' ;
47
47
import { ButtonContainer } from '../SubComponents/ButtonContainer' ;
48
48
import { ThreeButtonContainer } from '../SubComponents/ThreeButtonContainer' ;
@@ -72,7 +72,10 @@ import icon from '../images/icon.png';
72
72
import ukca from '../images/ukca.png' ;
73
73
74
74
// allows two top level containers: zoom and voronoi
75
- const VictoryZoomVoronoiContainer : any = createContainer ( 'zoom' , 'voronoi' ) ;
75
+ const VictoryZoomVoronoiContainer :any = createContainer (
76
+ 'zoom' ,
77
+ 'voronoi' ,
78
+ ) ;
76
79
77
80
function CentileChart ( {
78
81
chartsVersion,
@@ -90,17 +93,17 @@ function CentileChart({
90
93
textScaleFactor,
91
94
enableExport,
92
95
exportChartCallback,
93
- clinicianFocus,
96
+ clinicianFocus
94
97
} : CentileChartProps ) {
95
98
const [ userDomains , setUserDomains ] = useState ( null ) ;
96
99
97
100
const [ storedChildMeasurements , setStoredChildMeasurements ] = useState ( childMeasurements ) ;
98
101
const { defaultShowCorrected, defaultShowChronological, showToggle } = defaultToggles ( childMeasurements ) ;
99
102
const [ showChronologicalAge , setShowChronologicalAge ] = useState ( defaultShowChronological ) ;
100
103
const [ showCorrectedAge , setShowCorrectedAge ] = useState ( defaultShowCorrected ) ;
101
- const chartRef = useRef < any > ( ) ;
104
+ const chartRef = useRef < any > ( ) ;
102
105
const [ active , setActive ] = useState ( false ) ;
103
- const [ fullScreen , setFullScreen ] = useState ( true ) ;
106
+ const [ fullScreen , setFullScreen ] = useState ( true ) ;
104
107
const [ centileLabels , setCentileLabels ] = useState ( false ) ;
105
108
106
109
// save & destruct domains and data on initial render and when dependencies change
@@ -113,15 +116,15 @@ function CentileChart({
113
116
measurementMethod ,
114
117
reference ,
115
118
showCorrectedAge ,
116
- showChronologicalAge ,
119
+ showChronologicalAge
117
120
) ,
118
121
[ storedChildMeasurements , sex , measurementMethod , reference , showCorrectedAge , showChronologicalAge ] ,
119
122
) ;
120
123
121
124
// get the highest reference index of visible centile data
122
125
let maxVisibleReferenceIndex : number = null ;
123
126
let minimumArrayLength ;
124
- centileData . forEach ( ( item , index ) => {
127
+ centileData . forEach ( ( item , index ) => {
125
128
switch ( index ) {
126
129
case 0 :
127
130
minimumArrayLength = 3 ; // neonates label gap
@@ -158,13 +161,15 @@ function CentileChart({
158
161
pubertyThresholds = makePubertyThresholds ( domains , sex ) ;
159
162
}
160
163
if ( reference === 'uk-who' ) {
161
- nondisjunctionThresholds = makeNonDisjunctionThresholds ( domains , sex ) ;
164
+ nondisjunctionThresholds = makeNonDisjunctionThresholds ( domains , sex )
162
165
}
163
166
164
- const filteredMidParentalHeightData = useMemo (
165
- ( ) => getFilteredMidParentalHeightData ( reference , childMeasurements , midParentalHeightData , sex ) ,
166
- [ reference , childMeasurements , midParentalHeightData , sex ] ,
167
- ) ;
167
+ const filteredMidParentalHeightData = useMemo ( ( ) => getFilteredMidParentalHeightData ( reference , childMeasurements , midParentalHeightData , sex ) , [
168
+ reference ,
169
+ childMeasurements ,
170
+ midParentalHeightData ,
171
+ sex
172
+ ] ) ;
168
173
169
174
// Create the shaded area at term
170
175
let termAreaData : null | any [ ] = null ;
@@ -196,37 +201,34 @@ function CentileChart({
196
201
setActive ( true ) ;
197
202
exportChartCallback ( chartRef . current . firstChild ) ; // this passes the raw SVG back to the client for converting
198
203
}
199
- } ;
204
+ }
200
205
201
206
// label fade on cut
202
207
const labelFadeEnd = ( ) => {
203
208
setActive ( false ) ;
204
- } ;
209
+ }
205
210
206
211
// full screen button action
207
212
const fullScreenPressed = ( ) => {
208
213
setFullScreen ( ! fullScreen ) ;
209
214
fullScreen ? setStoredChildMeasurements ( [ ] ) : setStoredChildMeasurements ( childMeasurements ) ;
210
- } ;
215
+ }
211
216
212
217
// toggle between corrected/uncorrected/both
213
218
const onSelectRadioButton = ( event : MouseEvent < HTMLButtonElement > ) => {
214
219
switch ( ( event . target as HTMLInputElement ) . value ) {
215
220
case 'unadjusted' :
216
221
setShowChronologicalAge ( true ) ;
217
222
setShowCorrectedAge ( false ) ;
218
-
219
223
break ;
220
224
case 'adjusted' :
221
- setShowChronologicalAge ( false ) ;
222
- setShowCorrectedAge ( true ) ;
223
-
224
- break ;
225
+ setShowChronologicalAge ( false ) ;
226
+ setShowCorrectedAge ( true ) ;
227
+ break ;
225
228
case 'both' :
226
- setShowChronologicalAge ( true ) ;
227
- setShowCorrectedAge ( true ) ;
228
-
229
- break ;
229
+ setShowChronologicalAge ( true ) ;
230
+ setShowCorrectedAge ( true ) ;
231
+ break ;
230
232
default :
231
233
console . warn ( 'Fall through case on toggle adjusted age function' ) ;
232
234
}
@@ -239,7 +241,7 @@ function CentileChart({
239
241
240
242
const renderGradientLabels = ( ) => {
241
243
setCentileLabels ( ! centileLabels ) ;
242
- } ;
244
+ }
243
245
244
246
// always reset zoom to default when measurements array changes
245
247
useLayoutEffect ( ( ) => {
@@ -253,9 +255,11 @@ function CentileChart({
253
255
< IndividualLogoContainer >
254
256
< img src = { icon } width = { 24 } height = { 24 } />
255
257
</ IndividualLogoContainer >
256
- < VersionLabel fontFamily = { styles . chartTitle . fontFamily } > { chartsVersion } </ VersionLabel >
258
+ < VersionLabel
259
+ fontFamily = { styles . chartTitle . fontFamily }
260
+ > { chartsVersion } </ VersionLabel >
257
261
< IndividualLogoContainer >
258
- < img src = { ukca } width = { 18 } height = { 18 } />
262
+ < img src = { ukca } width = { 18 } height = { 18 } />
259
263
</ IndividualLogoContainer >
260
264
</ LogoContainer >
261
265
</ TopContainer >
@@ -278,9 +282,7 @@ function CentileChart({
278
282
containerComponent = {
279
283
< VictoryZoomVoronoiContainer
280
284
data-testid = "label-container"
281
- containerRef = { ( ref ) => {
282
- chartRef . current = ref ;
283
- } }
285
+ containerRef = { ref => { chartRef . current = ref } }
284
286
allowZoom = { allowZooming }
285
287
allowPan = { allowZooming }
286
288
onZoomDomainChange = { handleZoomChange }
@@ -296,15 +298,15 @@ function CentileChart({
296
298
datum ,
297
299
midParentalHeightData ,
298
300
clinicianFocus ,
299
- sex ,
300
- ) ;
301
- if ( tooltipTextList ) {
301
+ sex
302
+ )
303
+ if ( tooltipTextList ) {
302
304
return tooltipTextList . join ( '\n' ) . replace ( / ^ \s + | \s + $ / g, '' ) ;
303
- }
305
+ }
304
306
} }
305
307
labelComponent = {
306
308
< VictoryTooltip
307
- data-testid = " tooltip"
309
+ data-testid = ' tooltip'
308
310
constrainToVisibleArea
309
311
backgroundPadding = { 5 }
310
312
pointerLength = { 5 }
@@ -316,23 +318,16 @@ function CentileChart({
316
318
flyoutStyle = { {
317
319
...styles . toolTipFlyout ,
318
320
} }
319
- style = { { ...styles . toolTipMain } }
321
+ style = { { ...styles . toolTipMain } }
320
322
/>
321
323
}
322
- voronoiBlacklist = { [
323
- 'linkLine' ,
324
- 'chronologicalboneagelinkline' ,
325
- 'correctedboneagelinkline' ,
326
- 'areaMPH' ,
327
- ] }
324
+ voronoiBlacklist = { [ 'linkLine' , 'chronologicalboneagelinkline' , 'correctedboneagelinkline' , 'areaMPH' ] }
328
325
/>
329
326
}
330
327
>
331
328
{
332
329
/* Term child shaded area: */
333
- termAreaData !== null && reference == 'uk-who' && (
334
- < VictoryArea style = { styles . termArea } data = { termAreaData } />
335
- )
330
+ termAreaData !== null && reference == "uk-who" && < VictoryArea style = { styles . termArea } data = { termAreaData } />
336
331
}
337
332
338
333
{ /* X axis: */ }
@@ -364,8 +359,7 @@ function CentileChart({
364
359
{ /* Any measurements plotting here are likely due to delayed puberty */ }
365
360
{ /* The upper border is the 0.4th centile so this must come before the centiles */ }
366
361
367
- { reference === 'uk-who' &&
368
- measurementMethod === 'height' &&
362
+ { reference === "uk-who" && measurementMethod === "height" &&
369
363
// delayed puberty area:
370
364
pubertyThresholds !== null && (
371
365
< VictoryArea
@@ -374,24 +368,23 @@ function CentileChart({
374
368
style = { styles . delayedPubertyArea }
375
369
name = "delayed"
376
370
/>
377
- ) }
371
+ )
372
+ }
378
373
379
374
{ /*
380
375
midparental height centiles
381
376
These are three lines, the MPH centile, a centile 2SD above it, and another 2SD below
382
377
There is an area fill between the highest and lowest
383
- */ }
378
+ */
379
+ }
384
380
385
- { ( reference === 'uk-who' || reference === 'cdc' ) &&
386
- measurementMethod === 'height' &&
387
- filteredMidParentalHeightData &&
388
- filteredMidParentalHeightData . map ( ( reference , index ) => {
381
+ { ( reference === "uk-who" || reference === "cdc" ) && measurementMethod === "height" && filteredMidParentalHeightData && filteredMidParentalHeightData . map ( ( reference , index ) => {
389
382
// this function filters the midparental height centile data to only those values
390
383
// one month either side of the most recent measurement, or 20 y if no measurements
391
384
// supplied.
392
- if ( index === 0 ) {
385
+ if ( index === 0 ) {
393
386
// neonates - remove
394
- return ;
387
+ return
395
388
}
396
389
397
390
const lowerData = reference . lowerParentalCentile ;
0 commit comments