diff --git a/src/pages/ReviewResultPage/components/RadarChart/index.tsx b/src/pages/ReviewResultPage/components/RadarChart/index.tsx index 16da10ab..71075763 100644 --- a/src/pages/ReviewResultPage/components/RadarChart/index.tsx +++ b/src/pages/ReviewResultPage/components/RadarChart/index.tsx @@ -12,8 +12,19 @@ interface RadarChartProps { const RadarChart = ({ answers }: RadarChartProps) => { const { darkMode } = useDarkMode() - const labels = answers.map((answer) => answer.statName) - const data = answers.map((answer) => answer.statScore) + const statGroups = new Map() + + answers.forEach((answer) => { + const statGroup = statGroups.get(answer.statName) + statGroups.set(answer.statName, [...(statGroup || []), answer.statScore]) + }) + + const labels = Array.from(statGroups.keys()) + const data = Array.from(statGroups.values()).map((scores) => { + const average = scores.reduce((acc, cur) => acc + cur, 0) / scores.length + + return Number(average.toFixed(2)) + }) const radarData: ChartData<'radar'> = { labels, @@ -31,6 +42,7 @@ const RadarChart = ({ answers }: RadarChartProps) => { const radarOptions: ChartOptions<'radar'> = { scales: { r: { + suggestedMax: 10, ticks: { stepSize: 10, count: 4,