260205_05_ENH: 1차 lg 수정 요청사항 반영

This commit is contained in:
2026-02-05 16:54:55 +09:00
parent 8c015bd443
commit 84675b77b3
25 changed files with 452 additions and 316 deletions

View File

@@ -13,7 +13,7 @@ import {
LIFE_STAGE_GROUPS,
PRODUCT_KEY_MAP,
PRODUCT_KEYS,
PRODUCTS,
PRODUCTS, SITE_TITLE,
YEARS
} from "@/const/lgConst";
import {useEffect, useMemo} from "react";
@@ -34,6 +34,8 @@ const LGPenetrationPage = () => {
const { filterValue, registerExcelExporter } = useLayoutFilter();
console.log(filterValue);
//TODO: LG가 0인 제품은 제외시키기
const productTableRows = useMemo<TopChartTableRow[]>(() => {
return apiOwnShareOfTotalPenetration.map((row) => ({
label: formatRowLabel(row.rowLabel),
@@ -125,7 +127,7 @@ const LGPenetrationPage = () => {
];
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(LG제품 보급률).xlsx`,
fileName: `${SITE_TITLE}(LG제품 보급률).xlsx`,
sheetName: "LG제품 보급률",
sections: sections,
});

View File

@@ -1,7 +1,7 @@
"use client";
import {useEffect, useMemo} from "react";
import {LAST_YEAR, PRODUCT_KEY_MAP, PRODUCT_KEYS, PRODUCTS, YEARS} from "@/const/lgConst";
import {LAST_YEAR, PRODUCT_KEY_MAP, PRODUCT_KEYS, PRODUCTS, SITE_TITLE, YEARS} from "@/const/lgConst";
import {
GroupedOverlayBar,
type GroupedOverlayBarData,
@@ -18,6 +18,8 @@ const LGPurchasePage = () => {
const { filterValue, registerExcelExporter } = useLayoutFilter();
console.log(filterValue);
//TODO: LG가 0인 제품은 제외시키기
const purchaseTableRows = useMemo<TopChartTableRow[]>(() => {
return apiOwnShareOfTotalPurchase.map((row) => ({
label: formatRowLabel(row.rowLabel),
@@ -68,7 +70,7 @@ const LGPurchasePage = () => {
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP);
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(LG제품 구매율).xlsx`,
fileName: `${SITE_TITLE}(LG제품 구매율).xlsx`,
sheetName: "LG제품 구매율",
sections: [
{ title: "LG제품 구매율", header: excelHeader, rows: apiOwnShareOfTotalPurchase, rowGap: 1 },

View File

@@ -19,7 +19,7 @@ import {
PRODUCTS,
YEARS,
AXIS_HIDE_STYLE,
GRID_X_NOT_PADDING, PRODUCT_KEY_MAP, LAST_YEAR,
GRID_X_NOT_PADDING, PRODUCT_KEY_MAP, LAST_YEAR, SITE_TITLE,
} from "@/const/lgConst";
import { formatRowLabel } from "@/lib/lg-dashboard";
import {buildHeader_ProductKeyMap, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
@@ -89,7 +89,7 @@ const PenetrationPage = () => {
];
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(보급률).xlsx`,
fileName: `${SITE_TITLE}(보급률).xlsx`,
sheetName: "전체 보급률",
sections: sections,
});

View File

@@ -42,7 +42,7 @@ const PurchasePage = () => {
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP);
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(구매율).xlsx`,
fileName: `${SITE_TITLE}(구매율).xlsx`,
sheetName: "구매율",
sections: [
{ title: "구매율", header: excelHeader, rows: apiTrendBuy, rowGap: 1 },

View File

@@ -1,12 +1,13 @@
"use client";
import { CategoryTargetData, CategoryTargetType } from "@/config/filter.types";
import {CategoryTargetData, CategoryTargetType, TotalFilterItem} from "@/config/filter.types";
import {categoryTarget, categoryTargetType} from "@/config/filter.data";
import { ChevronRight } from "lucide-react";
import { useMemo } from "react";
import {useCallback, useMemo} from "react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import {ProductsFilterItem} from "@/types/lg";
import {YEARS} from "@/const/lgConst";
export type CategoryTypeValue = {
label: string;
@@ -15,6 +16,7 @@ export type CategoryTypeValue = {
export type CategoryFilterValue = {
product: string;
year: string;
type: CategoryTypeValue
target: CategoryTargetData;
};
@@ -26,111 +28,175 @@ type CategoryFilterProps = {
className?: string;
};
type Option = { key: string; label: string; value: string | CategoryTypeValue | CategoryTargetData };
type RowDef = {
id: "year" | "product" | "type" | "target";
title: string;
options: Option[];
isActive: (v: Option["value"]) => boolean;
onSelect: (v: Option["value"]) => void;
};
function FilterLine({ title, options, isActive, onSelect }: Omit<RowDef, "id">) {
return (
<div className="flex min-w-0">
<div className="flex w-[140px] shrink-0 items-center gap-2 px-3 py-2">
<ChevronRight className="h-4 w-4 text-gray-700" />
<span className="text-sm font-semibold text-gray-900 content-text-sm">
{title}
</span>
</div>
<div className="min-w-0 flex-1 overflow-x-auto px-2 py-2">
<div className="flex w-max items-center gap-1 whitespace-nowrap">
{options.map((opt) => {
const active = isActive(opt.value);
return (
<Button
key={opt.key}
type="button"
variant={active ? "default" : "secondary"}
onClick={() => onSelect(opt.value)}
className="h-8 shrink-0 rounded-sm px-3 text-sm font-semibold content-text-base"
>
{opt.label}
</Button>
);
})}
</div>
</div>
</div>
);
}
const CategoryFilter = ({ filterItems, value, onChange, className }: CategoryFilterProps) => {
const currentTargetItem = useMemo(() => {
return categoryTarget.find((item) => item.type.includes(value.type.value));
}, [value.type]);
}, [value.type.value]);
const handlePick = (
key: keyof CategoryFilterValue,
v: string | CategoryTypeValue | CategoryTargetData
) => {
if (value[key] === v) return;
const next: CategoryFilterValue = { ...value, [key]: v } as CategoryFilterValue;
// type 비교는 객체참조가 아니라 value로 비교해야 함
const handlePick = useCallback(
(key: keyof CategoryFilterValue, v: string | CategoryTypeValue | CategoryTargetData) => {
// same check
if (key === "type" && typeof v === "object" && "value" in v) {
if (value.type.value === v.value) return;
if (key === "type" && typeof v === "object" && v.value !== value.type.value) {
const nextItem = categoryTarget.find((item) => item.type.includes(v.value));
const firstTarget = nextItem?.children?.[0]?.target;
if (firstTarget) next.target = firstTarget;
}
const nextItem = categoryTarget.find((item) => item.type.includes(v.value));
const firstTarget = nextItem?.children?.[0]?.target;
onChange(next);
};
onChange({
...value,
type: v,
target: (firstTarget ?? value.target) as CategoryTargetData,
});
return;
}
if (key !== "type") {
// string/primitive 비교
if ((value as any)[key] === v) return;
onChange({ ...value, [key]: v } as CategoryFilterValue);
}
},
[value, onChange]
);
const rowDefs = useMemo<RowDef[]>(() => {
const yearRow:RowDef = {
id:"year",
title: "연도",
options:(YEARS).map((y) => ({
key:y,
label:`20${y}년`,
value:y,
})),
isActive: (v) => value.year === v,
onSelect: (v) => handlePick("year", v as string),
};
const productRow: RowDef = {
id: "product",
title: "제품",
options: (filterItems.items ?? []).map((p) => ({
key: p,
label: p,
value: p,
})),
isActive: (v) => value.product === v,
onSelect: (v) => handlePick("product", v as string),
};
const typeRow: RowDef = {
id: "type",
title: "기준",
options: categoryTargetType.map((t) => ({
key: t.label,
label: t.label,
value: { label: t.label, value: t.value },
})),
isActive: (v) => {
const vv = v as CategoryTypeValue;
return value.type.value === vv.value;
},
onSelect: (v) => handlePick("type", v as CategoryTypeValue),
};
const targetRow: RowDef = {
id: "target",
title: "데이터",
options: (currentTargetItem?.children ?? []).map((c) => ({
key: String(c.target),
label: c.label,
value: c.target,
})),
isActive: (v) => value.target === v,
onSelect: (v) => handlePick("target", v as CategoryTargetData),
};
// 여기 순서만 바꾸면 배치도 같이 바뀜 (left: 앞쪽 half, right: 뒤쪽 half)
return [yearRow, productRow, typeRow, targetRow];
}, [YEARS, filterItems.items, currentTargetItem, value, handlePick]);
const cells = useMemo(() => {
const half = Math.ceil(rowDefs.length / 2); // 3개면 2개(left) + 1개(right)
const maxRows = half;
return rowDefs.map((def, i) => {
const col = i < half ? 0 : 1; // 0:left, 1:right
const row = i < half ? i : i - half;
return { def, col, row, maxRows };
});
}, [rowDefs]);
return (
<div className={cn("w-full border border-gray-300 bg-white/70 backdrop-blur-sm", className)}>
{/* 제품 (1줄 나열) */}
<div className="flex min-w-0 border-b border-gray-200">
<div className="flex w-[140px] shrink-0 items-center gap-2 px-3 py-2">
<ChevronRight className="h-4 w-4 text-gray-700" />
<span className="text-sm font-semibold text-gray-900 content-text-sm">제품</span>
</div>
<div className="min-w-0 flex-1 overflow-x-auto px-2 py-2">
<div className="flex w-max items-center gap-1 whitespace-nowrap">
{filterItems.items.map((p) => {
const active = value.product === p;
return (
<Button
key={p}
type="button"
variant={active ? "default" : "secondary"}
onClick={() => handlePick("product", p)}
className="h-6 shrink-0 rounded-sm px-3 text-sm font-semibold content-text-sm"
>
{p}
</Button>
);
})}
</div>
</div>
</div>
{/* 기준 (1줄 나열) */}
<div className="flex min-w-0 border-b border-gray-200">
<div className="flex w-[140px] shrink-0 items-center gap-2 px-3 py-2">
<ChevronRight className="h-4 w-4 text-gray-700" />
<span className="text-sm font-semibold text-gray-900 content-text-sm">기준</span>
</div>
<div className="min-w-0 flex-1 overflow-x-auto px-2 py-2">
<div className="flex w-max items-center gap-1 whitespace-nowrap">
{categoryTargetType.map((item) => {
const active = value.type.label === item.label;
return (
<Button
key={item.label}
type="button"
variant={active ? "default" : "secondary"}
onClick={() => {
handlePick("type", {label:item.label, value:item.value});
}}
className="h-6 shrink-0 rounded-sm px-3 text-sm font-semibold content-text-sm"
>
{item.label}
</Button>
);
})}
</div>
</div>
</div>
{/* 데이터 (1줄 나열) */}
<div className="flex min-w-0">
<div className="flex w-[140px] shrink-0 items-center gap-2 px-3 py-2">
<ChevronRight className="h-4 w-4 text-gray-700" />
<span className="text-sm font-semibold text-gray-900 content-text-sm">데이터</span>
</div>
<div className="min-w-0 flex-1 overflow-x-auto px-2 py-2">
<div className="flex w-max items-center gap-1 whitespace-nowrap">
{currentTargetItem?.children?.map((child) => {
const active = value.target === child.target;
return (
<Button
key={child.target}
type="button"
variant={active ? "default" : "secondary"}
onClick={() => handlePick("target", child.target)}
className="h-6 shrink-0 rounded-sm px-3 text-sm font-semibold content-text-sm"
>
{child.label}
</Button>
);
})}
</div>
</div>
<div className="grid grid-cols-2">
{cells.map(({ def, col, row, maxRows }) => {
const showRowDivider = row < maxRows - 1; // 같은 rowIndex 기준으로 좌/우 라인 맞춤
return (
<div
key={def.id}
style={{
gridColumnStart: col + 1,
gridRowStart: row + 1,
}}
className={cn(
"min-w-0",
showRowDivider && "border-b border-gray-200",
col === 1 && "border-l-4 border-gray-300"
)}
>
<FilterLine
title={def.title}
options={def.options}
isActive={def.isActive}
onSelect={def.onSelect}
/>
</div>
);
})}
</div>
</div>
);

View File

@@ -5,8 +5,8 @@ import Image from "next/image";
import {topMenus} from "@/config/menu.data";
import {Button} from "@/components/ui/button";
import {LogOut} from "lucide-react";
import {DASHBOARD_YEAR} from "@/const/commonConst";
import {cn} from "@/lib/utils";
import {SITE_TITLE} from "@/const/lgConst";
interface HeaderProps {
activeTopId: string;
@@ -70,7 +70,7 @@ const Header = ({
</nav>
</div>
<div className="flex justify-between items-center">
<h1 className="font-bold content-text-2xl text-header-color">{DASHBOARD_YEAR}년도 가전보급률 Dashboard</h1>
<h1 className="font-bold content-text-2xl text-header-color">{SITE_TITLE}</h1>
</div>
{/* 우측 컨트롤 */}
<div className="flex items-center gap-4">

View File

@@ -13,7 +13,7 @@ import TotalFilter from "./TotalFilter";
import CategoryFilter, {CategoryFilterValue} from "./CategoryFilter";
import ExcelDownloadButton from "./ExcelDownloadButton";
import {LayoutFilterProvider} from "./LayoutFilterContext";
import {PRODUCTS_FILTER_ITEM} from "@/const/lgConst";
import {LAST_YEAR, PRODUCTS_FILTER_ITEM} from "@/const/lgConst";
import {ProductsFilterItem} from "@/types/lg";
import {ArrowUp} from "lucide-react";
@@ -38,6 +38,7 @@ export const buildDefaultCategoryValue = (categoryFilterItems: ProductsFilterIte
const initTarget = firstTarget ?? CategoryTargetData.PROFILE;
return {
year: LAST_YEAR,
product: initProduct,
type: initType,
target: initTarget,
@@ -118,73 +119,79 @@ const MainLayout = ({ children }: MainLayoutProps) => {
<LayoutFilterProvider
value={isTotal? { isTotal: true, filterValue: totalValue } : { isTotal: false, filterValue: categoryValue }}
>
<Header
activeTopId={activeTop.id}
onNavigate={movePage}
/>
<div className="flex-1 min-h-0 flex flex-col bg-lg-main-body p-1 pl-6">
<SubMenu
subMenu={subMenus}
activeSubId={activeSub.id}
<Header
activeTopId={activeTop.id}
onNavigate={movePage}
/>
<div className="flex-1 min-h-0 flex flex-col pr-4">
<div className="bg-card lg-tab-content flex-1 min-h-0 flex flex-col overflow-hidden">
<div className="shrink-0 flex items-center justify-between px-2 py-1">
<button
type="button"
onClick={toggleFilter}
className={cn(
"inline-flex items-center gap-2 font-semibold text-gray-900 content-text-sm",
"select-none"
)}
>
필터 <span className="text-sm leading-none">{isFilterOpen ? "▲" : "▼"}</span>
</button>
<ExcelDownloadButton/>
</div>
{isFilterOpen && (
<div className="shrink-0">
{isTotal ? (
<TotalFilter filters={totalFilters} value={totalValue} onChange={setTotalValue} />
) : (
<CategoryFilter filterItems={categoryFilterItems} value={categoryValue} onChange={setCategoryValue} />
)}
</div>
)}
<div className="relative flex-1 min-h-0">
<div
ref={scrollRef}
onScroll={onScrollContent}
className="h-full overflow-auto"
>
<div className="p-3 pb-8">
{children}
</div>
</div>
{showScrollTop && (
<div className="flex-1 min-h-0 flex flex-col bg-lg-main-body p-1 pl-6">
<SubMenu
subMenu={subMenus}
activeSubId={activeSub.id}
onNavigate={movePage}
/>
<div className="flex-1 min-h-0 flex flex-col pr-4">
<div className="bg-card lg-tab-content flex-1 min-h-0 flex flex-col overflow-hidden">
<div className="shrink-0 flex items-center justify-between px-2 py-1">
<div className="flex">
<button
type="button"
onClick={scrollToTop}
aria-label="위로 가기"
onClick={toggleFilter}
className={cn(
"absolute -bottom-2 right-4 z-20",
"h-8 w-8 rounded-full",
"bg-gray-900/80 text-white hover:bg-primary",
"flex items-center justify-center"
"inline-flex items-center gap-2 font-semibold text-gray-900 content-text-sm",
"select-none"
)}
>
<ArrowUp className="h-5 w-5" />
필터 <span className="text-sm leading-none">{isFilterOpen ? "▲" : "▼"}</span>
</button>
{isTotal && (
<div className={"ml-5 content-text-sm"}>
페이지에 대한 설명
</div>
)}
</div>
<ExcelDownloadButton/>
</div>
{isFilterOpen && (
<div className="shrink-0">
{isTotal ? (
<TotalFilter filters={totalFilters} value={totalValue} onChange={setTotalValue} />
) : (
<CategoryFilter filterItems={categoryFilterItems} value={categoryValue} onChange={setCategoryValue} />
)}
</div>
)}
<div className="relative flex-1 min-h-0">
<div
ref={scrollRef}
onScroll={onScrollContent}
className="h-full overflow-auto"
>
<div className="p-3 pb-8">
{children}
</div>
</div>
{showScrollTop && (
<button
type="button"
onClick={scrollToTop}
aria-label="위로 가기"
className={cn(
"absolute -bottom-2 right-4 z-20",
"h-8 w-8 rounded-full",
"bg-gray-900/80 text-white hover:bg-primary",
"flex items-center justify-center"
)}
>
<ArrowUp className="h-5 w-5" />
</button>
)}
</div>
</div>
</div>
</div>
</div>
</LayoutFilterProvider>
</div>
);

View File

@@ -14,13 +14,14 @@ const BannerButtons = ({
onSelectBanner
}: BannerButtonsProps) => {
return (
<div className="flex flex-col gap-2">
<div className="flex flex-col gap-1.5">
<div className="text-center font-bold p-1">구분 필터</div>
{banners.map((banner) => (
<button
key={banner.variable}
onClick={() => onSelectBanner(banner)}
className={`
px-4 py-2 text-sm font-bold rounded-lg transition-colors cursor-pointer
px-4 py-1.5 text-sm font-bold rounded-lg transition-colors cursor-pointer
${
selectedBanner === banner
? "bg-primary text-primary-foreground"

View File

@@ -6,7 +6,7 @@ import {
BANNER_GROUP,
BANNER_KEY_MAP,
GRID_Y_NOT_PADDING,
LAST_YEAR,
SAMPLE_SIZE_NOTICE, SITE_TITLE,
} from "@/const/lgConst";
import {parseNumber} from "@/lib/utils";
import {
@@ -36,11 +36,11 @@ const SEP_R = "lg-table__sep-r";
const getSectionBannerKeys = (spec: SectionSpec): BannerKey[] =>
spec.groupKeys.flatMap((gk) => BANNER_GROUP[gk].keys);
const buildColumns = (spec: SectionSpec): DataColumn<ServerBannerRow>[] => {
const buildColumns = (spec: SectionSpec, selectedYear:string): DataColumn<ServerBannerRow>[] => {
const columns: DataColumn<ServerBannerRow>[] = [
{
key: "rowLabel",
header: "",
header: `20${selectedYear}년`,
headRowSpan: 2,
rowHead: true,
cellClassName: "lg-table__rowhead",
@@ -79,9 +79,10 @@ const buildColumns = (spec: SectionSpec): DataColumn<ServerBannerRow>[] => {
type BannerSummaryProps = {
data: ServerBannerRow[];
useChart: boolean;
useYear: boolean;
};
const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
const BannerSummary = ({ data, useChart, useYear }: BannerSummaryProps) => {
const {filterValue, registerExcelExporter } = useLayoutFilter();
const buildChartData = (rows: ServerBannerRow[], bannerKeys: BannerKey[]): ChartData => {
@@ -117,10 +118,10 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
const specTitle = spec.title;
const bannerKeys = getSectionBannerKeys(spec);
const columns = buildColumns(spec);
const columns = buildColumns(spec, useYear? filterValue.year : "");
// rows가 spec마다 다르면 여기서 가져오도록 구성
const rows = wrapSampleRow(data);
const rows = wrapSampleRow(useYear? data.filter((d) => d.year === filterValue.year) : data);
const chartData = buildChartData(rows, bannerKeys);
return {
@@ -132,7 +133,7 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
chartData,
};
});
}, [data]);
}, [data, useYear, filterValue.year]);
useEffect(() => {
registerExcelExporter(async (payload) => {
@@ -150,7 +151,7 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
;
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
fileName: `${SITE_TITLE}(${sheetName}).xlsx`,
sheetName: sheetName,
sections: sections,
});
@@ -162,35 +163,42 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
<div className="flex flex-col gap-6">
{sectionRows.map((sectionRow) => {
return (
useChart ?
<LeftChartTable<ServerBannerRow>
key={sectionRow.specTitle}
title={sectionRow.specTitle}
columns={sectionRow.columns}
rows={sectionRow.rows}
signStyle={signStyleGap}
chart={
<HorizontalBar
data={sectionRow.chartData}
height="100%"
showFocusLabel="none"
legend={{ show: false }}
grid={GRID_Y_NOT_PADDING}
xAxis={{ type: "value", show: false }}
yAxis={{ type: "category", data: sectionRow.chartData.categories, show: false }}
/>
}
chartCell={{ key: "total", startRowIndex: 1 }}
minWidthPx={1200}
/>
:
<DataTable<ServerBannerRow>
key={sectionRow.specTitle}
title={sectionRow.specTitle}
columns={sectionRow.columns}
rows={sectionRow.rows}
signStyle={signStyleGap}
/>
<div key={`div_${sectionRow.specTitle}`}>
{
useChart ?
<LeftChartTable<ServerBannerRow>
key={sectionRow.specTitle}
title={sectionRow.specTitle}
columns={sectionRow.columns}
rows={sectionRow.rows}
signStyle={signStyleGap}
chart={
<HorizontalBar
data={sectionRow.chartData}
height="100%"
showFocusLabel="none"
legend={{ show: false }}
grid={GRID_Y_NOT_PADDING}
xAxis={{ type: "value", show: false }}
yAxis={{ type: "category", data: sectionRow.chartData.categories, show: false }}
/>
}
chartCell={{ key: "total", startRowIndex: 1 }}
minWidthPx={1200}
starUnder30Sample={true}
/>
:
<DataTable<ServerBannerRow>
key={sectionRow.specTitle}
title={sectionRow.specTitle}
columns={sectionRow.columns}
rows={sectionRow.rows}
signStyle={signStyleGap}
starUnder30Sample={true}
/>
}
<div className="float-right content-text-sm">{SAMPLE_SIZE_NOTICE}</div>
</div>
);
})}
</div>

View File

@@ -15,12 +15,11 @@ import {
isBannerGroupKey,
wrapSampleRow
} from "@/lib/lg-dashboard";
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR} from "@/const/lgConst";
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, SAMPLE_SIZE_NOTICE} from "@/const/lgConst";
import {createDefaultGrid, createDefaultLegend, reverseCategories} from "@/lib/chart-options";
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
import {CategoryTypeValue} from "@/components/layout/CategoryFilter";
type CategoryByDataProps = {
selectedYear: string;
title?: string;
chartMode: CategoryChartMode;
allTableData: ServerBannerRow[];
@@ -42,6 +41,7 @@ const signStyleGap: SignStyle<ServerBannerRow> = {
};
const CategoryByData = ({
selectedYear,
title,
chartMode,
allTableData,
@@ -51,11 +51,11 @@ const CategoryByData = ({
}: CategoryByDataProps) => {
const [selectedBanner, setSelectedBanner] = useState<bannerType>(banners[0]);
const buildColumns = (groupKey: BannerGroupKey): DataColumn<ServerBannerRow>[] => {
const buildColumns = (groupKey: BannerGroupKey, selectedYear:string): DataColumn<ServerBannerRow>[] => {
const columns: DataColumn<ServerBannerRow>[] = [
{
key: "rowLabel",
header: "",
header: `20${selectedYear}년`,
headRowSpan: 2,
rowHead: true,
cellClassName: "lg-table__rowhead",
@@ -79,20 +79,21 @@ const CategoryByData = ({
const chartData = useMemo(() => {
const excludeRowLabels =["사례수", "gap"];
const chartTargetData = allTableData.filter((row) => row.year === selectedYear || Number(row.year) === Number(selectedYear) - 1);
if(chartMode == "horizontal"){
return reverseCategories(buildYearSeriesChartData(allTableData, {excludeRowLabels}));
return reverseCategories(buildYearSeriesChartData(chartTargetData, {excludeRowLabels}));
}
return buildRowLabelSeriesChartData(allTableData, {excludeRowLabels});
return buildRowLabelSeriesChartData(chartTargetData, {excludeRowLabels});
}, [allTableData, chartMode]);
}, [allTableData, selectedYear, chartMode]);
const tableColumns = useMemo(() => {
const v = selectedBanner.variable;
return isBannerGroupKey(v) ? buildColumns(v) : [];
}, [selectedBanner.variable]);
return isBannerGroupKey(v) ? buildColumns(v, selectedYear) : [];
}, [selectedBanner.variable, selectedYear]);
const tableData = useMemo(() => wrapSampleRow(allTableData).filter((row) => row.year === LAST_YEAR), [allTableData, LAST_YEAR]);
const tableData = useMemo(() => wrapSampleRow(allTableData).filter((row) => row.year === selectedYear), [allTableData, selectedYear]);
return (
<div>
@@ -113,6 +114,7 @@ const CategoryByData = ({
data={chartData}
height={`${chartHeight ?? 340}px`}
showFocusLabel="none"
paletteVarNames={chartData.series.length === 1? ["--chart-1"]: ["--chart-2","--chart-1"]}
/>
}
</div>
@@ -132,9 +134,11 @@ const CategoryByData = ({
signStyle={signStyleGap}
wrapperClassName="border rounded-lg"
fillGreaterThan5={fillGreaterThan5}
starUnder30Sample={true}
/>
</div>
</div>
<div className="float-right content-text-sm">{SAMPLE_SIZE_NOTICE}</div>
</div>
);
};

View File

@@ -5,6 +5,7 @@ import { cn, parseNumber } from "@/lib/utils";
import type { DataColumn, SignStyle } from "../types";
import SectionTitle from "../SectionTitle";
import { TABLE_DIMENSIONS } from "@/const/chartConst";
import {isSampleRow} from "@/lib/lg-dashboard";
type MergedChartCell<T> = {
/** 차트를 삽입할 컬럼 key(해당 컬럼 td는 startRow에서만 렌더되고 rowSpan 적용) */
@@ -32,6 +33,7 @@ type Props<T extends Record<string, unknown>> = {
wrapperClassName?: string;
tableClassName?: string;
minWidthPx?: number;
starUnder30Sample?: boolean;
};
// toNumber는 utils.ts의 parseNumber로 통합됨
@@ -65,6 +67,7 @@ export default function LeftChartTable<T extends Record<string, unknown>>({
wrapperClassName,
tableClassName,
minWidthPx = TABLE_DIMENSIONS.MIN_WIDTH.COMPACT,
starUnder30Sample = true
}: Props<T>) {
const hasGroupHeader = useMemo(
() => columns.some((c) => c.group) || columns.some((c) => c.headRowSpan === 2),
@@ -169,6 +172,7 @@ export default function LeftChartTable<T extends Record<string, unknown>>({
<tbody>
{rows.map((row, ri) => {
const sampleRow = isSampleRow(row.rowLabel as string ?? "");
const isSignRow = signStyle?.rowSelector ? signStyle.rowSelector(row, ri) : false;
return (
@@ -199,7 +203,7 @@ export default function LeftChartTable<T extends Record<string, unknown>>({
? raw
: String(raw);
const n = isSignRow ? parseNumber(raw) : null;
const n = c.numeric ? parseNumber(raw) : null;
const shouldSign = isSignRow && (signStyle?.keys ? signStyle.keys.includes(c.key) : !!c.numeric);
if (c.rowHead) {
@@ -216,13 +220,16 @@ export default function LeftChartTable<T extends Record<string, unknown>>({
}
if (!shouldSign) {
const numContent = c.numeric ? parseNumber(content) ?? 0 : 0;
const isStar = starUnder30Sample && sampleRow && numContent < 30;
return (
<td
key={String(c.key)}
className={cn(c.cellClassName)}
style={c.width ? { width: c.width } : undefined}
>
{content}
{isStar?`${content}*`:content}
</td>
);
}
@@ -236,8 +243,10 @@ export default function LeftChartTable<T extends Record<string, unknown>>({
);
}
const cls = n > 0 ? posCls : n < 0 ? negCls : zeroCls;
const txt = renderSigned(n, { display, showPlus, arrowWithNumber, zeroText });
return (
<td key={String(c.key)} className={cn(c.cellClassName, cls)}>
{txt}

View File

@@ -5,44 +5,17 @@ import {CategoryByData} from "@/components/lge-dashboard";
import {apiBrandShareByYear} from "@/config/sample.data";
import {PageData, ServerBannerRow} from "@/types/lg";
import {buildGapRow} from "@/lib/lg-dashboard";
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst";
import {BANNER_GROUP, BANNER_KEY_MAP, SITE_TITLE, YEARS} from "@/const/lgConst";
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
import {CategoryTypeValue} from "@/components/layout/CategoryFilter";
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
const Brand = () => {
const {filterValue, registerExcelExporter} = useLayoutFilter();
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => {
const cleaned = apiBrandShareByYear.filter(
(r) => !(r.year === LAST_YEAR && r.rowLabel === "gap")
);
const gapRow = buildGapRow(cleaned, 25, 26, "lg", "gap");
let finalData = cleaned;
if (gapRow) {
const insertIdx = cleaned.findIndex(
(r) => r.year === LAST_YEAR && r.rowLabel === "lg"
);
if (insertIdx >= 0) {
finalData = [
...cleaned.slice(0, insertIdx + 1),
gapRow,
...cleaned.slice(insertIdx + 1),
];
}
}
return [
{
title: "브랜드",
chartMode: "reverseStack",
data: finalData,
},
];
}, []);
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [
{title: "브랜드", chartMode:"reverseStack", data: apiBrandShareByYear},
], []);
useEffect(() => {
registerExcelExporter(async (payload) => {
@@ -63,7 +36,7 @@ const Brand = () => {
});
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
fileName: `${SITE_TITLE}(${sheetName}).xlsx`,
sheetName: sheetName,
sections: sections,
});
@@ -76,6 +49,7 @@ const Brand = () => {
{tableDataArray.map((tableData) => (
<CategoryByData
key={`cbd-${tableData.title.replaceAll(/\s+/g, "_")}`}
selectedYear={filterValue.year}
title={tableData.title}
chartMode={tableData.chartMode}
allTableData={tableData.data}

View File

@@ -1,11 +1,11 @@
'use client'
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
import {useEffect, useMemo} from "react";
import {useEffect, useMemo, useState} from "react";
import {PageData, ServerBannerRow} from "@/types/lg";
import {apiOwnershipPathByYear, apiOwnershipTriggerByYear} from "@/config/sample.data";
import {CategoryByData} from "@/components/lge-dashboard";
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst";
import {BANNER_GROUP, BANNER_KEY_MAP, SITE_TITLE, YEARS} from "@/const/lgConst";
import {CategoryTypeValue} from "@/components/layout/CategoryFilter";
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
@@ -14,8 +14,8 @@ const OwnershipPath = () => {
console.log(filterValue);
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [
{title: "보유 경로", chartMode:"reverseStack", data: apiOwnershipPathByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))},
{title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))},
{title: "보유 경로", chartMode:"reverseStack", data: apiOwnershipPathByYear},
{title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear, chartHeight: 550,},
], []);
useEffect(() => {
@@ -37,7 +37,7 @@ const OwnershipPath = () => {
});
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
fileName: `${SITE_TITLE}(${sheetName}).xlsx`,
sheetName: sheetName,
sections: sections,
});
@@ -50,6 +50,7 @@ const OwnershipPath = () => {
{tableDataArray.map((tableData) => (
<CategoryByData
key={`cbd-${tableData.title.replaceAll(/\s+/g, "_")}`}
selectedYear={filterValue.year}
title={tableData.title}
chartMode={tableData.chartMode}
allTableData={tableData.data}

View File

@@ -5,7 +5,7 @@ import {apiPaymentMethodByYear} from "@/config/sample.data";
import {useEffect, useMemo} from "react";
import {PageData, ServerBannerRow} from "@/types/lg";
import {CategoryByData} from "@/components/lge-dashboard";
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst";
import {BANNER_GROUP, BANNER_KEY_MAP, SITE_TITLE, YEARS} from "@/const/lgConst";
import {CategoryTypeValue} from "@/components/layout/CategoryFilter";
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
@@ -14,7 +14,7 @@ const PaymentMethod = () => {
console.log(filterValue);
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [
{title: "구매 형식", chartMode:"reverseStack", data: apiPaymentMethodByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))},
{title: "구매 형식", chartMode:"reverseStack", data: apiPaymentMethodByYear},
], []);
useEffect(() => {
@@ -36,7 +36,7 @@ const PaymentMethod = () => {
});
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
fileName: `${SITE_TITLE}(${sheetName}).xlsx`,
sheetName: sheetName,
sections: sections,
});
@@ -49,6 +49,7 @@ const PaymentMethod = () => {
{tableDataArray.map((tableData) => (
<CategoryByData
key={`cbd-${tableData.title.replaceAll(/\s+/g, "_")}`}
selectedYear={filterValue.year}
title={tableData.title}
chartMode={tableData.chartMode}
allTableData={tableData.data}

View File

@@ -13,7 +13,7 @@ const PenetrationChange = () => {
const penetrationChangeData = useMemo<ServerBannerRow[]>(() => apiYearIndex, []);
return(
<BannerSummary data={penetrationChangeData} useChart={true} />
<BannerSummary data={penetrationChangeData} useChart={true} useYear={false} />
);
}

View File

@@ -27,7 +27,7 @@ const Profile = () => {
}, [isTotal, filterValue]);
return (
<BannerSummary data={profileData} useChart={false} />
<BannerSummary data={profileData} useChart={false} useYear={true} />
);
}

View File

@@ -5,7 +5,7 @@ import {useEffect, useMemo} from "react";
import {PageData, ServerBannerRow} from "@/types/lg";
import { apiOwnershipPathByYear, apiOwnershipTriggerByYear} from "@/config/sample.data";
import {CategoryByData} from "@/components/lge-dashboard";
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst";
import {BANNER_GROUP, BANNER_KEY_MAP, SITE_TITLE, YEARS} from "@/const/lgConst";
import {CategoryTypeValue} from "@/components/layout/CategoryFilter";
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
@@ -14,8 +14,8 @@ const PurchaseBehavior = () => {
console.log(filterValue);
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [
{title: "보유 경로", chartMode:"horizontal", data: apiOwnershipPathByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))},
{title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))},
{title: "보유 경로", chartMode:"horizontal", data: apiOwnershipPathByYear},
{title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear},
], []);
useEffect(() => {
@@ -37,7 +37,7 @@ const PurchaseBehavior = () => {
});
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
fileName: `${SITE_TITLE}(${sheetName}).xlsx`,
sheetName: sheetName,
sections: sections,
});
@@ -50,6 +50,7 @@ const PurchaseBehavior = () => {
{tableDataArray.map((tableData) => (
<CategoryByData
key={`cbd-${tableData.title.replaceAll(/\s+/g, "_")}`}
selectedYear={filterValue.year}
title={tableData.title}
chartMode={tableData.chartMode}
allTableData={tableData.data}

View File

@@ -8,7 +8,7 @@ import {
import {useEffect, useMemo} from "react";
import {PageData, ServerBannerRow} from "@/types/lg";
import {CategoryByData} from "@/components/lge-dashboard";
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst";
import {BANNER_GROUP, BANNER_KEY_MAP, SITE_TITLE, YEARS} from "@/const/lgConst";
import {CategoryTypeValue} from "@/components/layout/CategoryFilter";
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
@@ -20,12 +20,12 @@ const PurchaseChannel = () => {
{
title: "구매 채널(온/오프라인)",
chartMode: "reverseStack",
data: apiPurchaseChannelSummaryByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")),
data: apiPurchaseChannelSummaryByYear,
},
{
title: "구매 채널(상세)",
chartMode: "horizontal",
data: apiPurchaseChannelByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")),
data: apiPurchaseChannelByYear,
chartHeight: 550,
},
], []);
@@ -49,7 +49,7 @@ const PurchaseChannel = () => {
});
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
fileName: `${SITE_TITLE}(${sheetName}).xlsx`,
sheetName: sheetName,
sections: sections,
});
@@ -62,6 +62,7 @@ const PurchaseChannel = () => {
{tableDataArray.map((tableData) => (
<CategoryByData
key={`cbd-${tableData.title.replaceAll(/\s+/g, "_")}`}
selectedYear={filterValue.year}
title={tableData.title}
chartMode={tableData.chartMode}
allTableData={tableData.data}

View File

@@ -5,7 +5,7 @@ import {useEffect, useMemo} from "react";
import {PageData, ServerBannerRow} from "@/types/lg";
import {apiFridgeDoorTypeByYear} from "@/config/sample.data";
import {CategoryByData} from "@/components/lge-dashboard";
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst";
import {BANNER_GROUP, BANNER_KEY_MAP, SITE_TITLE, YEARS} from "@/const/lgConst";
import {CategoryTypeValue} from "@/components/layout/CategoryFilter";
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
@@ -17,7 +17,7 @@ const TypeSpec = () => {
{
title: "타입",
chartMode: "horizontal",
data: apiFridgeDoorTypeByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")),
data: apiFridgeDoorTypeByYear,
},
], []);
@@ -40,7 +40,7 @@ const TypeSpec = () => {
});
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
fileName: `${SITE_TITLE}(${sheetName}).xlsx`,
sheetName: sheetName,
sections: sections,
});
@@ -53,6 +53,7 @@ const TypeSpec = () => {
{tableDataArray.map((tableData) => (
<CategoryByData
key={`cbd-${tableData.title.replaceAll(/\s+/g, "_")}`}
selectedYear={filterValue.year}
title={tableData.title}
chartMode={tableData.chartMode}
allTableData={tableData.data}

View File

@@ -5,6 +5,7 @@ import type React from "react";
import { cn, parseNumber } from "@/lib/utils";
import type { DataColumn, SignDisplayMode, SignStyle } from "../types";
import SectionTitle from "../SectionTitle";
import {isSampleRow} from "@/lib/lg-dashboard";
type Props<T extends Record<string, unknown>> = {
columns: DataColumn<T>[];
@@ -14,6 +15,7 @@ type Props<T extends Record<string, unknown>> = {
wrapperClassName?: string;
signStyle?: SignStyle<T>;
fillGreaterThan5?: boolean;
starUnder30Sample?: boolean;
};
// parseSignedNumber는 utils.ts의 parseNumber로 통합됨
@@ -55,6 +57,7 @@ const DataTable = <T extends Record<string, unknown>>({
wrapperClassName,
signStyle,
fillGreaterThan5 = false,
starUnder30Sample = false,
}: Props<T>) => {
const hasGroup = columns.some((c) => !!c.group) || columns.some((c) => c.headRowSpan === 2);
@@ -177,6 +180,7 @@ const DataTable = <T extends Record<string, unknown>>({
<tbody>
{rows.map((row, rIdx) => {
const sampleRow = isSampleRow(row.rowLabel as string ?? "");
const signRow = isSignRow(row, rIdx);
const total = parseNumber(row.total);
@@ -227,14 +231,15 @@ const DataTable = <T extends Record<string, unknown>>({
);
}
const numContent = c.numeric ? parseNumber(content) ?? 0 : 0;
const isFill = fillGreaterThan5 && total && numContent > total + 5;
const isStar = starUnder30Sample && sampleRow && numContent < 30;
return (
<td key={String(c.key)} style={{ textAlign: align }} className={
cn(c.cellClassName, isFill? "bg-red-200" :"")
}>
{content}
{isStar?`${content}*`:content}
</td>
);
})}

View File

@@ -290,8 +290,18 @@ export const apiLifeStageByProduct: ServerBannerRow[] = [
export const apiOwnershipSummary: ServerBannerRow[] = [
bannerRow("26", "사례수", "2000"),
bannerRow("26", "보유율", "85"),
bannerRow("26", "gap", "1"), // 26-25
bannerRow("26", "보유대수", "1.2"),
bannerRow("26", "gap", "5"), // 26-25
bannerRow("26", "보유대수", "1.3"),
bannerRow("25", "사례수", "2000"),
bannerRow("25", "보유율", "80"),
bannerRow("25", "gap", "4"), // 26-25
bannerRow("25", "보유대수", "1.2"),
bannerRow("24", "사례수", "2000"),
bannerRow("24", "보유율", "76"),
bannerRow("24", "gap", "-", ), // 26-25
bannerRow("24", "보유대수", "1.0"),
];
/** ---------------------------
@@ -315,8 +325,18 @@ export const apiYearIndex: ServerBannerRow[] = [
* 25/26 사례수 + 브랜드
* -------------------------- */
export const apiBrandShareByYear: ServerBannerRow[] = [
bannerRow("24", "사례수", "500"),
bannerRow("24", "lg", "46"),
bannerRow("24", "gap", "-"),
bannerRow("24", "삼성", "41"),
bannerRow("24", "위니아", "4"),
bannerRow("24", "캐리어", "4"),
bannerRow("24", "하이얼", "1"),
bannerRow("24", "기타", "4"),
bannerRow("25", "사례수", "500"),
bannerRow("25", "lg", "48"),
bannerRow("25", "gap", "2"),
bannerRow("25", "삼성", "40"),
bannerRow("25", "위니아", "4"),
bannerRow("25", "캐리어", "3"),
@@ -325,6 +345,7 @@ export const apiBrandShareByYear: ServerBannerRow[] = [
bannerRow("26", "사례수", "520"),
bannerRow("26", "lg", "47"),
bannerRow("26", "gap", "-1"),
bannerRow("26", "삼성", "40"),
bannerRow("26", "위니아", "5"),
bannerRow("26", "캐리어", "3"),
@@ -361,6 +382,12 @@ export const apiFridgeDoorTypeByYear: ServerBannerRow[] = [
* 25/26 사례수 + 보유 경로(구매 경로)
* -------------------------- */
export const apiOwnershipPathByYear: ServerBannerRow[] = [
bannerRow("24", "사례수", "520"),
bannerRow("24", "신규 구입", "7"),
bannerRow("24", "기존 제품 작동하나 신규 구입", "5"),
bannerRow("24", "기존 제품 고장으로 신규 구입", "30"),
bannerRow("24", "추가 구입", "58"),
bannerRow("25", "사례수", "520"),
bannerRow("25", "신규 구입", "8"),
bannerRow("25", "기존 제품 작동하나 신규 구입", "4"),
@@ -375,6 +402,17 @@ export const apiOwnershipPathByYear: ServerBannerRow[] = [
];
export const apiOwnershipTriggerByYear: ServerBannerRow[] = [
bannerRow("24", "사례수", "520"),
bannerRow("24", "오래되어 새로운 제품 교체 필요", "23"),
bannerRow("24", "이사로 인해 새로 구입", "22"),
bannerRow("24", "이전 제품 고장으로 새로 구입", "17"),
bannerRow("24", "새로운 기능/기술 사용하고 싶어서", "14"),
bannerRow("24", "리모델링, 인테리어 계기로 새로 구입", "7"),
bannerRow("24", "혼수로 장만", "7"),
bannerRow("24", "(결혼 외) 가구 분가/독립하게 되어서", "6"),
bannerRow("24", "가구 구성원이 늘어서", "3"),
bannerRow("24", "가구 구성원이 줄어서", '2'),
bannerRow("25", "사례수", "520"),
bannerRow("25", "오래되어 새로운 제품 교체 필요", "23"),
bannerRow("25", "이사로 인해 새로 구입", "22"),
@@ -404,6 +442,11 @@ export const apiOwnershipTriggerByYear: ServerBannerRow[] = [
* 25/26 결제수단
* -------------------------- */
export const apiPaymentMethodByYear: ServerBannerRow[] = [
bannerRow("24", "사례수", "650"),
bannerRow("24", "일시불", "60"),
bannerRow("24", "할부", "30"),
bannerRow("24", "렌탈", "10"),
bannerRow("25", "사례수", "650"),
bannerRow("25", "일시불", "60"),
bannerRow("25", "할부", "30"),
@@ -424,9 +467,21 @@ export const apiPurchaseRateKpis: ServerBannerRow[] = [
bannerRow("26", "사례수", "700"),
bannerRow("26", "구매율", "35"),
bannerRow("26", "gap", "2"), // 26-25
bannerRow("25", "사례수", "700"),
bannerRow("25", "구매율", "33"),
bannerRow("25", "gap", "5"), // 26-25
bannerRow("24", "사례수", "700"),
bannerRow("24", "구매율", "28"),
bannerRow("24", "gap", "-"), // 26-25
];
export const apiPurchaseChannelSummaryByYear: ServerBannerRow[] = [
bannerRow("24", "사례수", "650"),
bannerRow("24", "오프라인", "65"),
bannerRow("24", "온라인/홈쇼핑", "35"),
bannerRow("25", "사례수", "650"),
bannerRow("25", "오프라인", "60"),
bannerRow("25", "온라인/홈쇼핑", "40"),
@@ -442,6 +497,21 @@ export const apiPurchaseChannelSummaryByYear: ServerBannerRow[] = [
* 25/26 사례수 + 유통채널
* -------------------------- */
export const apiPurchaseChannelByYear: ServerBannerRow[] = [
bannerRow("24", "사례수", "650"),
bannerRow("24", "오프라인 단독 매장", "25"),
bannerRow("24", "전자제품 양판점", "20"),
bannerRow("24", "대형할인점", "10"),
bannerRow("24", "백화점", "5"),
bannerRow("24", "오픈마켓", "15"),
bannerRow("24", "제조사 공식 홈페이지", "8"),
bannerRow("24", "포털 쇼핑채널 입점몰", "4"),
bannerRow("24", "백화점 기반 쇼핑몰", "2"),
bannerRow("24", "TV 홈쇼핑", "3"),
bannerRow("24", "유통사 온라인 쇼핑몰", "4"),
bannerRow("24", "라이프스타일 쇼핑몰", "2"),
bannerRow("24", "해외 직구/대행 사이트", "1"),
bannerRow("24", "중고거래 사이트", "1"),
bannerRow("25", "사례수", "650"),
bannerRow("25", "오프라인 단독 매장", "25"),
bannerRow("25", "전자제품 양판점", "20"),

View File

@@ -1,3 +1,2 @@
export const UNKNOWN_HTTP_ERROR = 'UNKNOWN_HTTP_ERROR';
export const NONE_HTTP_ERROR = 'NONE_HTTP_ERROR';
export const DASHBOARD_YEAR = 2026;
export const NONE_HTTP_ERROR = 'NONE_HTTP_ERROR';

View File

@@ -1,36 +1,28 @@
import {BannerKey, LifeStageRow} from "@/types/lg";
import {GaugeColumn} from "@/components/lge-dashboard";
export const SITE_TITLE = 'LGE CX Dashboard';
export const PRODUCT_KEY_MAP = {
washingMachine: "세탁기",
refrigerator: "냉장고",
airConditioner: "에어컨",
tv: "TV",
microwave: "전자 레인지",
vacuumCleaner: "청소기",
laptop: "노트북",
kimchiRefrigerator: "김치 냉장고",
airFryer: "에어 프라이어",
tablet: "태블릿",
waterPurifier: "정수기",
monitor: "모니터",
airPurifier: "공기 청정기",
dryer: "건조기",
electricRange: "전기 레인지",
humidifier: "가습기",
dehumidifier: "제습기",
oven: "오븐",
robotVacuum: "로봇 청소기",
dishwasher: "식기 세척기",
massageChair: "안마 의자",
clothingCareSystem: "의류 관리기",
waterPurifier: "정수기",
electricRange: "전기 레인지",
foodWasteDisposer: "음식물처리기",
projector: "빔프로젝터",
comboAirCareProduct: "복합 에어케어 제품",
ventilationSystem: "환기 시스템",
wineCellar: "와인 셀러",
premiumBathroomVentFan: "프리미엄 욕실 환풍기",
shoeCareSystem: "신발 관리기",
washingMachine: "세탁기",
dryer: "건조기",
vacuumCleaner: "청소기",
robotVacuum: "로봇 청소기",
clothingCareSystem: "의류 관리기",
airConditioner: "에어컨",
airPurifier: "공기 청정기",
tv: "TV",
monitor: "모니터",
laptop: "노트북",
} as const;
export const BANNER_KEY_MAP = {
@@ -115,7 +107,7 @@ export const LIFE_STAGE_GROUPS = [
export const PRODUCT_KEYS = Object.keys(PRODUCT_KEY_MAP) as Array<keyof typeof PRODUCT_KEY_MAP>;
export const PRODUCTS = Object.values(PRODUCT_KEY_MAP) as Array<string>;
export const YEARS = ["24", "25", "26"];
export const LAST_YEAR = YEARS.at(-1);
export const LAST_YEAR = YEARS.at(-1)!;
export const BRAND_LIST = ['Cbrand', 'Samsung', 'LG'];
/** X 축 패딩 없앤 GridOption*/
@@ -132,12 +124,8 @@ export const PRODUCTS_FILTER_ITEM = [
PRODUCT_KEY_MAP.refrigerator, // 냉장고
PRODUCT_KEY_MAP.kimchiRefrigerator, // 김치 냉장고
PRODUCT_KEY_MAP.dishwasher, // 식기 세척기
PRODUCT_KEY_MAP.microwave, // 전자 레인지
PRODUCT_KEY_MAP.electricRange, // 전기 레인지
PRODUCT_KEY_MAP.oven, // 오븐
PRODUCT_KEY_MAP.waterPurifier, // 정수기
PRODUCT_KEY_MAP.electricRange, // 전기 레인지
PRODUCT_KEY_MAP.foodWasteDisposer, // 음식물처리기
],
},
@@ -149,8 +137,6 @@ export const PRODUCTS_FILTER_ITEM = [
PRODUCT_KEY_MAP.vacuumCleaner, // 청소기
PRODUCT_KEY_MAP.robotVacuum, // 로봇 청소기
PRODUCT_KEY_MAP.clothingCareSystem, // 의류 관리기
PRODUCT_KEY_MAP.massageChair, // 안마 의자
PRODUCT_KEY_MAP.shoeCareSystem, // 신발 관리기
],
},
{
@@ -158,11 +144,6 @@ export const PRODUCTS_FILTER_ITEM = [
items: [
PRODUCT_KEY_MAP.airConditioner, // 에어컨
PRODUCT_KEY_MAP.airPurifier, // 공기 청정기
PRODUCT_KEY_MAP.humidifier, // 가습기
PRODUCT_KEY_MAP.dehumidifier, // 제습기
PRODUCT_KEY_MAP.comboAirCareProduct, // 복합 에어케어 제품
PRODUCT_KEY_MAP.ventilationSystem, // 환기 시스템
PRODUCT_KEY_MAP.premiumBathroomVentFan // 프리미엄 욕실 환풍기
],
},
{
@@ -171,8 +152,6 @@ export const PRODUCTS_FILTER_ITEM = [
PRODUCT_KEY_MAP.tv, // TV
PRODUCT_KEY_MAP.monitor, // 모니터
PRODUCT_KEY_MAP.laptop, // 노트북
PRODUCT_KEY_MAP.tablet, // 태블릿
PRODUCT_KEY_MAP.projector, // 빔프로젝터
],
},
] as const;
@@ -229,4 +208,6 @@ export const BANNER_GROUP = {
label: "소득수준",
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

@@ -3,7 +3,7 @@ import {ChartData} from "@/components/lge-dashboard";
import {BANNER_GROUP} from "@/const/lgConst";
import {formatNumber} from "@/lib/utils";
export const isSampleRow = (raw: string) => raw.replace(/\s+/g, "") === "사례수";
export const isSampleRow = (raw: string) => raw.replace(/\s+/g, "").includes("사례수");
/**
* Row Label을 표시용 텍스트로 포맷팅합니다.

View File

@@ -133,6 +133,9 @@ export function parseNumber(
if (s === "" || s === "-" || s === "−") return null;
s = s.replaceAll("(", "");
s = s.replaceAll(")", "");
if (allowComma) s = s.replaceAll(",", "");
if (allowPercent) s = s.replaceAll("%", "");
if (allowMinus) s = s.replaceAll("−", "-"); // 유니코드 마이너스 -> ASCII 마이너스