260330_01_ENH: 26일자 수정사항 반영(라이프스테이지 중분류 제외)
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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[]>(() => {
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user