260330_01_ENH: 26일자 수정사항 반영(라이프스테이지 중분류 제외)

This commit is contained in:
2026-03-30 13:18:08 +09:00
parent ee8bb13209
commit 7f9465e96f
19 changed files with 203 additions and 94 deletions

View File

@@ -1,7 +1,9 @@
'use client'
import {DataColumn} from "@/components/lge-dashboard";
import BannerSummary from "@/components/lge-dashboard/combo/BannerSummary";
import {useMemo} from "react";
import {parseNumber} from "@/lib/utils";
import {BannerRow} from "@/types/lg.types";
import {CategoryPageProps} from "../../sub-page/CategoryPage";
import {LAST_YEAR} from "@/const/lg-common.const";
@@ -30,8 +32,33 @@ const PenetrationChange = ({
return tempProfileData;
}, [dataMap]);
const getCellClassName = (row: BannerRow, column: DataColumn<BannerRow>, rowIndex: number) => {
const currentYear = Number(row.year);
if (currentYear !== 2024 && currentYear !== 2025) return undefined;
if (column.key === "rowLabel" || column.key === "total") return undefined;
const prevRow = penetrationChangeData[rowIndex - 1];
if (!prevRow || Number(prevRow.year) !== currentYear - 1) return undefined;
const currentValue = parseNumber(row[column.key]);
const prevValue = parseNumber(prevRow[column.key]);
if (currentValue === null || prevValue === null) return undefined;
const gap = currentValue - prevValue;
if (gap >= 3) return "lg-num-pos";
if (gap <= -3) return "lg-num-neg";
return undefined;
};
return(
<BannerSummary data={penetrationChangeData} useChart={true} useYear={false} />
<BannerSummary
data={penetrationChangeData}
useChart={true}
useYear={false}
getCellClassName={getCellClassName}
/>
);
}

View File

