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:
24
src/utils/categoryColorUtils.ts
Normal file
24
src/utils/categoryColorUtils.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
// 카테고리별 색상 유틸리티 함수
|
||||
|
||||
/**
|
||||
* 카테고리에 따른 일관된 색상을 반환하는 함수
|
||||
* @param category 카테고리 이름
|
||||
* @returns 해당 카테고리의 색상 코드
|
||||
*/
|
||||
export const getCategoryColor = (category: string): string => {
|
||||
// 카테고리 이름 소문자화 및 공백 제거로 일관성 유지
|
||||
const normalizedCategory = category.trim().toLowerCase();
|
||||
|
||||
// 카테고리별 색상 매핑
|
||||
if (normalizedCategory.includes('음식') || normalizedCategory.includes('식비')) {
|
||||
return '#81c784'; // 초록색 (식비)
|
||||
} else if (normalizedCategory.includes('쇼핑') || normalizedCategory.includes('생활비')) {
|
||||
return '#AED581'; // 연한 녹색 (쇼핑/생활비)
|
||||
} else if (normalizedCategory.includes('교통')) {
|
||||
return '#2E7D32'; // 진한 녹색 (교통비)
|
||||
}
|
||||
|
||||
// 기본 색상
|
||||
return '#4CAF50'; // 기본 녹색
|
||||
};
|
||||
Reference in New Issue
Block a user