diff --git a/src/__tests__/utils/generateStatsSvg.test.ts b/src/__tests__/utils/generateStatsSvg.test.ts index 8ce86c2..8b3b76e 100644 --- a/src/__tests__/utils/generateStatsSvg.test.ts +++ b/src/__tests__/utils/generateStatsSvg.test.ts @@ -20,7 +20,8 @@ describe('generateStatsSvg 유틸리티 함수 테스트', () => { // 사용자 데이터가 SVG에 포함되어 있는지 확인 expect(result).toContain('testuser'); expect(result).toContain('50'); - expect(result).toContain('200/1000'); + expect(result).toContain('200'); + expect(result).toContain('1000'); expect(result).toContain('20.00%'); expect(result).toContain('5000'); }); diff --git a/src/utils/generateCategorySvg.ts b/src/utils/generateCategorySvg.ts index 52be5f1..de229bb 100644 --- a/src/utils/generateCategorySvg.ts +++ b/src/utils/generateCategorySvg.ts @@ -61,21 +61,31 @@ export function generateCategorySvg(stats: TCategoryStats, theme: Theme = 'light const angleSize = percentage * 360; const endAngle = currentAngle + angleSize; - // 원형 조각 경로 - const startX = pieCenterX + radius * Math.cos((currentAngle - 90) * Math.PI / 180); - const startY = pieCenterY + radius * Math.sin((currentAngle - 90) * Math.PI / 180); - const endX = pieCenterX + radius * Math.cos((endAngle - 90) * Math.PI / 180); - const endY = pieCenterY + radius * Math.sin((endAngle - 90) * Math.PI / 180); - const largeArcFlag = angleSize > 180 ? 1 : 0; - - const path = ` - - `; + let path: string; + + if (angleSize >= 359.99) { + // 100%인 경우 arc 대신 원을 그림 (SVG arc는 시작점==끝점이면 렌더링 안됨) + path = ` + + `; + } else { + // 원형 조각 경로 + const startX = pieCenterX + radius * Math.cos((currentAngle - 90) * Math.PI / 180); + const startY = pieCenterY + radius * Math.sin((currentAngle - 90) * Math.PI / 180); + const endX = pieCenterX + radius * Math.cos((endAngle - 90) * Math.PI / 180); + const endY = pieCenterY + radius * Math.sin((endAngle - 90) * Math.PI / 180); + const largeArcFlag = angleSize > 180 ? 1 : 0; + + path = ` + + `; + } // 퍼센트 라벨 const midAngle = currentAngle + angleSize / 2; @@ -97,7 +107,7 @@ export function generateCategorySvg(stats: TCategoryStats, theme: Theme = 'light legends += ` ${capitalizedName} - ${percentage}% + ${percentage}% `; }); } diff --git a/src/utils/generateStatsSvg.ts b/src/utils/generateStatsSvg.ts index 1b6c85f..5b6b21d 100644 --- a/src/utils/generateStatsSvg.ts +++ b/src/utils/generateStatsSvg.ts @@ -24,6 +24,11 @@ const themes: Record = { export function generateStatsSvg(stats: Tstats, theme: Theme = 'light'): string { const colors = themes[theme]; + const rankParts = stats.wargame_rank.split('/'); + const rankDisplay = rankParts.length === 2 + ? `${rankParts[0]}/${rankParts[1]}` + : `${stats.wargame_rank}`; + return ` @@ -61,7 +67,7 @@ export function generateStatsSvg(stats: Tstats, theme: Theme = 'light'): string Rank - ${stats.wargame_rank} + ${rankDisplay}