@@ -28,7 +28,7 @@ import {
calcGapProductRow, calcTotalBaseRow,
formatRowLabel,
normalizeFilterCondition,
withGapRow, withTotalBaseRow
withGapRow, withTotalBaseRow, wrapSampleRow
} from "@/lib/lg-dashboard";
import {
buildHeader_LifeStageColumns,
@@ -83,21 +83,23 @@ const LGPenetrationPage = () => {
const penetrationRows =
data?.statisticsDataMap?.penetration
.filter((r) => r.rowLabel == `보유`)
.filter((r) => r.rowLabel == `보유` || r.rowLabel == `사례수`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
return {
...row,
rowLabel: row.year,
rowLabel: rowLabel,
}
}) ?? [];
const penetrationLGRows =
data?.statisticsDataMap?.penetration_lg
.filter((row) => row.rowLabel === `보유`)
.filter((r) => r.rowLabel == `보유` || r.rowLabel == `사례수`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
return {
...row,
rowLabel: row.year,
rowLabel: rowLabel,
}
}) ?? [];
@@ -122,8 +124,9 @@ const LGPenetrationPage = () => {
}, [penetrationLGRows]);
const penetrationLGRowsWithGap = useMemo(() => {
const withGap = withGapRow(penetrationLGRows, calcGapProductRow);
return withTotalBaseRow("보급률",penetrationRows, withGap, calcTotalBaseRow);
const withGap = withGapRow(penetrationLGRows, calcGapProductRow, -1, -3);
return withTotalBaseRow("보급률",penetrationRows, wrapSampleRow(withGap, false), calcTotalBaseRow);
}, [penetrationRows, penetrationLGRows]);
const productTableRows = useMemo<TopChartTableRow[]>(() => {

View File

@@ -25,7 +25,7 @@ import {
calcGapProductRow, calcTotalBaseRow,
formatRowLabel,
normalizeFilterCondition,
withGapRow, withTotalBaseRow
withGapRow, withTotalBaseRow, wrapSampleRow
} from "@/lib/lg-dashboard";
import {buildHeader_ProductKeyMap, exportDashboardExcel} from "@/lib/lg-export-excel";
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
@@ -55,26 +55,28 @@ const LGPurchasePage = () => {
const purchaseRows =
data?.statisticsDataMap?.purchase
.filter((r) => r.rowLabel == `구매`)
.filter((r) => r.rowLabel == `구매` || r.rowLabel == `사례수`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
return {
...row,
rowLabel: row.year,
rowLabel: rowLabel,
}
}) ?? [];
const purchaseLGRows =
data?.statisticsDataMap?.purchase_lg
.filter((row) => row.rowLabel === `구입`)
.filter((row) => row.rowLabel === `구입` || row.rowLabel == `사례수`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
return {
...row,
rowLabel: row.year,
rowLabel: rowLabel,
}
}) ?? [];
const purchaseLGRowsWithGap = useMemo(() => {
const withGap = withGapRow(purchaseLGRows, calcGapProductRow);
const withGap = withGapRow(wrapSampleRow(purchaseLGRows, false), calcGapProductRow, -1, -3);
return withTotalBaseRow("구입율",purchaseRows, withGap, calcTotalBaseRow);
}, [purchaseRows, purchaseLGRows]);

View File

@@ -25,7 +25,7 @@ import { AXIS_HIDE_STYLE, GRID_X_NOT_PADDING } from "@/components/lge-dashboard/
import {
calcCagrRow, calcGapProductRow,
formatRowLabel,
normalizeFilterCondition, withCagrRow, withGapRow
normalizeFilterCondition, withCagrRow, withGapRow, wrapSampleRow
} from "@/lib/lg-dashboard";
import {buildHeader_ProductKeyMap, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
import {StatisticsRequest} from "@/types/lg.types";
@@ -56,21 +56,39 @@ const PenetrationPage = () => {
const penetrationRows =
data?.statisticsDataMap?.penetration
.filter((r) => r.rowLabel == `보유`)
.filter((r) => r.rowLabel == `보유` || r.rowLabel == `사례수`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
return {
...row,
rowLabel: row.year,
rowLabel: rowLabel,
}
}) ?? [];
const penetrationBrandRows =
const penetrationBrandRows = (
data?.statisticsDataMap?.penetration_brand
.filter((row) => BRAND_LIST.includes(row.rowLabel)) ?? [];
?.filter((row) => BRAND_LIST.includes(row.rowLabel)) ?? []
).map((row) => {
PRODUCT_KEYS.forEach((k) => {
(row as any)[k] = Number((row as any)[k]).toFixed(0);
});
return row;
});
const penetrationRowsWithGapCagr = useMemo(() => {
const withGap = withGapRow(penetrationRows, calcGapProductRow);
return withCagrRow(withGap, calcCagrRow);
const withGap = withGapRow(penetrationRows, calcGapProductRow, -1, -3);
const withCagr = withCagrRow(withGap, calcCagrRow, -1, 2);
withCagr.forEach((row) => {
if (row.rowLabel !== "CAGR") {
PRODUCT_KEYS.forEach((k) => {
(row as any)[k] = Number((row as any)[k]).toFixed(0);
});
}
});
return wrapSampleRow(withCagr, false);
}, [penetrationRows]);
const productTableRows = useMemo<TopChartTableRow[]>(() => {
@@ -84,7 +102,7 @@ const PenetrationPage = () => {
const productChartData = useMemo<ChartData>(() => {
return {
categories: [...PRODUCTS],
series: penetrationRows
series: penetrationRows.filter((r) => !r.rowLabel.includes("사례수"))
.map((row) => ({
name: row.year,
data: PRODUCT_KEYS.map((k) => toNumOr0((row as any)[k])),
@@ -148,7 +166,7 @@ const PenetrationPage = () => {
});
});
return () => registerExcelExporter(null);
}, [registerExcelExporter, penetrationRows, penetrationBrandRows]);
}, [registerExcelExporter, penetrationRowsWithGapCagr, penetrationBrandRows]);
return (
<div>
@@ -158,12 +176,12 @@ const PenetrationPage = () => {
variant={isBrandShare ? "default" : "secondary"}
onClick={() => setIsBrandShare((v) => !v)}
>
{"브랜드별 점유율"}
{"브랜드 점유율 변화"}
</Button>
</div>
<TopChartTable
title={isBrandShare ? "브랜드별 점유율" : "전체 보급률"}
title={isBrandShare ? "브랜드 점유율 변화" : "전체 보급률"}
categories={[...PRODUCTS]}
rows={productTableRows}
chart={
@@ -174,7 +192,7 @@ const PenetrationPage = () => {
xAxis={{ type: "category", data: PRODUCTS, ...AXIS_HIDE_STYLE }}
yAxis={{ type: "value", ...AXIS_HIDE_STYLE }}
showFocusLabel={"none"}
yearBrandPalette={["--chart-lg","--chart-samsung","--chart-cbrand"]}
yearBrandPalette={[ "--chart-etc", "--chart-cbrand","--chart-samsung","--chart-lg"]}
height={260}
/>
) : (
@@ -192,6 +210,7 @@ const PenetrationPage = () => {
signStyle={signStyleGapRow}
fillCAGR={true}
/>
<BottomDescription description={"CAGR(%) 5%p 이상 품목에 대해 음영 표시"} />
<BottomDescription description={description} />
</div>
);

View File

@@ -21,7 +21,13 @@ import {
VerticalBar,
} from "@/components/lge-dashboard";
import { useLayoutFilter } from "@/components/layout/LayoutFilterContext";
import {calcGapProductRow, formatRowLabel, normalizeFilterCondition, withGapRow} from "@/lib/lg-dashboard";
import {
calcGapProductRow,
formatRowLabel,
normalizeFilterCondition,
withGapRow,
wrapSampleRow
} from "@/lib/lg-dashboard";
import {buildHeader_ProductKeyMap, exportDashboardExcel} from "@/lib/lg-export-excel";
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
import {SelectedMap} from "@/types/common";
@@ -49,16 +55,17 @@ const PurchasePage = () => {
const purchaseRows =
data?.statisticsDataMap?.purchase
.filter((r) => r.rowLabel == `구매`)
.filter((r) => r.rowLabel == `구매` || r.rowLabel == `사례수`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
return {
...row,
rowLabel: row.year,
rowLabel: rowLabel,
}
}) ?? [];
const purchaseRowsWithGap = useMemo(() => {
return withGapRow(purchaseRows, calcGapProductRow);
return withGapRow(wrapSampleRow(purchaseRows, false), calcGapProductRow, -1, -3);
}, [purchaseRows]);
const purchaseTableRows = useMemo<TopChartTableRow[]>(() => {
@@ -72,7 +79,7 @@ const PurchasePage = () => {
const purchaseChartData = useMemo<ChartData>(() => {
return {
categories: [...PRODUCTS],
series: purchaseRows
series: purchaseRows.filter((r) => !r.rowLabel.includes("사례수"))
.map((r) => ({
name: r.rowLabel,
data: PRODUCT_KEYS.map((k) => (r as any)[k] ?? null),

View File

@@ -123,11 +123,6 @@
--lg-orange-500: 29.6 95% 56.0%;
--lg-orange-400: 29.6 85% 68.0%;
--lg-orange-300: 29.6 75% 78.0%;
--samsung-blue-600: 218.93 53.91% 52.35%; /* #4472C7 */
--samsung-blue-500: 218.93 48.0% 56.0%; /* #597FC5 */
--samsung-blue-400: 218.93 40.0% 66.0%; /* #869ECB */
--samsung-blue-300: 218.93 33.0% 76.0%; /* #AEBCD6 */
/* =============================
Brand Core
(semantic은 "실제 색"으로 정의)
@@ -172,23 +167,25 @@
--chart-2-t: 0 0% 70%;
--chart-3-t: 0 0% 88%;
--chart-stack-1: 334 81% 41%;
--chart-stack-2: 334 81% 53%;
--chart-stack-3: 334 82% 64%;
--chart-stack-4: 335 82% 75%;
--chart-stack-5: 335 83% 84%;
--chart-stack-6: 17 80% 84%;
--chart-stack-7: 17 80% 73%;
--chart-stack-8: 0 0% 25%;
--chart-stack-9: 0 0% 37%;
--chart-stack-10: 0 0% 49%;
--chart-stack-11: 0 0% 61%;
--chart-stack-12: 0 0% 73%;
--chart-stack-13: 0 0% 85%;
--chart-stack-1: 335 64% 34%;
--chart-stack-2: 332 65% 57%;
--chart-stack-3: 334 66% 73%;
--chart-stack-4: 334 28% 49%;
--chart-stack-5: 340 25% 58%;
--chart-stack-6: 0 28% 69%;
--chart-stack-7: 26 37% 70%;
--chart-stack-8: 27 38% 83%;
--chart-stack-9: 30 45% 91%;
--chart-stack-10: 0 0% 50%;
--chart-stack-11: 0 0% 60%;
--chart-stack-12: 0 0% 71%;
--chart-stack-13: 0 0% 82%;
--chart-stack-14: 0 0% 91%;
--chart-lg: var(--chart-1);
--chart-samsung: 218 48% 58%;
--chart-cbrand: var(--chart-2);
--chart-etc: 0 0% 74%;
--chart-border: hsl(0 0% 95%);