260127_01_ENH: 커스텀 컴포넌트들 1차 완성 및 일부페이지에 SampleData 적용
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
'use client'
|
||||
|
||||
const AirSolutionPage = () => {
|
||||
return (
|
||||
<div>AirSolutionPage</div>
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
'use client'
|
||||
|
||||
const HAKitchenPage = () => {
|
||||
return (
|
||||
<div>HAKitchenPage</div>
|
||||
<div>
|
||||
<div>HAKitchenPage</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use client'
|
||||
|
||||
const HALivingPage = () => {
|
||||
return (
|
||||
<div>HALivingPage</div>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use client'
|
||||
|
||||
const MSDigitalPage = () => {
|
||||
return (
|
||||
<div>MSDigitalPage</div>
|
||||
|
||||
@@ -1,6 +1,76 @@
|
||||
'use client'
|
||||
|
||||
import {Button} from "@/components/ui/button";
|
||||
import TopChartTable from "../../../../../components/lge-dashboard/combo/TopChartTable";
|
||||
import {
|
||||
GroupedOverlayBar, GroupedOverlayBarData,
|
||||
signStyleGapRow, TopChartTableRow
|
||||
} from "@/components/lge-dashboard";
|
||||
import {PRODUCT_KEYS, PRODUCTS, YEARS} from "@/const/lgConst";
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import {useEffect} from "react";
|
||||
import {apiOwnShareOfTotalPenetration, apiTrendCategories} from "@/config/sample.data";
|
||||
|
||||
const LGPenetrationPage = () => {
|
||||
|
||||
const displayRowLabel = (i:number, rowLabel: string) => {
|
||||
if (rowLabel === "gap") return "전년 대비 GAP(%)";
|
||||
return rowLabel;
|
||||
};
|
||||
|
||||
const productTableRows: TopChartTableRow[] = apiOwnShareOfTotalPenetration.map((row, i) => ({
|
||||
label: displayRowLabel(i, row.rowLabel),
|
||||
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
||||
}));
|
||||
|
||||
const total: Array<Array<number>> = YEARS.map(() => Array(PRODUCT_KEYS.length).fill(0));
|
||||
const focus: Array<Array<number>> = YEARS.map(() => Array(PRODUCT_KEYS.length).fill(0));
|
||||
|
||||
const yearIndexMap = new Map<number, number>(YEARS.map((y, i) => [y, i]));
|
||||
|
||||
const totalRows = apiTrendCategories.filter((r) => YEARS.includes(r.year as any) && r.rowLabel.endsWith("년"));
|
||||
const lgRows = apiOwnShareOfTotalPenetration.filter((r) => YEARS.includes(r.year as any) && r.rowLabel.endsWith("년"));
|
||||
|
||||
lgRows.forEach((r, ri) => {
|
||||
const yi = yearIndexMap.get(r.year);
|
||||
if (yi == null) return;
|
||||
|
||||
for (let ci = 0; ci < PRODUCT_KEYS.length; ci++) {
|
||||
const k = PRODUCT_KEYS[ci];
|
||||
const t = (totalRows[ri] as any)[k];
|
||||
const v = (r as any)[k];
|
||||
// total/focus 모두 같은 값(“전체 보급률 중 자사제품 비율”이므로)
|
||||
total[yi][ci] = typeof v === "number" ? t : 0;
|
||||
focus[yi][ci] = typeof v === "number" ? v : 0;
|
||||
}
|
||||
})
|
||||
|
||||
const productChartData: GroupedOverlayBarData = {
|
||||
categories: PRODUCTS,
|
||||
years: YEARS,
|
||||
totalName: "전체",
|
||||
focusName: "LG",
|
||||
total: total,
|
||||
focus: focus,
|
||||
}
|
||||
|
||||
return (
|
||||
<div>LGPenetrationPage</div>
|
||||
<div>
|
||||
<TopChartTable
|
||||
title={"LG제품 보급률"}
|
||||
categories={[...PRODUCTS]}
|
||||
rows={productTableRows}
|
||||
chart={
|
||||
<GroupedOverlayBar
|
||||
data={productChartData}
|
||||
yearTotalColor={{ "24": "--chart-total-1", "25": "--chart-total-2", "26": "--chart-total-3" }}
|
||||
yearFocusColor={{ "24": "--chart-lg-1", "25": "--chart-lg-2", "26": "--chart-lg-3" }}
|
||||
showFocusLabel={"last"}
|
||||
/>
|
||||
}
|
||||
signStyle={signStyleGapRow}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,69 @@
|
||||
'use client'
|
||||
|
||||
import TopChartTable from "../../../../../components/lge-dashboard/combo/TopChartTable";
|
||||
import {PRODUCT_KEYS, PRODUCTS, YEARS} from "@/const/lgConst";
|
||||
import {GroupedOverlayBar, GroupedOverlayBarData, signStyleGapRow, TopChartTableRow} from "@/components/lge-dashboard";
|
||||
import { apiOwnShareOfTotalPurchase, apiTrendBuy} from "@/config/sample.data";
|
||||
|
||||
const LGPurchasePage = () => {
|
||||
const displayRowLabel = (i:number, rowLabel: string) => {
|
||||
if (rowLabel === "gap") return "전년 대비 GAP(%)";
|
||||
return rowLabel;
|
||||
};
|
||||
|
||||
const purchaseTableRows: TopChartTableRow[] = apiOwnShareOfTotalPurchase.map((row, i) => ({
|
||||
label: displayRowLabel(i, row.rowLabel),
|
||||
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
||||
}));
|
||||
|
||||
const total: Array<Array<number>> = YEARS.map(() => Array(PRODUCT_KEYS.length).fill(0));
|
||||
const focus: Array<Array<number>> = YEARS.map(() => Array(PRODUCT_KEYS.length).fill(0));
|
||||
|
||||
const yearIndexMap = new Map<number, number>(YEARS.map((y, i) => [y, i]));
|
||||
|
||||
const totalRows = apiTrendBuy.filter((r) => YEARS.includes(r.year as any) && r.rowLabel.endsWith("년"));
|
||||
const lgRows = apiOwnShareOfTotalPurchase.filter((r) => YEARS.includes(r.year as any) && r.rowLabel.endsWith("년"));
|
||||
|
||||
lgRows.forEach((r, ri) => {
|
||||
const yi = yearIndexMap.get(r.year);
|
||||
if (yi == null) return;
|
||||
|
||||
for (let ci = 0; ci < PRODUCT_KEYS.length; ci++) {
|
||||
const k = PRODUCT_KEYS[ci];
|
||||
const t = (totalRows[ri] as any)[k];
|
||||
const v = (r as any)[k];
|
||||
// total/focus 모두 같은 값(“전체 보급률 중 자사제품 비율”이므로)
|
||||
total[yi][ci] = typeof v === "number" ? t : 0;
|
||||
focus[yi][ci] = typeof v === "number" ? v : 0;
|
||||
}
|
||||
})
|
||||
|
||||
const purchaseChartData: GroupedOverlayBarData = {
|
||||
categories: PRODUCTS,
|
||||
years: YEARS,
|
||||
totalName: "전체",
|
||||
focusName: "LG",
|
||||
total: total,
|
||||
focus: focus,
|
||||
}
|
||||
|
||||
return (
|
||||
<div>LGPurchasePage</div>
|
||||
<div>
|
||||
<TopChartTable
|
||||
title={"LG제품 구매율"}
|
||||
categories={[...PRODUCTS]}
|
||||
rows={purchaseTableRows}
|
||||
chart={
|
||||
<GroupedOverlayBar
|
||||
data={purchaseChartData}
|
||||
yearTotalColor={{ "24": "--chart-total-1", "25": "--chart-total-2", "26": "--chart-total-3" }}
|
||||
yearFocusColor={{ "24": "--chart-lg-1", "25": "--chart-lg-2", "26": "--chart-lg-3" }}
|
||||
showFocusLabel={"last"}
|
||||
/>
|
||||
}
|
||||
signStyle={signStyleGapRow}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,122 @@
|
||||
'use client'
|
||||
|
||||
import {useEffect, useState} from "react";
|
||||
import TopChartTable from "@/components/lge-dashboard/combo/TopChartTable";
|
||||
|
||||
import VerticalBar from "@/components/lge-dashboard/chart/VerticalBar";
|
||||
import {
|
||||
AXIS_HIDE_STYLE, ChartData,
|
||||
GRID_X_NOT_PADDING,
|
||||
GroupedStackBar, signStyleGapRow, TopChartTableRow, GroupedStackBarData
|
||||
} from "@/components/lge-dashboard";
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import {apiBrandByYearCategories, apiTrendCategories} from "@/config/sample.data";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {BRAND_LIST, PRODUCT_KEYS, PRODUCTS, YEARS} from "@/const/lgConst";
|
||||
|
||||
|
||||
const PenetrationPage = () => {
|
||||
const { totalValue, registerExcelExporter } = useLayoutFilter();
|
||||
const [isBrandShare, setIsBrandShare] = useState<boolean>(false);
|
||||
|
||||
const displayRowLabel = (i:number, rowLabel: string) => {
|
||||
if (rowLabel === "gap") return "전년 대비 GAP(%)";
|
||||
return rowLabel;
|
||||
};
|
||||
|
||||
const productTableRows: TopChartTableRow[] = apiTrendCategories.map((row, i) => ({
|
||||
label: displayRowLabel(i, row.rowLabel),
|
||||
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
||||
}));
|
||||
|
||||
const productChartData: ChartData = {
|
||||
categories: [...PRODUCTS], // 한글 라벨(세탁기/냉장고/...)
|
||||
series: apiTrendCategories
|
||||
.filter((r) => r.rowLabel.endsWith("년")) // 24년/25년/26년만 차트에 사용
|
||||
.map((r) => ({
|
||||
name: r.rowLabel, // legend: 24년/25년/26년
|
||||
data: PRODUCT_KEYS.map((k) => (r as any)[k] ?? null),
|
||||
})),
|
||||
}
|
||||
|
||||
const rowMap = new Map<string, (typeof apiBrandByYearCategories)[number]>();
|
||||
for (const r of apiBrandByYearCategories) {
|
||||
rowMap.set(`${r.year}__${r.rowLabel}`, r);
|
||||
}
|
||||
|
||||
const brandShareChartData: GroupedStackBarData = (() => {
|
||||
const values: number[][][] = YEARS.map(() =>
|
||||
BRAND_LIST.map(() => new Array(PRODUCTS.length).fill(0))
|
||||
);
|
||||
|
||||
YEARS.forEach((year, yi) =>{
|
||||
BRAND_LIST.forEach((brand, bi) => {
|
||||
PRODUCT_KEYS.forEach((k, ci) => {
|
||||
const row = rowMap.get(`${year}__${brand}`);
|
||||
const v = (row as any)?.[k];
|
||||
values[yi][bi][ci] = typeof v === "number" ? v : 0;
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
return { categories: PRODUCTS, years: YEARS, brands: BRAND_LIST, values };
|
||||
})();
|
||||
|
||||
useEffect(() => {
|
||||
registerExcelExporter(async (payload) => {
|
||||
// payload.isTotal / payload.totalValue / payload.categoryValue 사용 가능
|
||||
// 여기서 데이터 수집 -> 엑셀 생성 -> 다운로드 수행
|
||||
// TODO: 실제 export 로직
|
||||
// await exportToExcel(payload);
|
||||
});
|
||||
|
||||
return () => registerExcelExporter(null);
|
||||
}, [registerExcelExporter]);
|
||||
|
||||
return (
|
||||
<div>PenetrationPage</div>
|
||||
<div>
|
||||
<div className="flex py-4">
|
||||
<Button
|
||||
className="h-8 px-3 text-sm font-semibold content-text-sm"
|
||||
variant={isBrandShare?"default":"secondary"}
|
||||
onClick={() => setIsBrandShare(!isBrandShare)}
|
||||
>
|
||||
{"브랜드별 점유율"}
|
||||
</Button>
|
||||
</div>
|
||||
<TopChartTable
|
||||
title={isBrandShare?"브랜드별 점유율":"전체 보급률"}
|
||||
categories={[...PRODUCTS]}
|
||||
rows={productTableRows}
|
||||
chart={
|
||||
isBrandShare?
|
||||
<GroupedStackBar
|
||||
data={brandShareChartData}
|
||||
grid={{...GRID_X_NOT_PADDING, top:60}}
|
||||
xAxis={{ type: "category", data: PRODUCTS, ...AXIS_HIDE_STYLE }}
|
||||
yAxis={{ type: "value", ...AXIS_HIDE_STYLE }}
|
||||
showFocusLabel={"none"}
|
||||
// 연도(24/25/26)별로 브랜드 3개 색상 지정 (브랜드 순서는 data.brands 순서)
|
||||
yearBrandPalette={{
|
||||
"24": ["--chart-cbrand-1", "--chart-samsung-1", "--chart-lg-1"],
|
||||
"25": ["--chart-cbrand-2", "--chart-samsung-2", "--chart-lg-2"],
|
||||
"26": ["--chart-cbrand-3", "--chart-samsung-3", "--chart-lg-3"],
|
||||
}}
|
||||
/>
|
||||
:
|
||||
<VerticalBar
|
||||
data={productChartData}
|
||||
paletteVarNames={["--chart-3", "--chart-2", "--chart-1"]}
|
||||
grid={GRID_X_NOT_PADDING}
|
||||
xAxis={{ type: "category", data: [...PRODUCTS], ...AXIS_HIDE_STYLE }}
|
||||
yAxis={{ type: "value", ...AXIS_HIDE_STYLE }}
|
||||
showFocusLabel={"last"}
|
||||
height={260}
|
||||
/>
|
||||
}
|
||||
signStyle={signStyleGapRow}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,58 @@
|
||||
'use client'
|
||||
|
||||
import {Button} from "@/components/ui/button";
|
||||
import TopChartTable from "../../../../../components/lge-dashboard/combo/TopChartTable";
|
||||
import {PRODUCT_KEYS, PRODUCTS} from "@/const/lgConst";
|
||||
import {
|
||||
AXIS_HIDE_STYLE, ChartData,
|
||||
GRID_X_NOT_PADDING,
|
||||
signStyleGapRow,
|
||||
TopChartTableRow
|
||||
} from "@/components/lge-dashboard";
|
||||
import VerticalBar from "../../../../../components/lge-dashboard/chart/VerticalBar";
|
||||
import {apiTrendBuy} from "@/config/sample.data";
|
||||
|
||||
const PurchasePage = () => {
|
||||
const displayRowLabel = (i:number, rowLabel: string) => {
|
||||
if (rowLabel === "gap") return "전년 대비 GAP(%)";
|
||||
return rowLabel;
|
||||
};
|
||||
|
||||
const purchaseTableRows: TopChartTableRow[] = apiTrendBuy.map((row, i) => ({
|
||||
label: displayRowLabel(i, row.rowLabel),
|
||||
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
||||
}));
|
||||
|
||||
const purchaseChartData: ChartData = {
|
||||
categories: [...PRODUCTS], // 한글 라벨(세탁기/냉장고/...)
|
||||
series: apiTrendBuy
|
||||
.filter((r) => r.rowLabel.endsWith("년")) // 24년/25년/26년만 차트에 사용
|
||||
.map((r) => ({
|
||||
name: r.rowLabel, // legend: 24년/25년/26년
|
||||
data: PRODUCT_KEYS.map((k) => (r as any)[k] ?? null),
|
||||
})),
|
||||
}
|
||||
|
||||
return (
|
||||
<div>PurchasePage</div>
|
||||
<div>
|
||||
<TopChartTable
|
||||
title={"전체 구매율"}
|
||||
categories={[...PRODUCTS]}
|
||||
rows={purchaseTableRows}
|
||||
chart={
|
||||
<VerticalBar
|
||||
data={purchaseChartData}
|
||||
paletteVarNames={["--chart-3", "--chart-2", "--chart-1"]}
|
||||
grid={GRID_X_NOT_PADDING}
|
||||
xAxis={{ type: "category", data: [...PRODUCTS], ...AXIS_HIDE_STYLE }}
|
||||
yAxis={{ type: "value", ...AXIS_HIDE_STYLE }}
|
||||
showFocusLabel={"last"}
|
||||
height={260}
|
||||
/>
|
||||
}
|
||||
signStyle={signStyleGapRow}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user