Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tooltips-on-safari-bone-age-cropping #106

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rcpch/digital-growth-charts-react-component-library",
"version": "7.0.10",
"version": "7.0.11",
"description": "A React component library for the RCPCH digital growth charts using Rollup, TypeScript and Styled-Components",
"main": "dist/index.js",
"module": "dist/esm.index.js",
Expand Down
40 changes: 22 additions & 18 deletions src/CentileChart/CentileChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,33 +289,39 @@ function CentileChart({
allowPan={allowZooming}
onZoomDomainChange={handleZoomChange}
zoomDomain={domains}
labels={({ datum }) => {
// This the tool tip text, and accepts a large number of arguments
// tool tips return contextual information for each datapoint, as well as the centile
// and SDS lines, as well as bone ages, events and midparental heights
const tooltipTextList = tooltipText(
reference,
measurementMethod,
datum,
midParentalHeightData,
clinicianFocus,
sex
)
if (tooltipTextList){
return tooltipTextList.join('\n').replace(/^\s+|\s+$/g, '');
}
}}
labelComponent={
<VictoryTooltip
data-testid='tooltip'
constrainToVisibleArea
backgroundPadding={5}
pointerLength={5}
cornerRadius={0}
flyoutHeight={(datum) => {
const numberOfLines = datum.text.length;
return numberOfLines * 18; // 18 is the line height
}}
flyoutStyle={{
...styles.toolTipFlyout,
}}
style={{...styles.toolTipMain}}
/>
}
labels={({ datum }) => {
// This the tool tip text, and accepts a large number of arguments
// tool tips return contextual information for each datapoint, as well as the centile
// and SDS lines, as well as bone ages, events and midparental heights
return tooltipText(
reference,
measurementMethod,
datum,
midParentalHeightData,
clinicianFocus,
sex
)
}
}
voronoiBlacklist={['linkLine', 'chronologicalboneagelinkline', 'correctedboneagelinkline', 'areaMPH']}
/>
}
Expand Down Expand Up @@ -688,7 +694,6 @@ function CentileChart({

showChronologicalAge && !showCorrectedAge ?
// Events against chronological age only if corrected age not showing
<VictoryPortal>
<VictoryScatter
key={"item-"+index}
name="eventcaret"
Expand All @@ -700,10 +705,9 @@ function CentileChart({
/>
}
/>
</VictoryPortal>
:
// Events against corrected age
<VictoryPortal>

<VictoryScatter
key={"item-"+index}
name="eventcaret"
Expand All @@ -715,7 +719,7 @@ function CentileChart({
/>
}
/>
</VictoryPortal>

)
}

Expand Down
17 changes: 11 additions & 6 deletions src/functions/getDomainsAndData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { Domains, IDomainSex } from '../interfaces/Domains';

import { IPlottedCentileMeasurement, Reference, ICentile } from '../interfaces/CentilesObject';
import deepCopy from './deepCopy';
import { ClientMeasurementObject } from '../interfaces/ClientMeasurementObject';
import { trisomy21HeightMaleCentileData } from '../chartdata/trisomy21_height_male_centile_data';
import { trisomy21HeightFemaleCentileData } from '../chartdata/trisomy21_height_female_centile_data';
import { trisomy21BMIFemaleCentileData } from '../chartdata/trisomy21_bmi_female_centile_data';
Expand All @@ -31,7 +30,6 @@ import { trisomy21WeightFemaleCentileData } from '../chartdata/trisomy21_weight_
import { trisomy21OFCMaleCentileData } from '../chartdata/trisomy21_ofc_male_centile_data';
import { trisomy21OFCFemaleCentileData } from '../chartdata/trisomy21_ofc_female_centile_data';
import { turnerHeightFemaleCentileData } from '../chartdata/turner_height_female_centile_data';
import { LineSegment } from 'victory';

type CentileLabelValues = {
0.4: { value: number; workingX: number };
Expand Down Expand Up @@ -267,11 +265,8 @@ function childMeasurementRanges(
let chronologicalX = measurement.plottable_data.centile_data.chronological_decimal_age_data.x;
let correctedY = measurement.plottable_data.centile_data.corrected_decimal_age_data.y;
let chronologicalY = measurement.plottable_data.centile_data.chronological_decimal_age_data.y;
const boneAgeX = measurement.bone_age.bone_age;
const errorsPresent = false;
// measurement.measurement_calculated_values.corrected_measurement_error ||
// measurement.measurement_calculated_values.chronological_measurement_error
// ? true
// : false;

if (!errorsPresent) {
if (showCorrected && !showChronological) {
Expand Down Expand Up @@ -299,6 +294,15 @@ function childMeasurementRanges(
lowestChildY = coord;
}
}
// if bone age is present and value is more extreme than the highest or lowest x, update:
if (boneAgeX) {
if (highestChildX < boneAgeX) {
highestChildX = boneAgeX;
}
if (lowestChildX > boneAgeX) {
lowestChildX = boneAgeX;
}
}
} else {
console.warn('Measurements considered invalid by the API given to the chart. The chart will ignore them.');
}
Expand Down Expand Up @@ -596,6 +600,7 @@ function getDomainsAndData(
}
if (errorFree) {
const { lowestChildX, highestChildX, lowestChildY, highestChildY } = childCoordinates;

lowestYFromMeasurements = lowestChildY;
highestYFromMeasurements = highestChildY;
const difference = highestChildX - lowestChildX;
Expand Down
Loading
Loading