Skip to content

Commit

Permalink
fix: Builder and useZscoreLines conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
petterav committed Mar 22, 2024
1 parent c4bec57 commit 55cf204
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface GrowthChartBuilderProps extends ChartDataTypes {
category: keyof typeof CategoryToLabel;
dataset: string;
dateOfBirth: Date;
isPercentiles: boolean;
}

export const GrowthChartBuilder = ({
Expand All @@ -25,6 +26,7 @@ export const GrowthChartBuilder = ({
category,
dataset,
dateOfBirth,
isPercentiles,
}: GrowthChartBuilderProps) => {
Chart.register(annotationPlugin);

Expand All @@ -38,7 +40,7 @@ export const GrowthChartBuilder = ({
const adjustIndex = (dataset === DataSetLabels.y_2_5) ? 24 : 0;
const startIndex = (category !== CategoryCodes.wflh_b && category !== CategoryCodes.wflh_g) ? adjustIndex : datasetMetadata.range.start;

const ZscoreLinesData = useZscoreLines(datasetValues, keysDataSet, datasetMetadata, category, dataset, startIndex);
const ZscoreLinesData = useZscoreLines(datasetValues, keysDataSet, datasetMetadata, category, dataset, startIndex, isPercentiles);
const MeasurementData = useMeasurementPlotting(measurementData, MeasuremenCode, category, dataset, dateOfBirth, startIndex);
const data: any = { datasets: [...ZscoreLinesData, ...MeasurementData] };
const annotations = GrowthChartAnnotations(ZscoreLinesData, datasetMetadata);
Expand Down Expand Up @@ -76,12 +78,12 @@ export const GrowthChartBuilder = ({
position: 'right',
min: minDataValue,
max: maxDataValue,
ticks: { padding: 18 },
ticks: { padding: isPercentiles ? 36 : 18 },
},
},
animation: {
onComplete: (chartAnimation: any) => AnnotateLineEnd(chartAnimation),
onProgress: (chartAnimation: any) => AnnotateLineEnd(chartAnimation),
onComplete: (chartAnimation: any) => AnnotateLineEnd(chartAnimation, isPercentiles, keysDataSet),
onProgress: (chartAnimation: any) => AnnotateLineEnd(chartAnimation, isPercentiles, keysDataSet),
},
};

Expand Down
3 changes: 2 additions & 1 deletion src/utils/Hooks/ChartDataVisualization/useZscoreLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const useZscoreLines = (
category: string,
dataset: string | number,
startIndex: number,
isPercentiles: boolean

Check failure on line 15 in src/utils/Hooks/ChartDataVisualization/useZscoreLines.ts

View workflow job for this annotation

GitHub Actions / lint_code

Missing trailing comma
) => {
const [zScoreLines, setZScoreLines] = useState<any[]>([]);

Expand All @@ -22,7 +23,7 @@ export const useZscoreLines = (
y: entry[key],
})),
borderWidth: 0.9,
borderColor: ChartLineColorPicker(key),
borderColor: ChartLineColorPicker(key, isPercentiles),
label: key,
}));

Expand Down

0 comments on commit 55cf204

Please sign in to comment.