260209_01_ENH: 테이블에 단위 텍스트 추가, 하단 설명 추가

This commit is contained in:
2026-02-09 16:28:29 +09:00
parent b7282bd07d
commit 6e6120f205
21 changed files with 249 additions and 173 deletions

View File

@@ -1,6 +1,7 @@
"use client"; "use client";
import { import {
BottomDescription,
GroupedOverlayBar, GroupedOverlayBar,
type GroupedOverlayBarData, type GroupedOverlayBarData,
signStyleGapRow, signStyleGapRow,
@@ -39,6 +40,7 @@ const LGPenetrationPage = () => {
const productTableRows = useMemo<TopChartTableRow[]>(() => { const productTableRows = useMemo<TopChartTableRow[]>(() => {
return apiOwnShareOfTotalPenetration.map((row) => ({ return apiOwnShareOfTotalPenetration.map((row) => ({
label: formatRowLabel(row.rowLabel), label: formatRowLabel(row.rowLabel),
total: row.total,
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null), values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
})); }));
}, []); }, []);
@@ -103,6 +105,12 @@ const LGPenetrationPage = () => {
}); });
}, []); }, []);
const description = useMemo(() => {
return "Q. 다음 중 귀댁에서 보유하고 계신 가전/전자 제품은 무엇입니까? 모두 선택해주세요.<br/>" +
"* 구독/렌탈/선물/경품/아파트 내 빌트인 제품을 모두 포함하여 선택해주세요.<br/>" +
"Q. 보유하고 계신 (제품)의 브랜드는 어떻게 되십니까?";
}, []);
useEffect(() => { useEffect(() => {
registerExcelExporter(async () => { registerExcelExporter(async () => {
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP); const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP);
@@ -152,6 +160,8 @@ const LGPenetrationPage = () => {
signStyle={signStyleGapRow} signStyle={signStyleGapRow}
/> />
<BottomDescription description={description} />
<LifeStageDiv lifeStageRowsByGroup={lifeStageRowsByGroup} /> <LifeStageDiv lifeStageRowsByGroup={lifeStageRowsByGroup} />
</div> </div>
); );

View File

@@ -23,6 +23,7 @@ const LGPurchasePage = () => {
const purchaseTableRows = useMemo<TopChartTableRow[]>(() => { const purchaseTableRows = useMemo<TopChartTableRow[]>(() => {
return apiOwnShareOfTotalPurchase.map((row) => ({ return apiOwnShareOfTotalPurchase.map((row) => ({
label: formatRowLabel(row.rowLabel), label: formatRowLabel(row.rowLabel),
total: row.total,
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null), values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
})); }));
}, []); }, []);
@@ -65,6 +66,16 @@ const LGPurchasePage = () => {
}; };
}, []); }, []);
const description = useMemo(() => {
return "Q. 다음 중 귀댁에서 보유하고 계신 가전/전자 제품은 무엇입니까? 모두 선택해주세요.<br/>" +
"* 구독/렌탈/선물/경품/아파트 내 빌트인 제품을 모두 포함하여 선택해주세요.<br/>" +
"Q. 보유하고 계신 (제품)을 언제 구입하셨습니까?<br/>" +
"* 새 상품을 선물 받은 경우, 선물 받은 연도로 입력해주세요.<br/>" +
"** 중고 제품인 경우, 중고 제품을 구입한 연도로 입력해주세요.<br/>" +
"*** 신규 입주 시 빌트인되어 있던 제품은 입주한 연도를 입력해주세요.<br/>" +
"Q. 보유하고 계신 (제품)의 브랜드는 어떻게 되십니까?";
}, []);
useEffect(() => { useEffect(() => {
registerExcelExporter(async () => { registerExcelExporter(async () => {
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP); const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP);

View File

@@ -8,7 +8,7 @@ import {
GroupedStackBar, GroupedStackBar,
signStyleGapRow, signStyleGapRow,
type TopChartTableRow, type TopChartTableRow,
type GroupedStackBarData, type GroupedStackBarData, BottomDescription,
} from "@/components/lge-dashboard"; } from "@/components/lge-dashboard";
import { useLayoutFilter } from "@/components/layout/LayoutFilterContext"; import { useLayoutFilter } from "@/components/layout/LayoutFilterContext";
import {apiBrandByYearCategories, apiTrendCategories} from "@/config/sample.data"; import {apiBrandByYearCategories, apiTrendCategories} from "@/config/sample.data";
@@ -33,6 +33,7 @@ const PenetrationPage = () => {
const productTableRows = useMemo<TopChartTableRow[]>(() => { const productTableRows = useMemo<TopChartTableRow[]>(() => {
return apiTrendCategories.map((row) => ({ return apiTrendCategories.map((row) => ({
label: formatRowLabel(row.rowLabel), label: formatRowLabel(row.rowLabel),
total: row.total,
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null), values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
})); }));
}, []); }, []);
@@ -71,6 +72,15 @@ const PenetrationPage = () => {
return { categories: PRODUCTS, years: YEARS, brands: BRAND_LIST, values }; return { categories: PRODUCTS, years: YEARS, brands: BRAND_LIST, values };
}, []); }, []);
const description = useMemo(() => {
if(isBrandShare){
return "Q. 보유하고 계신 (제품)의 브랜드는 어떻게 되십니까?";
}
return "Q. 다음 중 귀댁에서 보유하고 계신 가전/전자 제품은 무엇입니까? 모두 선택해주세요.<br/>" +
"* 구독/렌탈/선물/경품/아파트 내 빌트인 제품을 모두 포함하여 선택해주세요.";
}, [isBrandShare]);
useEffect(() => { useEffect(() => {
registerExcelExporter(async () => { registerExcelExporter(async () => {
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP); const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP);
@@ -140,7 +150,9 @@ const PenetrationPage = () => {
) )
} }
signStyle={signStyleGapRow} signStyle={signStyleGapRow}
fillCAGR={true}
/> />
<BottomDescription description={description} />
</div> </div>
); );
}; };

View File

@@ -10,6 +10,7 @@ import {
SITE_TITLE SITE_TITLE
} from "@/const/lgConst"; } from "@/const/lgConst";
import { import {
BottomDescription,
type ChartData, type ChartData,
signStyleGapRow, signStyleGapRow,
TopChartTable, TopChartTable,
@@ -28,6 +29,7 @@ const PurchasePage = () => {
const purchaseTableRows = useMemo<TopChartTableRow[]>(() => { const purchaseTableRows = useMemo<TopChartTableRow[]>(() => {
return apiTrendBuy.map((row) => ({ return apiTrendBuy.map((row) => ({
label: formatRowLabel(row.rowLabel), label: formatRowLabel(row.rowLabel),
total: row.total,
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null), values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
})); }));
}, []); }, []);
@@ -44,6 +46,15 @@ const PurchasePage = () => {
}; };
}, []); }, []);
const description = useMemo(() => {
return "Q. 다음 중 귀댁에서 보유하고 계신 가전/전자 제품은 무엇입니까? 모두 선택해주세요.<br/>" +
"* 구독/렌탈/선물/경품/아파트 내 빌트인 제품을 모두 포함하여 선택해주세요.<br/>" +
"Q. 보유하고 계신 (제품)을 언제 구입하셨습니까?<br/>" +
"* 새 상품을 선물 받은 경우, 선물 받은 연도로 입력해주세요.<br/>" +
"** 중고 제품인 경우, 중고 제품을 구입한 연도로 입력해주세요.<br/>" +
"*** 신규 입주 시 빌트인되어 있던 제품은 입주한 연도를 입력해주세요.";
}, []);
useEffect(() => { useEffect(() => {
registerExcelExporter(async () => { registerExcelExporter(async () => {
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP); const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP);
@@ -78,6 +89,8 @@ const PurchasePage = () => {
} }
signStyle={signStyleGapRow} signStyle={signStyleGapRow}
/> />
<BottomDescription description={description} />
</div> </div>
); );
}; };

View File

@@ -31,7 +31,7 @@ const buildDefaultTotalValue = (): SelectedMap => {
return init; return init;
}; };
export const buildDefaultCategoryValue = (categoryFilterItems: ProductsFilterItem): CategoryFilterValue => { const buildDefaultCategoryValue = (categoryFilterItems: ProductsFilterItem): CategoryFilterValue => {
const initProduct = categoryFilterItems.items[0]; const initProduct = categoryFilterItems.items[0];
const initType = {label:"보유", value:CategoryTargetType.PENETRATION} const initType = {label:"보유", value:CategoryTargetType.PENETRATION}
const firstTarget = categoryTarget.find((x) => x.type.includes(initType.value))?.children?.[0]?.target; const firstTarget = categoryTarget.find((x) => x.type.includes(initType.value))?.children?.[0]?.target;
@@ -45,6 +45,12 @@ export const buildDefaultCategoryValue = (categoryFilterItems: ProductsFilterIte
}; };
}; };
const buildTotalPartDescription = (pathname:string) => {
return pathname.match("penetration")
? "■ 보급률: 전체 소비자 중, 조사 년도에 해당 제품을 <strong>보유하고 있는 비율</strong>"
: "■ 구매율: 전체 소비자 중, 조사 년도에 해당 제품을 <strong>구매한 비율</strong>";
}
const MainLayout = ({ children }: MainLayoutProps) => { const MainLayout = ({ children }: MainLayoutProps) => {
const router = useRouter(); const router = useRouter();
const pathname = usePathname(); const pathname = usePathname();
@@ -62,6 +68,7 @@ const MainLayout = ({ children }: MainLayoutProps) => {
const isFilterOpen = isTotal ? isTotalFilterOpen : isCategoryFilterOpen; const isFilterOpen = isTotal ? isTotalFilterOpen : isCategoryFilterOpen;
const categoryFilterItems = PRODUCTS_FILTER_ITEM.find((m) => pathname.match?.(m.path)) ?? PRODUCTS_FILTER_ITEM[0]; const categoryFilterItems = PRODUCTS_FILTER_ITEM.find((m) => pathname.match?.(m.path)) ?? PRODUCTS_FILTER_ITEM[0];
const totalPartDescription = buildTotalPartDescription(pathname);
const [totalValue, setTotalValue] = useState<SelectedMap>(() => buildDefaultTotalValue()); const [totalValue, setTotalValue] = useState<SelectedMap>(() => buildDefaultTotalValue());
const [categoryValue, setCategoryValue] = useState<CategoryFilterValue>(() => buildDefaultCategoryValue(categoryFilterItems)); const [categoryValue, setCategoryValue] = useState<CategoryFilterValue>(() => buildDefaultCategoryValue(categoryFilterItems));
@@ -137,16 +144,15 @@ const MainLayout = ({ children }: MainLayoutProps) => {
type="button" type="button"
onClick={toggleFilter} onClick={toggleFilter}
className={cn( className={cn(
"inline-flex items-center gap-2 font-semibold text-gray-900 content-text-sm", "inline-flex items-center gap-2 font-semibold text-gray-900 content-text-sm cursor-pointer",
"select-none" "select-none"
)} )}
> >
<Filter className="h-4 w-4 fill-[hsl(var(--lg-gray-500))] stroke-[hsl(var(--lg-gray-500))]" /> <Filter className="h-4 w-4 fill-[hsl(var(--lg-gray-500))] stroke-[hsl(var(--lg-gray-500))]" />
필터 <span className="text-sm leading-none">{isFilterOpen ? "▲" : "▼"}</span> 필터 <span className="text-sm leading-none mb-1">{isFilterOpen ? "▲" : "▼"}</span>
</button> </button>
{isTotal && ( {isTotal && (
<div className={"ml-5 content-text-sm"}> <div className={"ml-5 content-text-sm"} dangerouslySetInnerHTML={{__html: totalPartDescription}}>
페이지에 대한 설명
</div> </div>
)} )}
</div> </div>

View File

@@ -0,0 +1,8 @@
const BottomDescription = ({description}:{description:string}) => {
return (
<div className="content-text-sm mt-2" dangerouslySetInnerHTML={{__html: description}}>
</div>
);
}
export default BottomDescription;

View File

@@ -1,6 +1,6 @@
const SectionTitle = ({title}:{title:string}) => { const SectionTitle = ({title}:{title:string}) => {
return ( return (
<div className="mb-2 font-semibold flex items-center gap-2"> <div className="font-semibold flex items-center gap-2">
<span className="w-3 h-3 bg-primary" /> <span className="w-3 h-3 bg-primary" />
{title} {title}
</div> </div>

View File

@@ -1,12 +1,12 @@
import {ChartData, DataColumn, DataTable, HorizontalBar, LeftChartTable, SignStyle} from "@/components/lge-dashboard"; import {ChartData, DataColumn, DataTable, HorizontalBar, LeftChartTable, SignStyle} from "@/components/lge-dashboard";
import {BannerKey, ServerBannerRow} from "@/types/lg"; import {BannerKey, ServerBannerRow} from "@/types/lg";
import {formatRowLabel, wrapSampleRow} from "@/lib/lg-dashboard"; import {formatRowLabel, isGapRow, wrapSampleRow} from "@/lib/lg-dashboard";
import {useEffect, useMemo} from "react"; import {useEffect, useMemo} from "react";
import { import {
BANNER_GROUP, BANNER_GROUP,
BANNER_KEY_MAP, BANNER_KEY_MAP,
GRID_Y_NOT_PADDING, GRID_Y_NOT_PADDING,
SAMPLE_SIZE_NOTICE, SITE_TITLE, SITE_TITLE,
} from "@/const/lgConst"; } from "@/const/lgConst";
import {parseNumber} from "@/lib/utils"; import {parseNumber} from "@/lib/utils";
import { import {
@@ -27,7 +27,7 @@ type SectionSpec = {
/** 3개 섹션(테이블)도 여기서만 선언 */ /** 3개 섹션(테이블)도 여기서만 선언 */
const SECTIONS: SectionSpec[] = [ const SECTIONS: SectionSpec[] = [
{ title: "가구 형태", groupKeys: ["lifeStage", "household", "age"] }, { title: "가구 형태", groupKeys: ["lifeStage", "household", "age"] },
{ title: "거주 형태", groupKeys: ["tenure", "housing", "pyeong"] }, { title: "거주 형태", groupKeys: ["occupancy", "housing", "houseSize"] },
{ title: "거주 지역 및 소득 수준", groupKeys: ["region", "income"] }, { title: "거주 지역 및 소득 수준", groupKeys: ["region", "income"] },
]; ];
@@ -105,7 +105,7 @@ const BannerSummary = ({ data, useChart, useYear }: BannerSummaryProps) => {
}; };
const signStyleGap: SignStyle<ServerBannerRow> = { const signStyleGap: SignStyle<ServerBannerRow> = {
rowSelector: (row) => row.rowLabel === "gap", rowSelector: (row) => isGapRow(row.rowLabel),
display: "arrow", display: "arrow",
arrowWithNumber: true, arrowWithNumber: true,
paint: "text", paint: "text",
@@ -121,7 +121,12 @@ const BannerSummary = ({ data, useChart, useYear }: BannerSummaryProps) => {
const columns = buildColumns(spec, useYear? filterValue.year : ""); const columns = buildColumns(spec, useYear? filterValue.year : "");
// rows가 spec마다 다르면 여기서 가져오도록 구성 // rows가 spec마다 다르면 여기서 가져오도록 구성
const rows = wrapSampleRow(useYear? data.filter((d) => d.year === filterValue.year) : data); const rows =
wrapSampleRow(useYear? data.filter((d) => d.year === filterValue.year) : data)
.map((row) => {
row.rowLabel = formatRowLabel(row.rowLabel);
return row
})
const chartData = buildChartData(rows, bannerKeys); const chartData = buildChartData(rows, bannerKeys);
return { return {
@@ -197,7 +202,6 @@ const BannerSummary = ({ data, useChart, useYear }: BannerSummaryProps) => {
starUnder30Sample={true} starUnder30Sample={true}
/> />
} }
<div className="float-right content-text-sm">{SAMPLE_SIZE_NOTICE}</div>
</div> </div>
); );
})} })}

View File

@@ -7,15 +7,15 @@ import {
} from "@/components/lge-dashboard"; } from "@/components/lge-dashboard";
import BannerButtons from "@/components/lge-dashboard/BannerButtons"; import BannerButtons from "@/components/lge-dashboard/BannerButtons";
import {totalFilters} from "@/config/filter.data"; import {totalFilters} from "@/config/filter.data";
import {useEffect, useMemo, useState} from "react"; import React, {useMemo, useState} from "react";
import {BannerGroupKey, CategoryChartMode, ServerBannerRow} from "@/types/lg"; import {BannerGroupKey, CategoryChartMode, ServerBannerRow} from "@/types/lg";
import { import {
buildRowLabelSeriesChartData, buildRowLabelSeriesChartData,
buildYearSeriesChartData, buildYearSeriesChartData, formatRowLabel,
isBannerGroupKey, isBannerGroupKey, isGapRow,
wrapSampleRow wrapSampleRow
} from "@/lib/lg-dashboard"; } from "@/lib/lg-dashboard";
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, SAMPLE_SIZE_NOTICE} from "@/const/lgConst"; import {BANNER_GROUP, BANNER_KEY_MAP, GAP_WORDING, SAMPLE_SIZE_NOTICE, UNIT_TEXT} from "@/const/lgConst";
import {createDefaultGrid, createDefaultLegend, reverseCategories} from "@/lib/chart-options"; import {createDefaultGrid, createDefaultLegend, reverseCategories} from "@/lib/chart-options";
type CategoryByDataProps = { type CategoryByDataProps = {
@@ -26,6 +26,7 @@ type CategoryByDataProps = {
fillGreaterThan5?: boolean; fillGreaterThan5?: boolean;
chartHeight?: number; chartHeight?: number;
chartWidth?: number; chartWidth?: number;
unitText?: string;
} }
const banners: bannerType[] = totalFilters.map((filter) => { const banners: bannerType[] = totalFilters.map((filter) => {
@@ -33,7 +34,7 @@ const banners: bannerType[] = totalFilters.map((filter) => {
}) })
const signStyleGap: SignStyle<ServerBannerRow> = { const signStyleGap: SignStyle<ServerBannerRow> = {
rowSelector: (row) => row.rowLabel === "gap", rowSelector: (row) => isGapRow(row.rowLabel),
display: "arrow", display: "arrow",
arrowWithNumber: true, arrowWithNumber: true,
paint: "text", paint: "text",
@@ -48,6 +49,7 @@ const CategoryByData = ({
fillGreaterThan5, fillGreaterThan5,
chartHeight, chartHeight,
chartWidth, chartWidth,
unitText = UNIT_TEXT,
}: CategoryByDataProps) => { }: CategoryByDataProps) => {
const [selectedBanner, setSelectedBanner] = useState<bannerType>(banners[0]); const [selectedBanner, setSelectedBanner] = useState<bannerType>(banners[0]);
@@ -93,11 +95,20 @@ const CategoryByData = ({
return isBannerGroupKey(v) ? buildColumns(v, selectedYear) : []; return isBannerGroupKey(v) ? buildColumns(v, selectedYear) : [];
}, [selectedBanner.variable, selectedYear]); }, [selectedBanner.variable, selectedYear]);
const tableData = useMemo(() => wrapSampleRow(allTableData).filter((row) => row.year === selectedYear), [allTableData, selectedYear]); const tableData = useMemo(() =>
wrapSampleRow(allTableData)
.filter((row) => row.year === selectedYear)
.map((row) => {
row.rowLabel = formatRowLabel(row.rowLabel);
return row
})
, [allTableData, selectedYear]);
return ( return (
<div> <div>
{title && <SectionTitle title={title} />} <div className="mb-2 flex items-center pr-6">
{title ? <SectionTitle title={title} /> : <div />}
</div>
<div className="flex gap-6 p-3"> <div className="flex gap-6 p-3">
<div className="flex-shrink-0" style={{ width: `${chartWidth ?? 400}px`}}> <div className="flex-shrink-0" style={{ width: `${chartWidth ?? 400}px`}}>
{ {
@@ -132,13 +143,11 @@ const CategoryByData = ({
columns={tableColumns} columns={tableColumns}
rows={tableData} rows={tableData}
signStyle={signStyleGap} signStyle={signStyleGap}
wrapperClassName="border rounded-lg"
fillGreaterThan5={fillGreaterThan5} fillGreaterThan5={fillGreaterThan5}
starUnder30Sample={true} starUnder30Sample={true}
/> />
</div> </div>
</div> </div>
<div className="float-right content-text-sm">{SAMPLE_SIZE_NOTICE}</div>
</div> </div>
); );
}; };

View File

@@ -6,6 +6,7 @@ import type { DataColumn, SignStyle } from "../types";
import SectionTitle from "../SectionTitle"; import SectionTitle from "../SectionTitle";
import { TABLE_DIMENSIONS } from "@/const/chartConst"; import { TABLE_DIMENSIONS } from "@/const/chartConst";
import {isSampleRow} from "@/lib/lg-dashboard"; import {isSampleRow} from "@/lib/lg-dashboard";
import {SAMPLE_SIZE_NOTICE, UNIT_TEXT} from "@/const/lgConst";
type MergedChartCell<T> = { type MergedChartCell<T> = {
/** 차트를 삽입할 컬럼 key(해당 컬럼 td는 startRow에서만 렌더되고 rowSpan 적용) */ /** 차트를 삽입할 컬럼 key(해당 컬럼 td는 startRow에서만 렌더되고 rowSpan 적용) */
@@ -34,6 +35,7 @@ type Props<T extends Record<string, unknown>> = {
tableClassName?: string; tableClassName?: string;
minWidthPx?: number; minWidthPx?: number;
starUnder30Sample?: boolean; starUnder30Sample?: boolean;
unitText?: string;
}; };
// toNumber는 utils.ts의 parseNumber로 통합됨 // toNumber는 utils.ts의 parseNumber로 통합됨
@@ -67,7 +69,8 @@ export default function LeftChartTable<T extends Record<string, unknown>>({
wrapperClassName, wrapperClassName,
tableClassName, tableClassName,
minWidthPx = TABLE_DIMENSIONS.MIN_WIDTH.COMPACT, minWidthPx = TABLE_DIMENSIONS.MIN_WIDTH.COMPACT,
starUnder30Sample = true starUnder30Sample = true,
unitText = UNIT_TEXT,
}: Props<T>) { }: Props<T>) {
const hasGroupHeader = useMemo( const hasGroupHeader = useMemo(
() => columns.some((c) => c.group) || columns.some((c) => c.headRowSpan === 2), () => columns.some((c) => c.group) || columns.some((c) => c.headRowSpan === 2),
@@ -137,9 +140,16 @@ export default function LeftChartTable<T extends Record<string, unknown>>({
return ( return (
<div className={cn("w-full", wrapperClassName)}> <div className={cn("w-full", wrapperClassName)}>
{title && ( <div className="mb-2 flex items-center justify-between">
<SectionTitle title={title} /> { title && <SectionTitle title={title} />}
)} {
(unitText || starUnder30Sample) &&
<div className="ml-auto text-gray-500 content-text-xs font-semibold text-right">
{unitText}
{starUnder30Sample && <><br/>{SAMPLE_SIZE_NOTICE}</>}
</div>
}
</div>
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table className={cn("lg-table", tableClassName)} style={{ minWidth: `${minWidthPx}px` }}> <table className={cn("lg-table", tableClassName)} style={{ minWidth: `${minWidthPx}px` }}>

View File

@@ -1,6 +1,8 @@
import GaugeCardTable from "./GaugeCardTable"; import GaugeCardTable from "./GaugeCardTable";
import {LIFE_STAGE_COLUMNS} from "@/const/lgConst"; import {LIFE_STAGE_COLUMNS, UNIT_TEXT} from "@/const/lgConst";
import {LifeStageGroup} from "@/types/lg"; import {LifeStageGroup} from "@/types/lg";
import SectionTitle from "../SectionTitle";
import React from "react";
type lifeStageDivProps = { type lifeStageDivProps = {
lifeStageRowsByGroup:LifeStageGroup[]; lifeStageRowsByGroup:LifeStageGroup[];
@@ -10,11 +12,10 @@ type lifeStageDivProps = {
const LifeStageDiv = ({lifeStageRowsByGroup}:lifeStageDivProps) => { const LifeStageDiv = ({lifeStageRowsByGroup}:lifeStageDivProps) => {
return ( return (
<div className="mt-6"> <div className="mt-6">
<div className="flex justify-between text-muted-foreground mb-5"> <SectionTitle title={"LG 가전 보급률 기준 라이프스테이지별 기회 영역"} />
<div className=" content-text-xs">
* 하위 테이블들에 대한 설명 <div className="flex justify-end text-muted-foreground mb-5">
</div> <div className="flex justify-end gap-4 content-text-xs">
<div className="flex justify-end gap-6 content-text-xs">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span className="inline-block h-4 w-8 border bg-gray-200 border-gray-300"/> <span className="inline-block h-4 w-8 border bg-gray-200 border-gray-300"/>
<span>제품 보유율</span> <span>제품 보유율</span>
@@ -27,6 +28,9 @@ const LifeStageDiv = ({lifeStageRowsByGroup}:lifeStageDivProps) => {
/> />
<span>시장 기회공간</span> <span>시장 기회공간</span>
</div> </div>
<div className="flex items-center gap-2">
{UNIT_TEXT}
</div>
</div> </div>
</div> </div>

View File

@@ -5,18 +5,20 @@ import { cn, parseNumber } from "@/lib/utils";
import type { ChartData, SignStyle, TopChartTableRow } from "../types"; import type { ChartData, SignStyle, TopChartTableRow } from "../types";
import SectionTitle from "../SectionTitle"; import SectionTitle from "../SectionTitle";
import { CHART_HEIGHTS, TABLE_DIMENSIONS } from "@/const/chartConst"; import { CHART_HEIGHTS, TABLE_DIMENSIONS } from "@/const/chartConst";
import {UNIT_TEXT} from "@/const/lgConst";
import {isCagrRow} from "@/lib/lg-dashboard";
type BaseProps = { export type TopChartTableProps = {
title?: string; title?: string;
categories: string[];
rows: TopChartTableRow[];
/** 테이블 상단(헤더 1행) 콜스팬 셀 내부에 렌더될 차트 */ /** 테이블 상단(헤더 1행) 콜스팬 셀 내부에 렌더될 차트 */
chart?: chart?:
| React.ReactNode | React.ReactNode
| ((ctx: { | ((ctx: {
/** 테이블 컬럼(=x축) 기준으로 구성된 ChartData */ /** 테이블 컬럼(=x축) 기준으로 구성된 ChartData */
chartData: ChartData; chartData: ChartData;
tableCategories: string[]; }) => React.ReactNode);
tableRows: TopChartTableRow[];
}) => React.ReactNode);
/** chart 셀 높이(px) */ /** chart 셀 높이(px) */
chartHeight?: number; chartHeight?: number;
/** 가로 스크롤 min-width */ /** 가로 스크롤 min-width */
@@ -25,31 +27,9 @@ type BaseProps = {
wrapperClassName?: string; wrapperClassName?: string;
/** +/-/0 색상/표기 옵션(선택) */ /** +/-/0 색상/표기 옵션(선택) */
signStyle?: SignStyle<TopChartTableRow>; signStyle?: SignStyle<TopChartTableRow>;
fillCAGR?: boolean;
unitText?: string;
}; };
/**
* 1) (신규) HTML 형태: columns=categories, rows=TopChartTableRow
*/
type HtmlModeProps = BaseProps & {
categories: string[];
rows: TopChartTableRow[];
};
/**
* 2) (호환) 기존 형태: ChartData 기반으로 rows/columns 자동 생성
* - rows = data.categories
* - cols = data.series.name
*/
type ChartDataModeProps = BaseProps & {
data: ChartData;
/** 좌측 rowhead 컬럼 헤더 */
categoryHeader?: string;
/** 값 표기 포맷터 */
valueFormatter?: (v: number) => string;
};
export type TopChartTableProps = HtmlModeProps | ChartDataModeProps;
// toNumber는 utils.ts의 parseNumber로 통합됨 // toNumber는 utils.ts의 parseNumber로 통합됨
function formatSignedNumber(n: number, zeroText: string, showPlus: boolean) { function formatSignedNumber(n: number, zeroText: string, showPlus: boolean) {
@@ -68,12 +48,16 @@ function toCellValue(v: unknown): CellValue {
export default function TopChartTable(props: TopChartTableProps) { export default function TopChartTable(props: TopChartTableProps) {
const { const {
title, title,
rows,
categories,
chart, chart,
chartHeight = CHART_HEIGHTS.DEFAULT, chartHeight = CHART_HEIGHTS.DEFAULT,
minWidthPx = TABLE_DIMENSIONS.MIN_WIDTH.STANDARD, minWidthPx = TABLE_DIMENSIONS.MIN_WIDTH.STANDARD,
tableClassName, tableClassName,
wrapperClassName, wrapperClassName,
signStyle, signStyle,
fillCAGR = false,
unitText = UNIT_TEXT
} = props; } = props;
const display = signStyle?.display ?? "number"; const display = signStyle?.display ?? "number";
@@ -83,63 +67,40 @@ export default function TopChartTable(props: TopChartTableProps) {
const negCls = signStyle?.negativeTextClassName ?? "lg-num-neg"; const negCls = signStyle?.negativeTextClassName ?? "lg-num-neg";
const zeroText = signStyle?.zeroText ?? "-"; const zeroText = signStyle?.zeroText ?? "-";
const { categories, rows, rowHeadHeader, valueFormatter } = useMemo(() => {
if ("data" in props) {
const d = props.data;
const tableRows: TopChartTableRow[] = d.categories.map((cat, i) => ({
label: String(cat ?? ""),
values: d.series.map((s) => toCellValue(s.data[i] ?? null)),
}));
return {
categories: d.series.map((s) => s.name),
rows: tableRows,
rowHeadHeader: props.categoryHeader ?? "",
valueFormatter: props.valueFormatter,
};
}
return {
categories: props.categories,
rows: props.rows,
rowHeadHeader: "",
valueFormatter: undefined,
};
}, [props]);
// 테이블 컬럼(=categories)을 x축으로 사용하는 chartData를 항상 제공 // 테이블 컬럼(=categories)을 x축으로 사용하는 chartData를 항상 제공
const chartData: ChartData = useMemo( const chartData: ChartData = useMemo(
() => ({ () => ({
categories, categories,
series: rows.map((r) => ({ series: rows.map((r) => ({
name: r.label, name: r.label,
data: r.values.map((v) => parseNumber(v) ?? null), data: r.values.map((v) => parseNumber(v) ?? null),
})), })),
}), }),
[categories, rows] [categories, rows]
); );
const chartNode = useMemo(() => { const chartNode = useMemo(() => {
if (!chart) return null; if (!chart) return null;
return typeof chart === "function" ? chart({ chartData, tableCategories: categories, tableRows: rows }) : chart; return typeof chart === "function" ? chart({ chartData }) : chart;
}, [chart, chartData, categories, rows]); }, [chart, chartData, categories, rows]);
return ( return (
<div className={cn("w-full", wrapperClassName)}> <div className={cn("w-full", wrapperClassName)}>
{title && ( <div className="mb-2 flex items-center justify-between">
<SectionTitle title={title} /> {title ? <SectionTitle title={title} /> : <div />}
)} {unitText ? <div className="text-gray-500 text-xs font-semibold">{unitText}</div> : null}
</div>
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table <table
className={cn("lg-table", tableClassName)} className={cn("lg-table", tableClassName)}
style={{ minWidth: `${minWidthPx}px` }} style={{ minWidth: `${minWidthPx}px` }}
> >
<thead> <thead>
<tr> <tr>
{/* 좌상단: rowhead 헤더(필요 시 표시). HTML과 동일하게 2행 rowspan */} {/* 좌상단: rowhead 헤더(필요 시 표시). HTML과 동일하게 2행 rowspan */}
<th rowSpan={2} className="lg-table__sep-r w-15" style={{ whiteSpace: "nowrap" }}> <th rowSpan={2} className="lg-table__sep-r w-15" style={{ whiteSpace: "nowrap" }}>
{rowHeadHeader}
</th> </th>
<td colSpan={categories.length} style={{ padding: 0, height: chartNode ? chartHeight : 0 }}> <td colSpan={categories.length} style={{ padding: 0, height: chartNode ? chartHeight : 0 }}>
{chartNode ? <div style={{ width: "100%", height: "100%" }}>{chartNode}</div> : null} {chartNode ? <div style={{ width: "100%", height: "100%" }}>{chartNode}</div> : null}
@@ -148,61 +109,65 @@ export default function TopChartTable(props: TopChartTableProps) {
<tr className="lg-table__subhead"> <tr className="lg-table__subhead">
{categories.map((c) => ( {categories.map((c) => (
<th key={c} className={"content-text-xs"}>{c}</th> <th key={c} className={"content-text-xs"}>{c}</th>
))} ))}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{rows.map((r, ri) => { {rows.map((r, ri) => {
const isSignRow = !!(signStyle?.rowSelector && signStyle.rowSelector(r, ri)); const isSignRow = !!(signStyle?.rowSelector && signStyle.rowSelector(r, ri));
const cagrRow = isCagrRow(r.label as string ?? "");
const total = parseNumber(r.total);
return ( return (
<tr key={`${r.label}-${ri}`}> <tr key={`${r.label}-${ri}`}>
<th scope="row" className="lg-table__rowhead lg-table__sep-r content-text-sm"> <th scope="row" className="lg-table__rowhead lg-table__sep-r content-text-sm">
{r.label} {r.label}
</th> </th>
{categories.map((_, ci) => { {categories.map((_, ci) => {
const raw = r.values?.[ci]; const raw = r.values?.[ci];
const n = parseNumber(raw); const n = parseNumber(raw);
// 일반 행 // 일반 행
if (!isSignRow) { if (!isSignRow) {
if (n === null) return <td key={ci}>-</td>;
const isFill = fillCAGR && cagrRow && total && n > total + 5;
const txt = n.toLocaleString();
return <td key={ci} className={cn(isFill? "bg-red-200" :"")}>{txt}</td>;
}
// sign row
if (n === null) return <td key={ci}>-</td>; if (n === null) return <td key={ci}>-</td>;
const txt = valueFormatter ? valueFormatter(n) : n.toLocaleString(); if (n === 0) return <td key={ci}>{zeroText}</td>;
return <td key={ci}>{txt}</td>;
}
// sign row const cls = n > 0 ? posCls : negCls;
if (n === null) return <td key={ci}>-</td>;
if (n === 0) return <td key={ci}>{zeroText}</td>;
const cls = n > 0 ? posCls : negCls; if (display === "arrow") {
const arrow = n > 0 ? "▲" : "▼";
const num = Math.abs(n);
return (
<td key={ci} className={cls}>
{arrow}
{arrowWithNumber ? ` ${num}` : ""}
</td>
);
}
if (display === "arrow") {
const arrow = n > 0 ? "▲" : "▼";
const num = Math.abs(n);
return ( return (
<td key={ci} className={cls}> <td key={ci} className={cls}>
{arrow} {formatSignedNumber(n, zeroText, showPlus)}
{arrowWithNumber ? ` ${num}` : ""} </td>
</td>
); );
} })}
</tr>
return (
<td key={ci} className={cls}>
{formatSignedNumber(n, zeroText, showPlus)}
</td>
);
})}
</tr>
); );
})} })}
</tbody> </tbody>
</table> </table>
</div>
</div> </div>
</div>
); );
} }

View File

@@ -19,3 +19,4 @@ export { default as CategoryByData } from "./combo/CategoryByData"
export { default as CardDefault } from "./card/Card"; export { default as CardDefault } from "./card/Card";
export { default as SectionTitle } from "./SectionTitle"; export { default as SectionTitle } from "./SectionTitle";
export { default as BottomDescription } from "./BottomDescription";

View File

@@ -14,7 +14,7 @@ const Brand = () => {
const {filterValue, registerExcelExporter} = useLayoutFilter(); const {filterValue, registerExcelExporter} = useLayoutFilter();
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [ const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [
{title: "브랜드", chartMode:"reverseStack", data: apiBrandShareByYear}, {title: "브랜드", chartMode:"reverseStack", data: apiBrandShareByYear, chartHeight:400},
], []); ], []);
useEffect(() => { useEffect(() => {

View File

@@ -5,7 +5,8 @@ import type React from "react";
import { cn, parseNumber } from "@/lib/utils"; import { cn, parseNumber } from "@/lib/utils";
import type { DataColumn, SignDisplayMode, SignStyle } from "../types"; import type { DataColumn, SignDisplayMode, SignStyle } from "../types";
import SectionTitle from "../SectionTitle"; import SectionTitle from "../SectionTitle";
import {isSampleRow} from "@/lib/lg-dashboard"; import {isCagrRow, isSampleRow} from "@/lib/lg-dashboard";
import {SAMPLE_SIZE_NOTICE, UNIT_TEXT} from "@/const/lgConst";
type Props<T extends Record<string, unknown>> = { type Props<T extends Record<string, unknown>> = {
columns: DataColumn<T>[]; columns: DataColumn<T>[];
@@ -15,7 +16,9 @@ type Props<T extends Record<string, unknown>> = {
wrapperClassName?: string; wrapperClassName?: string;
signStyle?: SignStyle<T>; signStyle?: SignStyle<T>;
fillGreaterThan5?: boolean; fillGreaterThan5?: boolean;
fillCAGR?: boolean;
starUnder30Sample?: boolean; starUnder30Sample?: boolean;
unitText?: string;
}; };
// parseSignedNumber는 utils.ts의 parseNumber로 통합됨 // parseSignedNumber는 utils.ts의 parseNumber로 통합됨
@@ -57,7 +60,9 @@ const DataTable = <T extends Record<string, unknown>>({
wrapperClassName, wrapperClassName,
signStyle, signStyle,
fillGreaterThan5 = false, fillGreaterThan5 = false,
fillCAGR = false,
starUnder30Sample = false, starUnder30Sample = false,
unitText = UNIT_TEXT,
}: Props<T>) => { }: Props<T>) => {
const hasGroup = columns.some((c) => !!c.group) || columns.some((c) => c.headRowSpan === 2); const hasGroup = columns.some((c) => !!c.group) || columns.some((c) => c.headRowSpan === 2);
@@ -148,9 +153,16 @@ const DataTable = <T extends Record<string, unknown>>({
return ( return (
<div className={cn("w-full overflow-x-auto", wrapperClassName)}> <div className={cn("w-full overflow-x-auto", wrapperClassName)}>
{title && ( <div className="mb-2 flex items-center justify-between">
<SectionTitle title={title} /> { title && <SectionTitle title={title} />}
)} {
(unitText || starUnder30Sample) &&
<div className="ml-auto text-gray-500 content-text-xs font-semibold text-right">
{unitText}
{starUnder30Sample && <><br/>{SAMPLE_SIZE_NOTICE}</>}
</div>
}
</div>
<table className={cn("lg-table", className)}> <table className={cn("lg-table", className)}>
<thead> <thead>
{hasGroup && ( {hasGroup && (

View File

@@ -1,4 +1,5 @@
import type React from "react"; import type React from "react";
import {GAP_WORDING} from "@/const/lgConst";
export type NewNumber = number | null | undefined; export type NewNumber = number | null | undefined;
@@ -45,6 +46,7 @@ export type GroupedOverlayBarData = {
export type TopChartTableRow = { export type TopChartTableRow = {
/** 좌측 rowhead 라벨 */ /** 좌측 rowhead 라벨 */
label: string; label: string;
total: number | string | null | undefined;
/** categories 순서대로 값 */ /** categories 순서대로 값 */
values: Array<number | string | null | undefined>; values: Array<number | string | null | undefined>;
}; };
@@ -122,7 +124,7 @@ export type SignStyle<T> = {
}; };
export const signStyleGapRow: SignStyle<TopChartTableRow> = { export const signStyleGapRow: SignStyle<TopChartTableRow> = {
rowSelector: (row) => row.label === "전년 대비 GAP(%)", rowSelector: (row) => row.label === GAP_WORDING,
display: "arrow", display: "arrow",
arrowWithNumber: true, arrowWithNumber: true,
paint: "text", paint: "text",

View File

@@ -32,7 +32,7 @@ export const totalFilters:TotalFilterItem[] = [
] ]
}, },
{ {
variable:"tenure", variable:"occupancy",
variableName:"입주 형태", variableName:"입주 형태",
children:[ children:[
{ value: "0", label: "전체"}, { value: "0", label: "전체"},
@@ -44,7 +44,7 @@ export const totalFilters:TotalFilterItem[] = [
] ]
}, },
{ {
variable:"pyeong", variable:"houseSize",
variableName:"거주 평형", variableName:"거주 평형",
children:[ children:[
{ value: "0", label: "전체"}, { value: "0", label: "전체"},

View File

@@ -158,9 +158,9 @@ const BANNER_GROUPS: Record<string, BannerKey[]> = {
lifeStage: ["single", "noKids", "preschoolKids", "schoolKids", "adultKids", "independentSenior"], lifeStage: ["single", "noKids", "preschoolKids", "schoolKids", "adultKids", "independentSenior"],
household: ["hh1", "hh2", "hh3", "hh4Plus"], household: ["hh1", "hh2", "hh3", "hh4Plus"],
age: ["age20s", "age30s", "age40s", "age50s", "age60s"], age: ["age20s", "age30s", "age40s", "age50s", "age60s"],
tenure: ["ownerOccupied", "jeonse", "depositAndMonthly", "monthlyNoDeposit", "otherTenure"], occupancy: ["ownerOccupied", "jeonse", "depositAndMonthly", "monthlyNoDeposit", "otherOccupancyType"],
housing: ["apartment", "house", "officetel", "villa", "studio", "otherHousingType"], housing: ["apartment", "house", "officetel", "villa", "studio", "otherHousingType"],
pyeong: ["under19Pyeong", "pyeong20s", "pyeong30s", "pyeong40s", "pyeong50Plus"], houseSize: ["under19Pyeong", "pyeong20s", "pyeong30s", "pyeong40s", "pyeong50Plus"],
region: [ region: [
"regionCapital", "regionCapital",
"regionGyeongnamBusanUlsan", "regionGyeongnamBusanUlsan",

View File

@@ -3,6 +3,8 @@
* - 차트 높이, Bar 너비, Grid 설정 등 * - 차트 높이, Bar 너비, Grid 설정 등
*/ */
import {GAP_WORDING} from "@/const/lgConst";
/** /**
* 차트 기본 높이 설정 * 차트 기본 높이 설정
*/ */
@@ -122,8 +124,8 @@ export const TABLE_DIMENSIONS = {
export const CHART_LABELS = { export const CHART_LABELS = {
TOTAL: "전체", TOTAL: "전체",
LG: "LG", LG: "LG",
GAP: "전년 대비 GAP(%)", GAP: GAP_WORDING,
CAGR: "CAGR(%)", CAGR: "CAGR(%p)",
SAMPLE_COUNT: "(사례수)", SAMPLE_COUNT: "(사례수)",
} as const; } as const;

View File

@@ -3,6 +3,11 @@ import {GaugeColumn} from "@/components/lge-dashboard";
export const SITE_TITLE = 'LGE CX Dashboard'; export const SITE_TITLE = 'LGE CX Dashboard';
export const GAP_WORDING = "전년 대비 GAP(%p)";
export const UNIT_TEXT = "(단위 %)"
export const SAMPLE_SIZE_NOTICE = "* 30표본 미만 해석에 주의";
export const PRODUCT_KEY_MAP = { export const PRODUCT_KEY_MAP = {
refrigerator: "냉장고", refrigerator: "냉장고",
kimchiRefrigerator: "김치 냉장고", kimchiRefrigerator: "김치 냉장고",
@@ -52,7 +57,7 @@ export const BANNER_KEY_MAP = {
jeonse: "전세", jeonse: "전세",
depositAndMonthly: "전+월세 (보증금有)", depositAndMonthly: "전+월세 (보증금有)",
monthlyNoDeposit: "월세 (보증금無)", monthlyNoDeposit: "월세 (보증금無)",
otherTenure: "기타", otherOccupancyType: "기타",
// 주거형태 // 주거형태
apartment: "아파트", apartment: "아파트",
@@ -181,15 +186,15 @@ export const BANNER_GROUP = {
label: "연령", label: "연령",
keys: [BANNER_KEY.age20s, BANNER_KEY.age30s, BANNER_KEY.age40s, BANNER_KEY.age50s, BANNER_KEY.age60s], keys: [BANNER_KEY.age20s, BANNER_KEY.age30s, BANNER_KEY.age40s, BANNER_KEY.age50s, BANNER_KEY.age60s],
}, },
tenure: { occupancy: {
label: "입주 형태", label: "입주 형태",
keys: [BANNER_KEY.ownerOccupied, BANNER_KEY.jeonse, BANNER_KEY.depositAndMonthly, BANNER_KEY.monthlyNoDeposit, BANNER_KEY.otherTenure], keys: [BANNER_KEY.ownerOccupied, BANNER_KEY.jeonse, BANNER_KEY.depositAndMonthly, BANNER_KEY.monthlyNoDeposit, BANNER_KEY.otherOccupancyType],
}, },
housing: { housing: {
label: "주거 형태", label: "주거 형태",
keys: [BANNER_KEY.apartment, BANNER_KEY.house, BANNER_KEY.officetel, BANNER_KEY.villa, BANNER_KEY.studio, BANNER_KEY.otherHousingType], keys: [BANNER_KEY.apartment, BANNER_KEY.house, BANNER_KEY.officetel, BANNER_KEY.villa, BANNER_KEY.studio, BANNER_KEY.otherHousingType],
}, },
pyeong: { houseSize: {
label: "거주 평형", label: "거주 평형",
keys: [BANNER_KEY.under19Pyeong, BANNER_KEY.pyeong20s, BANNER_KEY.pyeong30s, BANNER_KEY.pyeong40s, BANNER_KEY.pyeong50Plus], keys: [BANNER_KEY.under19Pyeong, BANNER_KEY.pyeong20s, BANNER_KEY.pyeong30s, BANNER_KEY.pyeong40s, BANNER_KEY.pyeong50Plus],
}, },
@@ -209,5 +214,3 @@ export const BANNER_GROUP = {
keys: [BANNER_KEY.incomeUnder299, BANNER_KEY.income300to599, BANNER_KEY.income600to899, BANNER_KEY.income900Plus], keys: [BANNER_KEY.incomeUnder299, BANNER_KEY.income300to599, BANNER_KEY.income600to899, BANNER_KEY.income900Plus],
}, },
} as const; } as const;
export const SAMPLE_SIZE_NOTICE = "* 30 미만 샘플에 대한 설명";

View File

@@ -1,14 +1,18 @@
import {BannerGroupKey, ServerBannerRow} from "@/types/lg"; import {BannerGroupKey, ServerBannerRow} from "@/types/lg";
import {ChartData} from "@/components/lge-dashboard"; import {ChartData} from "@/components/lge-dashboard";
import {BANNER_GROUP} from "@/const/lgConst"; import {BANNER_GROUP, GAP_WORDING} from "@/const/lgConst";
import {formatNumber} from "@/lib/utils"; import {formatNumber} from "@/lib/utils";
export const isSampleRow = (raw: string) => raw.replace(/\s+/g, "").includes("사례수"); export const isSampleRow = (raw: string) => raw.replace(/\s+/g, "").includes("사례수");
export const isCagrRow = (raw: string) => raw.replace(/\s+/g, "").toUpperCase().includes("CAGR");
export const isGapRow = (raw: string) => raw.replace(/\s+/g, "").toUpperCase().includes("GAP");
/** /**
* Row Label을 표시용 텍스트로 포맷팅합니다. * Row Label을 표시용 텍스트로 포맷팅합니다.
* - "사례수" -> "(사례수)" * - "사례수" -> "(사례수)"
* - "gap" -> "전년 대비 GAP(%)" * - "gap" -> "전년 대비 GAP(%p)"
* - "CAGR" -> "CAGR(%)" * - "CAGR" -> "CAGR(%)"
* - "24" -> "24년" * - "24" -> "24년"
* - "보급율" -> "보급율(%)" * - "보급율" -> "보급율(%)"
@@ -18,7 +22,7 @@ export function formatRowLabel(
label: string, label: string,
options?: { options?: {
convertSample?: boolean; // "사례수" -> "(사례수)" (기본값: true) convertSample?: boolean; // "사례수" -> "(사례수)" (기본값: true)
convertGap?: boolean; // "gap" -> "전년 대비 GAP(%)" (기본값: true) convertGap?: boolean; // "gap" -> "전년 대비 GAP(%p)" (기본값: true)
convertCagr?: boolean; // "CAGR" -> "CAGR(%)" (기본값: true) convertCagr?: boolean; // "CAGR" -> "CAGR(%)" (기본값: true)
convertYear?: boolean; // "24" -> "24년" (기본값: true) convertYear?: boolean; // "24" -> "24년" (기본값: true)
convertRate?: boolean; // "~율" -> "~율(%)" (기본값: true) convertRate?: boolean; // "~율" -> "~율(%)" (기본값: true)
@@ -37,11 +41,11 @@ export function formatRowLabel(
const t = label.trim(); const t = label.trim();
if (convertSample && t === "사례수") return "(사례수)"; if (convertSample && t === "사례수") return "(사례수)";
if (convertGap && t.toLowerCase() === "gap") return "전년 대비 GAP(%)"; if (convertGap && t.toLowerCase() === "gap") return GAP_WORDING;
if (convertCagr && t.toUpperCase() === "CAGR") return "CAGR(%)"; if (convertCagr && t.toUpperCase() === "CAGR") return "CAGR(%p)";
if (convertYear && /^\d{2}$/.test(t)) return `${t}년`; if (convertYear && /^\d{2}$/.test(t)) return `${t}년`;
if (convertRate && t.endsWith("율")) return `${t}(%)`; if (convertRate && t.endsWith("율")) return `${t.replaceAll('(%)','')}(%)`;
if (convertCount && t.includes("대수")) return `${t}(대)`; if (convertCount && t.includes("대수")) return `${t.replaceAll('(대)','')}(대)`;
return t; return t;
} }