260330_02_ENH: 연도별 사례수 row에서 Column으로 이동

This commit is contained in:
2026-03-30 16:59:51 +09:00
parent 7f9465e96f
commit a0ee062899
8 changed files with 66 additions and 32 deletions

View File

@@ -83,23 +83,29 @@ const LGPenetrationPage = () => {
const penetrationRows =
data?.statisticsDataMap?.penetration
.filter((r) => r.rowLabel == `보유` || r.rowLabel == `사례수`)
.filter((r) => r.rowLabel == `보유`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
const rowSample = data?.statisticsDataMap?.penetration
.find(r => r.rowLabel == '사례수' && r.year == row.year)?.total ?? 0;
return {
...row,
rowLabel: rowLabel,
rowLabel: row.year,
sample: `(${rowSample})`,
}
}) ?? [];
const penetrationLGRows =
data?.statisticsDataMap?.penetration_lg
.filter((r) => r.rowLabel == `보유` || r.rowLabel == `사례수`)
.filter((r) => r.rowLabel == `보유`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
const rowSample = data?.statisticsDataMap?.penetration_lg
.find(r => r.rowLabel == '사례수' && r.year == row.year)?.total ?? 0;
return {
...row,
rowLabel: rowLabel,
rowLabel: row.year,
sample: `(${rowSample})`,
}
}) ?? [];
@@ -124,7 +130,7 @@ const LGPenetrationPage = () => {
}, [penetrationLGRows]);
const penetrationLGRowsWithGap = useMemo(() => {
const withGap = withGapRow(penetrationLGRows, calcGapProductRow, -1, -3);
const withGap = withGapRow(penetrationLGRows, calcGapProductRow, -1, -2);
return withTotalBaseRow("보급률",penetrationRows, wrapSampleRow(withGap, false), calcTotalBaseRow);
}, [penetrationRows, penetrationLGRows]);
@@ -132,6 +138,7 @@ const LGPenetrationPage = () => {
const productTableRows = useMemo<TopChartTableRow[]>(() => {
return penetrationLGRowsWithGap.map((row) => ({
label: formatRowLabel(row.rowLabel),
sample: row.sample,
total: row.total,
values: includeProductKeys.map((k) => (row as any)[k] ?? null),
}));
@@ -204,7 +211,7 @@ const LGPenetrationPage = () => {
useEffect(() => {
registerExcelExporter(async () => {
const excelHeader = buildHeader_ProductKeyMap(productKeyMap);
const excelHeader = buildHeader_ProductKeyMap(productKeyMap, "sample");
const lifeStageHeader = buildHeader_LifeStageColumns(LIFE_STAGE_COLUMNS);
type AnyRow = Record<string, any>;

View File

@@ -55,28 +55,34 @@ const LGPurchasePage = () => {
const purchaseRows =
data?.statisticsDataMap?.purchase
.filter((r) => r.rowLabel == `구매` || r.rowLabel == `사례수`)
.filter((r) => r.rowLabel == `구매`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
const rowSample = data?.statisticsDataMap?.purchase
.find(r => r.rowLabel == '사례수' && r.year == row.year)?.total ?? 0;
return {
...row,
rowLabel: rowLabel,
rowLabel: row.year,
sample: `(${rowSample})`,
}
}) ?? [];
const purchaseLGRows =
data?.statisticsDataMap?.purchase_lg
.filter((row) => row.rowLabel === `구입` || row.rowLabel == `사례수`)
.filter((row) => row.rowLabel === `구입`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
const rowSample = data?.statisticsDataMap?.purchase_lg
.find(r => r.rowLabel == '사례수' && r.year == row.year)?.total ?? 0;
return {
...row,
rowLabel: rowLabel,
rowLabel: row.year,
sample: `(${rowSample})`,
}
}) ?? [];
const purchaseLGRowsWithGap = useMemo(() => {
const withGap = withGapRow(wrapSampleRow(purchaseLGRows, false), calcGapProductRow, -1, -3);
const withGap = withGapRow(wrapSampleRow(purchaseLGRows, false), calcGapProductRow, -1, -2);
return withTotalBaseRow("구입율",purchaseRows, withGap, calcTotalBaseRow);
}, [purchaseRows, purchaseLGRows]);
@@ -99,6 +105,7 @@ const LGPurchasePage = () => {
const purchaseTableRows = useMemo<TopChartTableRow[]>(() => {
return purchaseLGRowsWithGap.map((row) => ({
label: formatRowLabel(row.rowLabel),
sample: row.sample,
total: row.total,
values: includeProductKeys.map((k) => (row as any)[k] ?? null),
}));
@@ -146,7 +153,7 @@ const LGPurchasePage = () => {
useEffect(() => {
registerExcelExporter(async () => {
const excelHeader = buildHeader_ProductKeyMap(productKeyMap);
const excelHeader = buildHeader_ProductKeyMap(productKeyMap, "sample");
await exportDashboardExcel({
fileName: `${SITE_TITLE}(LG제품 구매율).xlsx`,

View File

@@ -56,12 +56,15 @@ const PenetrationPage = () => {
const penetrationRows =
data?.statisticsDataMap?.penetration
.filter((r) => r.rowLabel == `보유` || r.rowLabel == `사례수`)
.filter((r) => r.rowLabel == `보유`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
const rowSample = data?.statisticsDataMap?.penetration
.find(r => r.rowLabel == '사례수' && r.year == row.year)?.total ?? 0;
return {
...row,
rowLabel: rowLabel,
rowLabel: row.year,
sample: `(${rowSample})`,
}
}) ?? [];
@@ -77,8 +80,8 @@ const PenetrationPage = () => {
});
const penetrationRowsWithGapCagr = useMemo(() => {
const withGap = withGapRow(penetrationRows, calcGapProductRow, -1, -3);
const withCagr = withCagrRow(withGap, calcCagrRow, -1, 2);
const withGap = withGapRow(penetrationRows, calcGapProductRow, -1, -2);
const withCagr = withCagrRow(withGap, calcCagrRow, -1, 1);
withCagr.forEach((row) => {
if (row.rowLabel !== "CAGR") {
@@ -94,6 +97,7 @@ const PenetrationPage = () => {
const productTableRows = useMemo<TopChartTableRow[]>(() => {
return penetrationRowsWithGapCagr.map((row) => ({
label: formatRowLabel(row.rowLabel),
sample: row.sample,
total: row.total,
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
}))
@@ -102,7 +106,7 @@ const PenetrationPage = () => {
const productChartData = useMemo<ChartData>(() => {
return {
categories: [...PRODUCTS],
series: penetrationRows.filter((r) => !r.rowLabel.includes("사례수"))
series: penetrationRows
.map((row) => ({
name: row.year,
data: PRODUCT_KEYS.map((k) => toNumOr0((row as any)[k])),
@@ -144,7 +148,8 @@ const PenetrationPage = () => {
useEffect(() => {
registerExcelExporter(async () => {
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP);
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP, "sample");
const brandHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP);
type AnyRow = Record<string, any>;
const sections: Section<AnyRow>[] = [
@@ -152,7 +157,7 @@ const PenetrationPage = () => {
...YEARS.map((year) => (
{
title: `브랜드 별 점유율_${year}년`,
header: excelHeader,
header: brandHeader,
rows: penetrationBrandRows.filter((row) => row.year === year),
rowGap: 1,
}

View File

@@ -55,22 +55,26 @@ const PurchasePage = () => {
const purchaseRows =
data?.statisticsDataMap?.purchase
.filter((r) => r.rowLabel == `구매` || r.rowLabel == `사례수`)
.filter((r) => r.rowLabel == `구매`)
.map((row) => {
const rowLabel = row.rowLabel == `사례수`? `${formatRowLabel(row.year)} ${row.rowLabel}` : row.year;
const rowSample = data?.statisticsDataMap?.purchase
.find(r => r.rowLabel == '사례수' && r.year == row.year)?.total ?? 0;
return {
...row,
rowLabel: rowLabel,
rowLabel: row.year,
sample: `(${rowSample})`,
}
}) ?? [];
const purchaseRowsWithGap = useMemo(() => {
return withGapRow(wrapSampleRow(purchaseRows, false), calcGapProductRow, -1, -3);
return withGapRow(wrapSampleRow(purchaseRows, false), calcGapProductRow, -1, -2);
}, [purchaseRows]);
const purchaseTableRows = useMemo<TopChartTableRow[]>(() => {
return purchaseRowsWithGap.map((row) => ({
label: formatRowLabel(row.rowLabel),
sample: row.sample,
total: row.total,
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
}));
@@ -100,7 +104,7 @@ const PurchasePage = () => {
useEffect(() => {
registerExcelExporter(async () => {
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP);
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP, "sample");
await exportDashboardExcel({
fileName: `${SITE_TITLE}(구매율).xlsx`,