rcpch / digital-growth-charts-react-component-library

A typescript React library for displaying RCPCH Digital Growth Charts from API data
https://growth.rcpch.ac.uk
MIT License
7 stars 9 forks source link

Chart not displaying plot points very close together #53

Closed snield1150 closed 1 year ago

snield1150 commented 1 year ago

We have a set of measurements in our test data which don't appear to be rendering properly on the chart. I have reproduced this on your on line demo chart site. I'm not sure whether this behaviour is by design or that it's a rare combination of measurements.

For example: Patient Date of birth = 28/02/2020 Gestation 40w 0d Sex = Male Weight Measurements:

28/02/2023 14 kg 28/02/2022 12.1 kg 28/02/2021 10.3 kg 01/03/2020 3.5 kg 28/02/2020 3.5 kg

So there is a measurement on the child's birth date and another 2 days later. Then 3 subsequent measurements a year apart.

The problem is that it shows the later 3 - albeit as very small points, and doesn't show the first two at all. I can zoom in by scrolling with the mouse wheel but can't see the points.

Given that our users are a mixture of Neonatal, Paediatricians and Dieticians, between them they cover the full range of child ages. So they may, over time, want to see the full history on a chart.

Thanks

snield1150 commented 1 year ago

On reflection, it may not be because the measurements are close together in time, but that as time goes on and further measurements are added, the measurements close to a child's birth date get hidden.

eatyourpeas commented 1 year ago

This is what I see with the measurements you post, is that right? You are right that the measurement at birth is not seen, but the others are. The points are dynamically sized to prevent them crowding and I agree it has not worked well with your use case. There is usually padding either side of the first and last measurement provided. It maybe that when age = 0 this is not happening as expected. If you have any other examples I would be grateful if you could post them and I can have a look.

image
snield1150 commented 1 year ago

Thanks for your reply. Here's another similar scenario. This time not complicating the matter with measurements close together. Just measurements starting at birth and covering > 2 years.

Patient Date of birth = 23/01/2020 Gestation 40w 0d Sex = Male

Weight Measurements: 23/01/2020 3.5 kg 23/03/2020 5.0 kg 23/01/2021 9.0 kg 23/01/2022 12 kg

Here's what the chart looks like (in our app) when just the first 3 are entered. i.e. child is still less than 2 years: image This is showing the 3 points correctly.

and here's what the chart looks like when the 4th measurement is added (on their 2nd birthday): image This is missing the first measurement

If I remove the last measurement and add one for 22/01/2022 - the day before their 2nd birthday - all 4 plot points show OK. Like this: image So it seems the chart is adjusting automatically when the child is 2 years old, but then misses measurements on or close to their date of birth. As you suggest, it's not padding before 0 years, when there are > two years of measurements.

I hope that makes sense.

eatyourpeas commented 1 year ago

Thanks @snield1150 great detective work. There is a bug here in the chart domain calculations - if children are < 4y the padding is set as for a child (as opposed to an infant or neonate) and the lower domain set to 42 weeks, though no check is made here if there are measurements below this. I have applied a fix and this should be published with the next update in week or so together with some other things.

Thanks for identifying this.

snield1150 commented 1 year ago

Hi, could you give me an idea of when this update will be available? Thanks

eatyourpeas commented 1 year ago

Sorry for the delay image I have pushed a patch. Thanks for picking this up.

snield1150 commented 1 year ago

Thanks for this. All updated and looks OK now with the same set of data.