Fix: Match chart colors to category list

Updated the expense chart to use the same colors as the category spending list for 음식, 쇼핑, and 교통비.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-21 11:49:00 +00:00
parent 40ddcee1da
commit cb29d6fe69
4 changed files with 30 additions and 19 deletions

View File

@@ -1,4 +1,3 @@
import React, { useState, useEffect } from 'react';
import NavBar from '@/components/NavBar';
import ExpenseChart from '@/components/ExpenseChart';
@@ -6,6 +5,7 @@ import AddTransactionButton from '@/components/AddTransactionButton';
import { useBudget } from '@/contexts/BudgetContext';
import { MONTHS_KR } from '@/hooks/useTransactions';
import { useIsMobile } from '@/hooks/use-mobile';
import { getCategoryColor } from '@/utils/categoryColorUtils';
// 새로 분리한 컴포넌트들 불러오기
import PeriodSelector from '@/components/analytics/PeriodSelector';
@@ -78,14 +78,12 @@ const Analytics = () => {
const savings = Math.max(0, totalBudget - totalExpense);
const savingsPercentage = totalBudget > 0 ? Math.round(savings / totalBudget * 100) : 0;
// 카테고리별 지출 차트 데이터 생성
// 카테고리별 지출 차트 데이터 생성 - 색상 유틸리티 사용
const categorySpending = getCategorySpending();
const expenseData = categorySpending.map(category => ({
name: category.title,
value: category.current,
color: category.title === '식비' ? '#81c784' :
category.title === '생활비' ? '#AED581' :
category.title === '교통비' ? '#2E7D32' : '#4CAF50'
color: getCategoryColor(category.title) // 일관된 색상 적용
}));
// 월별 데이터 생성 - 샘플 데이터 제거하고 현재 달만 실제 데이터 사용