Skip to content

Commit

Permalink
feat: [CGC-50] Connect Growth Chart Config Percentiles or Z-Scores to…
Browse files Browse the repository at this point in the history
… App (#57)
  • Loading branch information
petterav authored Mar 25, 2024
1 parent 01f30f8 commit 7a278cb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-03-22T20:34:59.747Z\n"
"PO-Revision-Date: 2024-03-22T20:34:59.747Z\n"
"POT-Creation-Date: 2024-03-25T03:31:40.489Z\n"
"PO-Revision-Date: 2024-03-25T03:31:40.489Z\n"

msgid "Date"
msgstr "Date"
Expand Down
3 changes: 3 additions & 0 deletions src/Plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const PluginInner = (propsFromParent: EnrollmentOverviewProps) => {
isWeightInGrams: chartConfig?.settings.weightInGrams || false,
});

const isPercentiles = chartConfig?.settings.usePercentiles || false;

const [open, setOpen] = useState(true);

if (isLoading) {
Expand Down Expand Up @@ -73,6 +75,7 @@ const PluginInner = (propsFromParent: EnrollmentOverviewProps) => {
<GrowthChart
trackedEntity={mappedTrackedEntity}
measurementData={mappedGrowthVariables}
isPercentiles={isPercentiles}
/>
</WidgetCollapsible>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/GrowthChart/GrowthChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import { MappedEntityValues } from '../../utils/DataFetching/Sorting/useMappedTr
interface GrowthChartProps {
trackedEntity: MappedEntityValues;
measurementData: MeasurementData[];
isPercentiles: boolean;
}

export const GrowthChart = ({
trackedEntity,
measurementData,
isPercentiles,
}: GrowthChartProps) => {
const trackedEntityGender = trackedEntity.gender;
const [isPercentiles] = useState<boolean>(false);

const [gender, setGender] = useState<string>(trackedEntityGender !== undefined ? trackedEntityGender : GenderCodes.CGC_Female);
const { chartDataForGender } = useChartDataForGender({ gender });
Expand Down
8 changes: 4 additions & 4 deletions src/utils/Hooks/ChartDataVisualization/useChartLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export const useChartLines = (
startIndex: number,
isPercentiles: boolean,
) => {
const [zScoreLines, setZScoreLines] = useState<any[]>([]);
const [ChartLines, setChartLines] = useState<any[]>([]);

useEffect(() => {
const ZscoreLines = keysDataSet.map((key) => ({
const newChartLines = keysDataSet.map((key) => ({
data: datasetValues.map((entry, index) => ({
x: startIndex + index,
y: entry[key],
Expand All @@ -27,8 +27,8 @@ export const useChartLines = (
label: key,
}));

setZScoreLines(ZscoreLines);
setChartLines(newChartLines);
}, [datasetValues, keysDataSet, datasetMetadata, category, dataset, startIndex, isPercentiles]);

return zScoreLines;
return ChartLines;
};

0 comments on commit 7a278cb

Please sign in to comment.