260202_04_ENH: Total 하위 페이지들에 useMemo 적용 및 LifeStyle 샘플 데이터 전체 값 조정
This commit is contained in:
@@ -1,35 +1,42 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
GroupedOverlayBar, GroupedOverlayBarData,
|
GroupedOverlayBar,
|
||||||
signStyleGapRow, TopChartTable, TopChartTableRow
|
type GroupedOverlayBarData,
|
||||||
|
signStyleGapRow,
|
||||||
|
TopChartTable,
|
||||||
|
type TopChartTableRow,
|
||||||
} from "@/components/lge-dashboard";
|
} from "@/components/lge-dashboard";
|
||||||
import {PRODUCT_KEYS, PRODUCTS, YEARS} from "@/const/lgConst";
|
import { PRODUCT_KEYS, PRODUCTS, YEARS } from "@/const/lgConst";
|
||||||
import {useMemo} from "react";
|
import { useMemo } from "react";
|
||||||
import {
|
import { apiOwnShareOfTotalPenetration, apiTrendCategories } from "@/config/sample.data";
|
||||||
apiOwnShareOfTotalPenetration,
|
|
||||||
apiTrendCategories
|
|
||||||
} from "@/config/sample.data";
|
|
||||||
import LifeStageDiv from "@/components/lge-dashboard/combo/LifeStageDiv";
|
import LifeStageDiv from "@/components/lge-dashboard/combo/LifeStageDiv";
|
||||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
import { useLayoutFilter } from "@/components/layout/LayoutFilterContext";
|
||||||
import {formatRowLabel} from "@/lib/lg-dashboard";
|
import { formatRowLabel } from "@/lib/lg-dashboard";
|
||||||
|
|
||||||
const LGPenetrationPage = () => {
|
const LGPenetrationPage = () => {
|
||||||
const { isTotal, filterValue } = useLayoutFilter();
|
const { isTotal, filterValue } = useLayoutFilter();
|
||||||
console.log(filterValue);
|
console.log(filterValue);
|
||||||
|
|
||||||
const productTableRows: TopChartTableRow[] = apiOwnShareOfTotalPenetration.map((row, i) => ({
|
const productTableRows = useMemo<TopChartTableRow[]>(() => {
|
||||||
|
return apiOwnShareOfTotalPenetration.map((row) => ({
|
||||||
label: formatRowLabel(row.rowLabel),
|
label: formatRowLabel(row.rowLabel),
|
||||||
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
||||||
}));
|
}));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const productChartData = useMemo<GroupedOverlayBarData>(() => {
|
||||||
const total: Array<Array<number>> = YEARS.map(() => Array(PRODUCT_KEYS.length).fill(0));
|
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 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 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 totalRows = apiTrendCategories.filter(
|
||||||
const lgRows = apiOwnShareOfTotalPenetration.filter((r) => YEARS.includes(r.year as any) && r.rowLabel.endsWith("년"));
|
(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) => {
|
lgRows.forEach((r, ri) => {
|
||||||
const yi = yearIndexMap.get(r.year);
|
const yi = yearIndexMap.get(r.year);
|
||||||
@@ -39,22 +46,21 @@ const LGPenetrationPage = () => {
|
|||||||
const k = PRODUCT_KEYS[ci];
|
const k = PRODUCT_KEYS[ci];
|
||||||
const t = (totalRows[ri] as any)[k];
|
const t = (totalRows[ri] as any)[k];
|
||||||
const v = (r as any)[k];
|
const v = (r as any)[k];
|
||||||
// total/focus 모두 같은 값(“전체 보급률 중 자사제품 비율”이므로)
|
|
||||||
total[yi][ci] = typeof v === "number" ? t : 0;
|
total[yi][ci] = typeof t === "number" ? t : 0;
|
||||||
focus[yi][ci] = typeof v === "number" ? v : 0;
|
focus[yi][ci] = typeof v === "number" ? v : 0;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
const productChartData: GroupedOverlayBarData = {
|
return {
|
||||||
categories: PRODUCTS,
|
categories: PRODUCTS,
|
||||||
years: YEARS,
|
years: YEARS,
|
||||||
totalName: "전체",
|
totalName: "전체",
|
||||||
focusName: "LG",
|
focusName: "LG",
|
||||||
total: total,
|
total,
|
||||||
focus: focus,
|
focus,
|
||||||
}
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -73,10 +79,9 @@ const LGPenetrationPage = () => {
|
|||||||
signStyle={signStyleGapRow}
|
signStyle={signStyleGapRow}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<LifeStageDiv/>
|
<LifeStageDiv />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default LGPenetrationPage;
|
export default LGPenetrationPage;
|
||||||
@@ -1,34 +1,41 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
|
import { useMemo } from "react";
|
||||||
import {PRODUCT_KEYS, PRODUCTS, YEARS} from "@/const/lgConst";
|
import { PRODUCT_KEYS, PRODUCTS, YEARS } from "@/const/lgConst";
|
||||||
import {
|
import {
|
||||||
GroupedOverlayBar,
|
GroupedOverlayBar,
|
||||||
GroupedOverlayBarData,
|
type GroupedOverlayBarData,
|
||||||
signStyleGapRow,
|
signStyleGapRow,
|
||||||
TopChartTable,
|
TopChartTable,
|
||||||
TopChartTableRow
|
type TopChartTableRow,
|
||||||
} from "@/components/lge-dashboard";
|
} from "@/components/lge-dashboard";
|
||||||
import { apiOwnShareOfTotalPurchase, apiTrendBuy} from "@/config/sample.data";
|
import { apiOwnShareOfTotalPurchase, apiTrendBuy } from "@/config/sample.data";
|
||||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
import { useLayoutFilter } from "@/components/layout/LayoutFilterContext";
|
||||||
import {formatRowLabel} from "@/lib/lg-dashboard";
|
import { formatRowLabel } from "@/lib/lg-dashboard";
|
||||||
|
|
||||||
const LGPurchasePage = () => {
|
const LGPurchasePage = () => {
|
||||||
const { isTotal, filterValue } = useLayoutFilter();
|
const { isTotal, filterValue } = useLayoutFilter();
|
||||||
console.log(filterValue);
|
console.log(filterValue);
|
||||||
|
|
||||||
const purchaseTableRows: TopChartTableRow[] = apiOwnShareOfTotalPurchase.map((row, i) => ({
|
const purchaseTableRows = useMemo<TopChartTableRow[]>(() => {
|
||||||
|
return apiOwnShareOfTotalPurchase.map((row) => ({
|
||||||
label: formatRowLabel(row.rowLabel),
|
label: formatRowLabel(row.rowLabel),
|
||||||
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
||||||
}));
|
}));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const purchaseChartData = useMemo<GroupedOverlayBarData>(() => {
|
||||||
const total: Array<Array<number>> = YEARS.map(() => Array(PRODUCT_KEYS.length).fill(0));
|
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 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 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 totalRows = apiTrendBuy.filter(
|
||||||
const lgRows = apiOwnShareOfTotalPurchase.filter((r) => YEARS.includes(r.year as any) && r.rowLabel.endsWith("년"));
|
(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) => {
|
lgRows.forEach((r, ri) => {
|
||||||
const yi = yearIndexMap.get(r.year);
|
const yi = yearIndexMap.get(r.year);
|
||||||
@@ -38,20 +45,22 @@ const LGPurchasePage = () => {
|
|||||||
const k = PRODUCT_KEYS[ci];
|
const k = PRODUCT_KEYS[ci];
|
||||||
const t = (totalRows[ri] as any)[k];
|
const t = (totalRows[ri] as any)[k];
|
||||||
const v = (r as any)[k];
|
const v = (r as any)[k];
|
||||||
// total/focus 모두 같은 값(“전체 보급률 중 자사제품 비율”이므로)
|
|
||||||
total[yi][ci] = typeof v === "number" ? t : 0;
|
// total은 t 기준으로 체크해야 안전
|
||||||
|
total[yi][ci] = typeof t === "number" ? t : 0;
|
||||||
focus[yi][ci] = typeof v === "number" ? v : 0;
|
focus[yi][ci] = typeof v === "number" ? v : 0;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
const purchaseChartData: GroupedOverlayBarData = {
|
return {
|
||||||
categories: PRODUCTS,
|
categories: PRODUCTS,
|
||||||
years: YEARS,
|
years: YEARS,
|
||||||
totalName: "전체",
|
totalName: "전체",
|
||||||
focusName: "LG",
|
focusName: "LG",
|
||||||
total: total,
|
total,
|
||||||
focus: focus,
|
focus,
|
||||||
}
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -71,6 +80,6 @@ const LGPurchasePage = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default LGPurchasePage;
|
export default LGPurchasePage;
|
||||||
@@ -1,51 +1,64 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
import {useEffect, useState} from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import TopChartTable from "@/components/lge-dashboard/combo/TopChartTable";
|
import TopChartTable from "@/components/lge-dashboard/combo/TopChartTable";
|
||||||
|
|
||||||
import VerticalBar from "@/components/lge-dashboard/chart/VerticalBar";
|
import VerticalBar from "@/components/lge-dashboard/chart/VerticalBar";
|
||||||
import {
|
import {
|
||||||
ChartData, GroupedStackBar, signStyleGapRow, TopChartTableRow, GroupedStackBarData
|
type ChartData,
|
||||||
|
GroupedStackBar,
|
||||||
|
signStyleGapRow,
|
||||||
|
type TopChartTableRow,
|
||||||
|
type GroupedStackBarData,
|
||||||
} from "@/components/lge-dashboard";
|
} from "@/components/lge-dashboard";
|
||||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
import { useLayoutFilter } from "@/components/layout/LayoutFilterContext";
|
||||||
import {apiBrandByYearCategories, apiTrendCategories} from "@/config/sample.data";
|
import { apiBrandByYearCategories, apiTrendCategories } from "@/config/sample.data";
|
||||||
import {Button} from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {BRAND_LIST, PRODUCT_KEYS, PRODUCTS, YEARS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING} from "@/const/lgConst";
|
import {
|
||||||
import {formatRowLabel} from "@/lib/lg-dashboard";
|
BRAND_LIST,
|
||||||
|
PRODUCT_KEYS,
|
||||||
|
PRODUCTS,
|
||||||
|
YEARS,
|
||||||
|
AXIS_HIDE_STYLE,
|
||||||
|
GRID_X_NOT_PADDING,
|
||||||
|
} from "@/const/lgConst";
|
||||||
|
import { formatRowLabel } from "@/lib/lg-dashboard";
|
||||||
|
|
||||||
const PenetrationPage = () => {
|
const PenetrationPage = () => {
|
||||||
const { isTotal, filterValue, registerExcelExporter } = useLayoutFilter();
|
const { isTotal, filterValue, registerExcelExporter } = useLayoutFilter();
|
||||||
console.log(filterValue);
|
console.log(filterValue);
|
||||||
|
|
||||||
const [isBrandShare, setIsBrandShare] = useState<boolean>(false);
|
const [isBrandShare, setIsBrandShare] = useState(false);
|
||||||
|
|
||||||
const productTableRows: TopChartTableRow[] = apiTrendCategories.map((row, i) => ({
|
const productTableRows = useMemo<TopChartTableRow[]>(() => {
|
||||||
|
return apiTrendCategories.map((row) => ({
|
||||||
label: formatRowLabel(row.rowLabel),
|
label: formatRowLabel(row.rowLabel),
|
||||||
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
||||||
}));
|
}));
|
||||||
|
}, []);
|
||||||
|
|
||||||
const productChartData: ChartData = {
|
const productChartData = useMemo<ChartData>(() => {
|
||||||
categories: [...PRODUCTS], // 한글 라벨(세탁기/냉장고/...)
|
return {
|
||||||
|
categories: [...PRODUCTS],
|
||||||
series: apiTrendCategories
|
series: apiTrendCategories
|
||||||
.filter((r) => r.rowLabel.endsWith("년")) // 24년/25년/26년만 차트에 사용
|
.filter((r) => r.rowLabel.endsWith("년"))
|
||||||
.map((r) => ({
|
.map((r) => ({
|
||||||
name: r.rowLabel, // legend: 24년/25년/26년
|
name: r.rowLabel,
|
||||||
data: PRODUCT_KEYS.map((k) => (r as any)[k] ?? null),
|
data: PRODUCT_KEYS.map((k) => (r as any)[k] ?? null),
|
||||||
})),
|
})),
|
||||||
}
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const brandShareChartData = useMemo<GroupedStackBarData>(() => {
|
||||||
const rowMap = new Map<string, (typeof apiBrandByYearCategories)[number]>();
|
const rowMap = new Map<string, (typeof apiBrandByYearCategories)[number]>();
|
||||||
for (const r of apiBrandByYearCategories) {
|
for (const r of apiBrandByYearCategories) {
|
||||||
rowMap.set(`${r.year}__${r.rowLabel}`, r);
|
rowMap.set(`${r.year}__${r.rowLabel}`, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
const brandShareChartData: GroupedStackBarData = (() => {
|
|
||||||
const values: number[][][] = YEARS.map(() =>
|
const values: number[][][] = YEARS.map(() =>
|
||||||
BRAND_LIST.map(() => new Array(PRODUCTS.length).fill(0))
|
BRAND_LIST.map(() => new Array(PRODUCTS.length).fill(0))
|
||||||
);
|
);
|
||||||
|
|
||||||
YEARS.forEach((year, yi) =>{
|
YEARS.forEach((year, yi) => {
|
||||||
BRAND_LIST.forEach((brand, bi) => {
|
BRAND_LIST.forEach((brand, bi) => {
|
||||||
PRODUCT_KEYS.forEach((k, ci) => {
|
PRODUCT_KEYS.forEach((k, ci) => {
|
||||||
const row = rowMap.get(`${year}__${brand}`);
|
const row = rowMap.get(`${year}__${brand}`);
|
||||||
@@ -53,19 +66,15 @@ const PenetrationPage = () => {
|
|||||||
values[yi][bi][ci] = typeof v === "number" ? v : 0;
|
values[yi][bi][ci] = typeof v === "number" ? v : 0;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
return { categories: PRODUCTS, years: YEARS, brands: BRAND_LIST, values };
|
return { categories: PRODUCTS, years: YEARS, brands: BRAND_LIST, values };
|
||||||
})();
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
registerExcelExporter(async (payload) => {
|
registerExcelExporter(async (payload) => {
|
||||||
// payload.isTotal / payload.totalValue / payload.categoryValue 사용 가능
|
// TODO: export
|
||||||
// 여기서 데이터 수집 -> 엑셀 생성 -> 다운로드 수행
|
|
||||||
// TODO: 실제 export 로직
|
|
||||||
// await exportToExcel(payload);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => registerExcelExporter(null);
|
return () => registerExcelExporter(null);
|
||||||
}, [registerExcelExporter]);
|
}, [registerExcelExporter]);
|
||||||
|
|
||||||
@@ -74,32 +83,32 @@ const PenetrationPage = () => {
|
|||||||
<div className="flex py-4">
|
<div className="flex py-4">
|
||||||
<Button
|
<Button
|
||||||
className="h-8 px-3 text-sm font-semibold content-text-sm"
|
className="h-8 px-3 text-sm font-semibold content-text-sm"
|
||||||
variant={isBrandShare?"default":"secondary"}
|
variant={isBrandShare ? "default" : "secondary"}
|
||||||
onClick={() => setIsBrandShare(!isBrandShare)}
|
onClick={() => setIsBrandShare((v) => !v)}
|
||||||
>
|
>
|
||||||
{"브랜드별 점유율"}
|
{"브랜드별 점유율"}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<TopChartTable
|
<TopChartTable
|
||||||
title={isBrandShare?"브랜드별 점유율":"전체 보급률"}
|
title={isBrandShare ? "브랜드별 점유율" : "전체 보급률"}
|
||||||
categories={[...PRODUCTS]}
|
categories={[...PRODUCTS]}
|
||||||
rows={productTableRows}
|
rows={productTableRows}
|
||||||
chart={
|
chart={
|
||||||
isBrandShare?
|
isBrandShare ? (
|
||||||
<GroupedStackBar
|
<GroupedStackBar
|
||||||
data={brandShareChartData}
|
data={brandShareChartData}
|
||||||
grid={{...GRID_X_NOT_PADDING, top:60}}
|
grid={{ ...GRID_X_NOT_PADDING, top: 60 }}
|
||||||
xAxis={{ type: "category", data: PRODUCTS, ...AXIS_HIDE_STYLE }}
|
xAxis={{ type: "category", data: PRODUCTS, ...AXIS_HIDE_STYLE }}
|
||||||
yAxis={{ type: "value", ...AXIS_HIDE_STYLE }}
|
yAxis={{ type: "value", ...AXIS_HIDE_STYLE }}
|
||||||
showFocusLabel={"none"}
|
showFocusLabel={"none"}
|
||||||
// 연도(24/25/26)별로 브랜드 3개 색상 지정 (브랜드 순서는 data.brands 순서)
|
|
||||||
yearBrandPalette={{
|
yearBrandPalette={{
|
||||||
"24": ["--chart-cbrand-1", "--chart-samsung-1", "--chart-lg-1"],
|
"24": ["--chart-cbrand-1", "--chart-samsung-1", "--chart-lg-1"],
|
||||||
"25": ["--chart-cbrand-2", "--chart-samsung-2", "--chart-lg-2"],
|
"25": ["--chart-cbrand-2", "--chart-samsung-2", "--chart-lg-2"],
|
||||||
"26": ["--chart-cbrand-3", "--chart-samsung-3", "--chart-lg-3"],
|
"26": ["--chart-cbrand-3", "--chart-samsung-3", "--chart-lg-3"],
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
:
|
) : (
|
||||||
<VerticalBar
|
<VerticalBar
|
||||||
data={productChartData}
|
data={productChartData}
|
||||||
paletteVarNames={["--chart-3", "--chart-2", "--chart-1"]}
|
paletteVarNames={["--chart-3", "--chart-2", "--chart-1"]}
|
||||||
@@ -109,11 +118,12 @@ const PenetrationPage = () => {
|
|||||||
showFocusLabel={"last"}
|
showFocusLabel={"last"}
|
||||||
height={260}
|
height={260}
|
||||||
/>
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
signStyle={signStyleGapRow}
|
signStyle={signStyleGapRow}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default PenetrationPage;
|
export default PenetrationPage;
|
||||||
@@ -1,33 +1,40 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
import {PRODUCT_KEYS, PRODUCTS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING} from "@/const/lgConst";
|
import { useMemo } from "react";
|
||||||
|
import { PRODUCT_KEYS, PRODUCTS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING } from "@/const/lgConst";
|
||||||
import {
|
import {
|
||||||
ChartData,
|
type ChartData,
|
||||||
signStyleGapRow, TopChartTable,
|
signStyleGapRow,
|
||||||
TopChartTableRow, VerticalBar
|
TopChartTable,
|
||||||
|
type TopChartTableRow,
|
||||||
|
VerticalBar,
|
||||||
} from "@/components/lge-dashboard";
|
} from "@/components/lge-dashboard";
|
||||||
import {apiTrendBuy} from "@/config/sample.data";
|
import { apiTrendBuy } from "@/config/sample.data";
|
||||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
import { useLayoutFilter } from "@/components/layout/LayoutFilterContext";
|
||||||
import {formatRowLabel} from "@/lib/lg-dashboard";
|
import { formatRowLabel } from "@/lib/lg-dashboard";
|
||||||
|
|
||||||
const PurchasePage = () => {
|
const PurchasePage = () => {
|
||||||
const { isTotal, filterValue } = useLayoutFilter();
|
const { isTotal, filterValue } = useLayoutFilter();
|
||||||
console.log(filterValue);
|
console.log(filterValue);
|
||||||
|
|
||||||
const purchaseTableRows: TopChartTableRow[] = apiTrendBuy.map((row, i) => ({
|
const purchaseTableRows = useMemo<TopChartTableRow[]>(() => {
|
||||||
|
return apiTrendBuy.map((row) => ({
|
||||||
label: formatRowLabel(row.rowLabel),
|
label: formatRowLabel(row.rowLabel),
|
||||||
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
||||||
}));
|
}));
|
||||||
|
}, []);
|
||||||
|
|
||||||
const purchaseChartData: ChartData = {
|
const purchaseChartData = useMemo<ChartData>(() => {
|
||||||
categories: [...PRODUCTS], // 한글 라벨(세탁기/냉장고/...)
|
return {
|
||||||
|
categories: [...PRODUCTS],
|
||||||
series: apiTrendBuy
|
series: apiTrendBuy
|
||||||
.filter((r) => r.rowLabel.endsWith("년")) // 24년/25년/26년만 차트에 사용
|
.filter((r) => r.rowLabel.endsWith("년"))
|
||||||
.map((r) => ({
|
.map((r) => ({
|
||||||
name: r.rowLabel, // legend: 24년/25년/26년
|
name: r.rowLabel,
|
||||||
data: PRODUCT_KEYS.map((k) => (r as any)[k] ?? null),
|
data: PRODUCT_KEYS.map((k) => (r as any)[k] ?? null),
|
||||||
})),
|
})),
|
||||||
}
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -50,6 +57,6 @@ const PurchasePage = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default PurchasePage;
|
export default PurchasePage;
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||||
import BannerSummary from "@/components/lge-dashboard/combo/BannerSummary";
|
import BannerSummary from "@/components/lge-dashboard/combo/BannerSummary";
|
||||||
import {useEffect, useMemo, useState} from "react";
|
import {useMemo} from "react";
|
||||||
import {ServerBannerRow} from "@/types/lg";
|
import {ServerBannerRow} from "@/types/lg";
|
||||||
import {apiOwnershipSummary, apiPurchaseRateKpis, apiYearIndex} from "@/config/sample.data";
|
import {apiYearIndex} from "@/config/sample.data";
|
||||||
|
|
||||||
const PenetrationChange = () => {
|
const PenetrationChange = () => {
|
||||||
const { filterValue } = useLayoutFilter();
|
const { filterValue } = useLayoutFilter();
|
||||||
|
|||||||
@@ -265,21 +265,21 @@ export const apiOwnShareOfTotalPurchase: ServerProductRow[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const apiLifeStageByProduct: ServerBannerRow[] = [
|
export const apiLifeStageByProduct: ServerBannerRow[] = [
|
||||||
bannerRow(26, "냉장고", 1200, {min:10, max:99}),
|
bannerRow(26, "냉장고", 97, {min:10, max:99}),
|
||||||
bannerRow(26, "세탁기", 1100, {min:10, max:99}),
|
bannerRow(26, "세탁기", 94, {min:10, max:99}),
|
||||||
bannerRow(26, "에어컨", 900, {min:10, max:99}),
|
bannerRow(26, "에어컨", 90, {min:10, max:99}),
|
||||||
bannerRow(26, "건조기", 500, {min:10, max:99}),
|
bannerRow(26, "건조기", 38, {min:10, max:99}),
|
||||||
bannerRow(26, "TV", 950, {min:10, max:99}),
|
bannerRow(26, "TV", 86, {min:10, max:99}),
|
||||||
bannerRow(26, "김치 냉장고", 700, {min:10, max:99}),
|
bannerRow(26, "김치 냉장고", 56, {min:10, max:99}),
|
||||||
bannerRow(26, "식기세척기", 450, {min:10, max:99}),
|
bannerRow(26, "식기세척기", 18, {min:10, max:99}),
|
||||||
bannerRow(26, "의류 관리기", 320, {min:10, max:99}),
|
bannerRow(26, "의류 관리기", 13, {min:10, max:99}),
|
||||||
|
|
||||||
bannerRow(26, "청소기", 1000, {min:10, max:99}),
|
bannerRow(26, "청소기", 78, {min:10, max:99}),
|
||||||
bannerRow(26, "공기 청정기", 800, {min:10, max:99}),
|
bannerRow(26, "공기 청정기", 52, {min:10, max:99}),
|
||||||
bannerRow(26, "정수기", 800, {min:10, max:99}),
|
bannerRow(26, "정수기", 42, {min:10, max:99}),
|
||||||
|
|
||||||
bannerRow(26, "로봇 청소기", 420, {min:10, max:99}),
|
bannerRow(26, "로봇 청소기", 22, {min:10, max:99}),
|
||||||
bannerRow(26, "음식물처리기", 420, {min:10, max:99}),
|
bannerRow(26, "음식물처리기", 26, {min:10, max:99}),
|
||||||
];
|
];
|
||||||
|
|
||||||
/** ---------------------------
|
/** ---------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user