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:
@@ -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) // 일관된 색상 적용
|
||||
}));
|
||||
|
||||
// 월별 데이터 생성 - 샘플 데이터 제거하고 현재 달만 실제 데이터 사용
|
||||
|
||||
Reference in New Issue
Block a user