@@ -121,6 +121,7 @@ function CentileChart({
121
121
) ,
122
122
[ storedChildMeasurements , sex , measurementMethod , reference , showCorrectedAge , showChronologicalAge ] ,
123
123
) ;
124
+
124
125
125
126
// get the highest reference index of visible centile data
126
127
let maxVisibleReferenceIndex : number = null ;
@@ -143,7 +144,8 @@ function CentileChart({
143
144
minimumArrayLength = 6 ;
144
145
break ;
145
146
}
146
- if ( item [ 0 ] . data . length > minimumArrayLength ) {
147
+
148
+ if ( item [ 0 ] . data !== null && item [ 0 ] . data . length > minimumArrayLength ) {
147
149
maxVisibleReferenceIndex = index ;
148
150
}
149
151
} ) ;
@@ -300,6 +302,7 @@ function CentileChart({
300
302
// This the tool tip text, and accepts a large number of arguments
301
303
// tool tips return contextual information for each datapoint, as well as the centile
302
304
// and SDS lines, as well as bone ages, events and midparental heights
305
+
303
306
const tooltipTextList = tooltipText (
304
307
reference ,
305
308
measurementMethod ,
@@ -336,7 +339,7 @@ function CentileChart({
336
339
337
340
{
338
341
/* Term child shaded area: */
339
- termAreaData !== null && < VictoryArea style = { styles . termArea } data = { termAreaData } />
342
+ termAreaData !== null && reference == "uk-who" && < VictoryArea style = { styles . termArea } data = { termAreaData } />
340
343
}
341
344
342
345
{ /* X axis: */ }
@@ -368,7 +371,7 @@ function CentileChart({
368
371
{ /* Any measurements plotting here are likely due to delayed puberty */ }
369
372
{ /* The upper border is the 0.4th centile so this must come before the centiles */ }
370
373
371
- {
374
+ { reference === "uk-who" && measurementMethod === "height" &&
372
375
// delayed puberty area:
373
376
pubertyThresholds !== null && (
374
377
< VictoryArea
@@ -387,27 +390,37 @@ function CentileChart({
387
390
*/
388
391
}
389
392
390
- { reference === "uk-who" && measurementMethod === "height" && filteredMidParentalHeightData &&
393
+ { ( reference === "uk-who" || reference === "cdc" ) && measurementMethod === "height" && filteredMidParentalHeightData &&
391
394
392
395
filteredMidParentalHeightData . map ( ( reference , index ) => {
393
396
394
397
// this function filters the midparental height centile data to only those values
395
398
// one month either side of the most recent measurement, or 20 y if no measurements
396
399
// supplied.
400
+ if ( index === 0 ) {
401
+ // neonates - remove
402
+ return
403
+ }
397
404
398
405
const lowerData = reference . lowerParentalCentile ;
399
406
const midData = reference . midParentalCentile ;
400
407
const upperData = reference . upperParentalCentile ;
401
408
402
409
return (
403
410
< VictoryGroup key = { 'midparentalCentileDataBlock' + index } >
404
- { upperData . map ( ( centile : ICentile , centileIndex : number ) => {
411
+ {
412
+ upperData . map ( ( centile : ICentile , centileIndex : number ) => {
405
413
// area lower and and upper boundaries
406
414
const newData : any = centile . data . map ( ( data , index ) => {
407
415
let o : any = Object . assign ( { } , data )
408
416
o . y0 = lowerData [ centileIndex ] . data [ index ] . y
409
417
return o ;
410
418
} )
419
+ if ( newData . length < 1 ) {
420
+ // prevents a css `width` infinity error if no data presented to centile line;
421
+ return
422
+ }
423
+
411
424
return (
412
425
< VictoryArea
413
426
name = "areaMPH"
@@ -419,6 +432,10 @@ function CentileChart({
419
432
} )
420
433
}
421
434
{ lowerData . map ( ( lowercentile : ICentile , centileIndex : number ) => {
435
+ if ( lowercentile . data . length < 1 ) {
436
+ // prevents a css `width` infinity error if no data presented to centile line
437
+ return
438
+ }
422
439
return (
423
440
< VictoryLine
424
441
name = "lowerCentileMPH"
@@ -430,6 +447,10 @@ function CentileChart({
430
447
) ;
431
448
} ) }
432
449
{ midData . map ( ( centile : ICentile , centileIndex : number ) => {
450
+ if ( centile . data . length < 1 ) {
451
+ // prevents a css `width` infinity error if no data presented to centile line
452
+ return
453
+ }
433
454
return (
434
455
< VictoryLine
435
456
name = "centileMPH"
@@ -441,6 +462,10 @@ function CentileChart({
441
462
) ;
442
463
} ) }
443
464
{ upperData . map ( ( uppercentile : ICentile , centileIndex : number ) => {
465
+ if ( uppercentile . data . length < 1 ) {
466
+ // prevents a css `width` infinity error if no data presented to centile line
467
+ return
468
+ }
444
469
return (
445
470
< VictoryLine
446
471
name = "upperCentileMPH"
@@ -474,6 +499,14 @@ function CentileChart({
474
499
{ centileData &&
475
500
centileData . map ( ( referenceData , referenceIndex ) => {
476
501
502
+ if ( reference === "cdc" ) {
503
+ if ( referenceIndex === 0 || ( measurementMethod === "ofc" && referenceIndex > 1 ) ) {
504
+ // this is a hack that needs fixing in future. It arrises because of the null data in the CDC neonate dataset (Fenton). Once the data is fixed, this can be removed. Only for weight is renders a line in the under ones.
505
+ // it also removes the duplicate tooltips in the head circumference chart
506
+ return
507
+ }
508
+ }
509
+
477
510
return (
478
511
< VictoryGroup
479
512
key = { 'centileDataBlock' + referenceIndex }
@@ -484,14 +517,14 @@ function CentileChart({
484
517
485
518
// BMI charts also have SDS lines at -5, -4, -3, -2, 2, 3, 4, 5
486
519
487
- if ( centile . data . length < 1 ) {
520
+ if ( centile . data !== null && centile . data . length < 1 ) {
488
521
// prevents a css `width` infinity error if no data presented to centile line
489
522
return
490
523
}
491
524
492
- if ( centileIndex % 2 === 0 ) {
525
+ if ( centileIndex % 2 ) {
493
526
// even index - centile is dashed
494
-
527
+
495
528
return (
496
529
< VictoryLine
497
530
data-testid = { 'reference-' + referenceIndex + '-centile-' + centile . centile + '-measurement-' + measurementMethod }
@@ -557,7 +590,7 @@ function CentileChart({
557
590
558
591
{
559
592
/* BMI SDS lines */
560
- measurementMethod === "bmi" && bmiSDSData &&
593
+ measurementMethod === "bmi" && bmiSDSData && reference === "uk-who" && // only render for UK-WHO BMI charts since other references do not have SDS lines
561
594
bmiSDSData . map ( ( sdsReferenceData , index ) => {
562
595
return (
563
596
< VictoryGroup
0 commit comments