From d7cb9259cde3c443a56a3f1236d43d77860d6020 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Wed, 28 Jan 2026 17:01:40 +0900 Subject: [PATCH] =?UTF-8?q?260128=5F03=5FENH:=20=EC=83=98=ED=94=8C?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=9E=9C=EB=8D=A4=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9,=20lg=20=EB=B3=B4=EA=B8=89=EB=A5=A0=20=ED=95=98?= =?UTF-8?q?=EB=8B=A8=20=EC=B9=B4=EB=93=9C=20+=20=EA=B2=8C=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=ED=85=8C=EC=9D=B4=EB=B8=94=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(main)/total/lg-penetration/page.tsx | 93 ++++++- .../(pages)/(main)/total/lg-purchase/page.tsx | 10 +- .../(pages)/(main)/total/penetration/page.tsx | 6 +- .../(pages)/(main)/total/purchase/page.tsx | 12 +- .../lge-dashboard/chart/GroupedOverlayBar.tsx | 3 +- .../lge-dashboard/chart/GroupedStackBar.tsx | 3 +- .../lge-dashboard/combo/GaugeCardTable.tsx | 58 +++++ src/components/lge-dashboard/index.ts | 2 + .../lge-dashboard/table/GaugeTable.tsx | 84 ++++--- src/components/lge-dashboard/types.ts | 19 +- src/config/sample.data.ts | 230 ++++++++++++------ src/const/lgConst.ts | 9 +- 12 files changed, 395 insertions(+), 134 deletions(-) create mode 100644 src/components/lge-dashboard/combo/GaugeCardTable.tsx diff --git a/src/app/(pages)/(main)/total/lg-penetration/page.tsx b/src/app/(pages)/(main)/total/lg-penetration/page.tsx index ebefc79..892a8e1 100644 --- a/src/app/(pages)/(main)/total/lg-penetration/page.tsx +++ b/src/app/(pages)/(main)/total/lg-penetration/page.tsx @@ -1,15 +1,18 @@ 'use client' -import {Button} from "@/components/ui/button"; -import TopChartTable from "../../../../../components/lge-dashboard/combo/TopChartTable"; import { - GroupedOverlayBar, GroupedOverlayBarData, - signStyleGapRow, TopChartTableRow + GaugeCardTable, GaugeColumn, + GroupedOverlayBar, GroupedOverlayBarData, LifeStageRow, + signStyleGapRow, TopChartTable, 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"; +import {useMemo} from "react"; +import { + apiLifeStageByProduct, + apiLifeStageByProductForGauge, + apiOwnShareOfTotalPenetration, + apiTrendCategories +} from "@/config/sample.data"; const LGPenetrationPage = () => { @@ -54,6 +57,53 @@ const LGPenetrationPage = () => { focus: focus, } + const norm = (s: string) => s.replace(/\s+/g, "").toLowerCase(); + const asNum = (v: unknown): number | null => typeof v === "number" && Number.isFinite(v) ? v : null; + + const LIFE_STAGE_COLUMNS: GaugeColumn[] = [ + { key: "item", header: "", rowHead: true, renderLabel: (r) => r.item }, + + { key: "total", header: "전체", max: 100, align: "left", cellType:"number"}, + { key: "single", header: "미혼", max: 100 , align: "left"}, + + { key: "noKids", header: "무자녀", group: "기혼", max: 100 , align: "left"}, + { key: "preschoolKids", header: "미취학", group: "기혼", max: 100 , align: "left"}, + { key: "schoolKids", header: "취학자녀", group: "기혼", max: 100 , align: "left"}, + { key: "adultKids", header: "성인자녀", group: "기혼", max: 100 , align: "left"}, + + { key: "independentSenior", header: "독립\n시니어", max: 100 , align: "left"}, + ]; + + const LIFE_STAGE_GROUPS = [ + { title: "필수가전 군", items: ["냉장고", "세탁기", "에어컨", "TV", "청소기", "김치 냉장고"] }, + { title: "케어가전 군", items: ["공기 청정기", "가습기", "제습기"] }, + { title: "Must & Best", items: ["건조기", "식기 세척기", "의류 관리기"] }, + { title: "신가전 군", items: ["로봇 청소기"] }, + ] as const; + + const lifeStageRowsByGroup = useMemo(() => { + const pick = (label: string) => apiLifeStageByProduct.find((r) => norm(r.rowLabel) === norm(label)); + + return LIFE_STAGE_GROUPS.map((g) => { + const rows: LifeStageRow[] = g.items.map((label) => { + const r = pick(label); + + return { + item: label, + total: asNum((r as any)?.total), // 서버에 all이 없으면 null로 남음 + single: asNum((r as any)?.single), + noKids: asNum((r as any)?.noKids), + preschoolKids: asNum((r as any)?.preschoolKids), + schoolKids: asNum((r as any)?.schoolKids), + adultKids: asNum((r as any)?.adultKids), + independentSenior: asNum((r as any)?.independentSenior), + }; + }); + + return { title: g.title, rows }; + }); + }, []); + return (
{ } signStyle={signStyleGapRow} /> + +
+
+
+ + 제품 보유율 +
+ +
+ + 시장 기회공간 +
+
+ +
+ {lifeStageRowsByGroup.map((g) => ( + + ))} +
+
+
); } diff --git a/src/app/(pages)/(main)/total/lg-purchase/page.tsx b/src/app/(pages)/(main)/total/lg-purchase/page.tsx index fe15b8f..6bfa280 100644 --- a/src/app/(pages)/(main)/total/lg-purchase/page.tsx +++ b/src/app/(pages)/(main)/total/lg-purchase/page.tsx @@ -1,8 +1,14 @@ '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 { + GroupedOverlayBar, + GroupedOverlayBarData, + signStyleGapRow, + TopChartTable, + TopChartTableRow +} from "@/components/lge-dashboard"; import { apiOwnShareOfTotalPurchase, apiTrendBuy} from "@/config/sample.data"; const LGPurchasePage = () => { diff --git a/src/app/(pages)/(main)/total/penetration/page.tsx b/src/app/(pages)/(main)/total/penetration/page.tsx index 7bd2b56..3a1988d 100644 --- a/src/app/(pages)/(main)/total/penetration/page.tsx +++ b/src/app/(pages)/(main)/total/penetration/page.tsx @@ -5,14 +5,12 @@ 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 + ChartData, 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"; +import {BRAND_LIST, PRODUCT_KEYS, PRODUCTS, YEARS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING} from "@/const/lgConst"; const PenetrationPage = () => { diff --git a/src/app/(pages)/(main)/total/purchase/page.tsx b/src/app/(pages)/(main)/total/purchase/page.tsx index 747ec4e..000570f 100644 --- a/src/app/(pages)/(main)/total/purchase/page.tsx +++ b/src/app/(pages)/(main)/total/purchase/page.tsx @@ -1,15 +1,11 @@ 'use client' -import {Button} from "@/components/ui/button"; -import TopChartTable from "../../../../../components/lge-dashboard/combo/TopChartTable"; -import {PRODUCT_KEYS, PRODUCTS} from "@/const/lgConst"; +import {PRODUCT_KEYS, PRODUCTS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING} from "@/const/lgConst"; import { - AXIS_HIDE_STYLE, ChartData, - GRID_X_NOT_PADDING, - signStyleGapRow, - TopChartTableRow + ChartData, + signStyleGapRow, TopChartTable, + TopChartTableRow, VerticalBar } from "@/components/lge-dashboard"; -import VerticalBar from "../../../../../components/lge-dashboard/chart/VerticalBar"; import {apiTrendBuy} from "@/config/sample.data"; const PurchasePage = () => { diff --git a/src/components/lge-dashboard/chart/GroupedOverlayBar.tsx b/src/components/lge-dashboard/chart/GroupedOverlayBar.tsx index 39579b6..b759a81 100644 --- a/src/components/lge-dashboard/chart/GroupedOverlayBar.tsx +++ b/src/components/lge-dashboard/chart/GroupedOverlayBar.tsx @@ -11,8 +11,9 @@ import type { } from "echarts"; import BaseEChart from "../BaseEChart"; import { buildLgPalette } from "../color"; -import {AXIS_HIDE_STYLE, GroupedOverlayBarData, ShowLabel} from "../types"; +import { GroupedOverlayBarData, ShowLabel} from "../types"; import {getIsShowLabel, roundedRectIcon} from "@/components/lge-dashboard/chart/utill"; +import {AXIS_HIDE_STYLE} from "@/const/lgConst"; type Props = { data: GroupedOverlayBarData; diff --git a/src/components/lge-dashboard/chart/GroupedStackBar.tsx b/src/components/lge-dashboard/chart/GroupedStackBar.tsx index 773b380..2535258 100644 --- a/src/components/lge-dashboard/chart/GroupedStackBar.tsx +++ b/src/components/lge-dashboard/chart/GroupedStackBar.tsx @@ -10,9 +10,10 @@ import type { SeriesOption, EChartsOption, } from "echarts"; import BaseEChart from "../BaseEChart"; -import {AXIS_HIDE_STYLE, GroupedStackBarData, ShowLabel} from "../types"; +import { GroupedStackBarData, ShowLabel} from "../types"; import { buildLgPalette } from "@/components/lge-dashboard/color"; import {getIsShowLabel, roundedRectIcon} from "@/components/lge-dashboard/chart/utill"; +import {AXIS_HIDE_STYLE} from "@/const/lgConst"; type Props = { data: GroupedStackBarData; diff --git a/src/components/lge-dashboard/combo/GaugeCardTable.tsx b/src/components/lge-dashboard/combo/GaugeCardTable.tsx new file mode 100644 index 0000000..1c0f7c7 --- /dev/null +++ b/src/components/lge-dashboard/combo/GaugeCardTable.tsx @@ -0,0 +1,58 @@ +"use client"; + +import React from "react"; +import { cn } from "@/lib/utils"; +import {GaugeColumn, GaugeTable} from "@/components/lge-dashboard"; +import Card from "@/components/lge-dashboard/card/Card"; + +export type GaugeCardTableProps = { + /** 카드 제목 */ + title: string; + /** GaugeTable columns */ + columns: GaugeColumn[]; + /** GaugeTable rows */ + rows: T[]; + + /** GaugeTable 옵션들 (필요한 것만 노출) */ + cellHeight?: number; + fillColor?: string; + trackColor?: string; + + className?: string; + cardClassName?: string; + tableClassName?: string; +}; + +const GaugeCardTable = >( + props: GaugeCardTableProps +) => { + const { + title, + columns, + rows, + cellHeight = 26, + fillColor, + trackColor, + className, + cardClassName, + tableClassName, + } = props; + + return ( +
+ +
+ +
+
+
+ ); +}; + +export default GaugeCardTable; diff --git a/src/components/lge-dashboard/index.ts b/src/components/lge-dashboard/index.ts index 7409559..d059e57 100644 --- a/src/components/lge-dashboard/index.ts +++ b/src/components/lge-dashboard/index.ts @@ -13,5 +13,7 @@ export { default as GaugeTable } from "./table/GaugeTable"; export { default as TopChartTable } from "./combo/TopChartTable"; export { default as LeftChartTable } from "./combo/LeftChartTable"; +export { default as GaugeCardTable } from "./combo/GaugeCardTable"; +export { default as CategoryByData } from "./combo/CategoryByData" export { default as CardDefault } from "./card/Card"; diff --git a/src/components/lge-dashboard/table/GaugeTable.tsx b/src/components/lge-dashboard/table/GaugeTable.tsx index ab3bd80..83c5bd8 100644 --- a/src/components/lge-dashboard/table/GaugeTable.tsx +++ b/src/components/lge-dashboard/table/GaugeTable.tsx @@ -21,7 +21,6 @@ type Props> = { cellHeight?: number; // 기본 26 /** 숫자 표시 여부/포맷 */ - showValue?: boolean; // 기본 true valueFormatter?: (v: number) => string; }; @@ -40,10 +39,9 @@ const GaugeTable = >({ className, wrapperClassName, scale = 1, - fillColor = "hsl(var(--primary) / 0.85)", - trackColor = "hsl(var(--lg-gray-200) / 0.85)", + fillColor = "hsl(var(--lg-gray-200) / 0.85)", + trackColor = "hsl(var(--lg-pink-300) / 0.2)", cellHeight = 26, - showValue = true, valueFormatter, }: Props) => { const hasGroup = columns.some((c) => !!c.group); @@ -68,9 +66,23 @@ const GaugeTable = >({ const fmt = valueFormatter ?? ((v: number) => String(Math.round(v))); + const clamp01 = (n: number) => Math.max(0, Math.min(1, n)); + return (
- +
+ + {columns.map((c, i) => ( + + ))} + {hasGroup && ( @@ -83,7 +95,7 @@ const GaugeTable = >({ )} {columns.map((c) => ( - ))} @@ -95,6 +107,7 @@ const GaugeTable = >({ {columns.map((c) => { const align = c.align ?? (c.rowHead ? "left" : "center"); + const cellType = c.cellType ?? "gauge"; if (c.rowHead) { const raw = row[c.key]; @@ -119,35 +132,42 @@ const GaugeTable = >({ const raw = row[c.key]; const v = num(raw); const max = c.max ?? 100; - const ratio = v === null ? 0 : Math.max(0, Math.min(1, (v * scale) / max)); + const ratio = v === null ? 0 : clamp01((v * scale) / max); const pct = ratio * 100; - return ( - + ); + } + + return ( + ); })} diff --git a/src/components/lge-dashboard/types.ts b/src/components/lge-dashboard/types.ts index e036c58..6035911 100644 --- a/src/components/lge-dashboard/types.ts +++ b/src/components/lge-dashboard/types.ts @@ -112,6 +112,17 @@ export type ServerBannerRow = ServerBaseRow & [k: string]: number | string; }; +export type LifeStageRow = Record & { + item: string; + total: number | null; + single: number | null; + noKids: number | null; + preschoolKids: number | null; + schoolKids: number | null; + adultKids: number | null; + independentSenior: number | null; +}; + export type ChartSeries = { /** legend에 노출될 이름 */ name: string; @@ -190,6 +201,7 @@ export type GaugeColumn = { /** 게이지 최대값 기준(기본 100) */ max?: number; renderLabel?: (row: T) => React.ReactNode; // rowHead에 쓰기 좋음 + cellType?: "gauge" | "number"; // default: "gauge" }; export type SignDisplayMode = "number" | "arrow"; @@ -233,13 +245,6 @@ export const signStyleGapRow: SignStyle = { arrowWithNumber: true, paint: "text", }; - -/** X 축 패딩 없앤 GridOption*/ -export const GRID_X_NOT_PADDING = { left: 0, right: 0, top: 50, bottom: 10, containLabel: false } as const; -/** T 축 패딩 없앤 GridOption*/ -export const GRID_Y_NOT_PADDING = { left: 10, right: 10, top: 0, bottom: 0, containLabel: false } as const; -/** 축 스타일 감춤 */ -export const AXIS_HIDE_STYLE = { axisLabel: { show: false }, axisTick: { show: false }, axisLine: { show: false }} as const; /** ChartLabel 보여지는 옵션 */ export type ShowLabel = "none" | "all" | "last" | "first"; diff --git a/src/config/sample.data.ts b/src/config/sample.data.ts index 20a3541..025d986 100644 --- a/src/config/sample.data.ts +++ b/src/config/sample.data.ts @@ -9,17 +9,42 @@ import {PRODUCT_KEY_MAP} from "@/components/lge-dashboard"; const PRODUCT_KEYS = Object.keys(PRODUCT_KEY_MAP) as ProductKey[]; -const randInt = (min: number, max: number) => - Math.floor(Math.random() * (max - min + 1)) + min; +const DUMMY_SEED = Number(process.env.NEXT_PUBLIC_DUMMY_SEED ?? 12345); + +// 문자열 → 32bit 해시 +const hash32 = (s: string) => { + let h = 2166136261; + for (let i = 0; i < s.length; i++) { + h ^= s.charCodeAt(i); + h = Math.imul(h, 16777619); + } + return h >>> 0; +}; + +// 결정적 PRNG +const mulberry32 = (a: number) => { + return () => { + let t = (a += 0x6d2b79f5); + t = Math.imul(t ^ (t >>> 15), t | 1); + t ^= t + Math.imul(t ^ (t >>> 7), t | 61); + return ((t ^ (t >>> 14)) >>> 0) / 4294967296; + }; +}; + +const randInt = (r: () => number, min: number, max: number) => + Math.floor(r() * (max - min + 1)) + min; type RandRange = { min: number | null; max: number | null }; -const makeProductDist = (range?: RandRange): Record => { +const makeProductDist = (seedKey: string, range?: RandRange): Record => { const min = range?.min ?? 1; const max = range?.max ?? 60; + const seed = (hash32(seedKey) ^ DUMMY_SEED) >>> 0; + const r = mulberry32(seed); + const out = {} as Record; - for (const k of PRODUCT_KEYS) out[k] = randInt(min, max); + for (const k of PRODUCT_KEYS) out[k] = randInt(r, min, max); return out; }; @@ -33,7 +58,7 @@ const productRow = ( year, rowLabel, total, - ...makeProductDist(range), + ...makeProductDist(`${year}|${rowLabel}|${range.min ?? ""}|${range.max ?? ""}`, range), ...(extra ?? {}), }); @@ -69,71 +94,119 @@ const calcCagrRow = (row24: ServerProductRow, row26: ServerProductRow): ServerPr return out; }; -// 배너(41키) 그룹별 합이 100 되도록 고정 분포 -const BANNER_DIST_DEFAULT: Record = { - // 라이프스테이지(6) - single: 20, - noKids: 20, - preschoolKids: 20, - schoolKids: 20, - adultKids: 10, - independentSenior: 10, +const splitTo100 = (r: () => number, n: number, minEach: number, maxEach: number): number[] => { + // 불가능한 범위 방어 + const minSum = n * minEach; + const maxSum = n * maxEach; + if (minSum > 100) throw new Error(`splitTo100 invalid: minEach too large (n=${n}, minEach=${minEach})`); + if (maxSum < 100) throw new Error(`splitTo100 invalid: maxEach too small (n=${n}, maxEach=${maxEach})`); - // 가구원수(4) - hh1: 25, - hh2: 35, - hh3: 20, - hh4Plus: 20, + // 1) 최소값으로 깔기 + const out = Array(n).fill(minEach); + const remain = 100 - minSum; - // 연령(5) - age20s: 15, - age30s: 25, - age40s: 30, - age50s: 20, - age60s: 10, + // 2) 각 슬롯이 추가로 받을 수 있는 상한 + const caps = Array(n).fill(maxEach - minEach); - // 점유형태(5) - ownerOccupied: 50, - jeonse: 25, - depositAndMonthly: 10, - monthlyNoDeposit: 10, - otherTenure: 5, + // 3) remain을 cap 내에서 랜덤 분배 + // (가중치 기반으로 일단 분배 → cap 초과를 다시 재분배) + const w = Array.from({ length: n }, () => randInt(r, 1, 100)); + const wSum = w.reduce((a, b) => a + b, 0); - // 주거형태(6) - apartment: 60, - house: 15, - officetel: 10, - villa: 10, - studio: 3, - otherHousingType: 2, + const add = w.map((wi) => Math.floor((wi / wSum) * remain)); + const used = add.reduce((a, b) => a + b, 0); + const left = remain - used; - // 평형(5) - under19Pyeong: 10, - pyeong20s: 20, - pyeong30s: 35, - pyeong40s: 20, - pyeong50Plus: 15, + // 남은 left를 가중치 큰 순으로 1씩 + const order = w + .map((wi, i) => ({ wi, i })) + .sort((a, b) => b.wi - a.wi) + .map((x) => x.i); - // 권역(6) - regionCapital: 45, - regionGyeongnamBusanUlsan: 15, - regionGyeongbukDaegu: 10, - regionJeollaGwangju: 10, - regionChungcheongDaejeonSejong: 10, - regionGangwonJeju: 10, + for (let k = 0; k < left; k++) add[order[k % n]] += 1; - // 소득(4) - incomeUnder299: 20, - income300to599: 40, - income600to899: 25, - income900Plus: 15, + // cap 적용(초과분 회수) + let overflow = 0; + for (let i = 0; i < n; i++) { + if (add[i] > caps[i]) { + overflow += add[i] - caps[i]; + add[i] = caps[i]; + } + } + + // 회수한 overflow를 cap 남은 곳에 다시 채우기(랜덤) + while (overflow > 0) { + const candidates = []; + for (let i = 0; i < n; i++) { + const room = caps[i] - add[i]; + if (room > 0) candidates.push({ i, room }); + } + if (candidates.length === 0) break; + + const pick = candidates[randInt(r, 0, candidates.length - 1)]; + add[pick.i] += 1; + overflow -= 1; + } + + // 최종 합 100 보장 + for (let i = 0; i < n; i++) out[i] += add[i]; + const sum = out.reduce((a, b) => a + b, 0); + if (sum !== 100) { + // 마지막 보정(이론상 거의 안 탐) + out[n - 1] += 100 - sum; + } + return out; }; -const bannerRow = (year: number, rowLabel: string, total: number, extra?: Record): ServerBannerRow => ({ +/** ✅ 그룹 키 정의(각 그룹 합 100) */ +const BANNER_GROUPS: Record = { + lifeStage: ["single", "noKids", "preschoolKids", "schoolKids", "adultKids", "independentSenior"], + household: ["hh1", "hh2", "hh3", "hh4Plus"], + age: ["age20s", "age30s", "age40s", "age50s", "age60s"], + tenure: ["ownerOccupied", "jeonse", "depositAndMonthly", "monthlyNoDeposit", "otherTenure"], + housing: ["apartment", "house", "officetel", "villa", "studio", "otherHousingType"], + pyeong: ["under19Pyeong", "pyeong20s", "pyeong30s", "pyeong40s", "pyeong50Plus"], + region: [ + "regionCapital", + "regionGyeongnamBusanUlsan", + "regionGyeongbukDaegu", + "regionJeollaGwangju", + "regionChungcheongDaejeonSejong", + "regionGangwonJeju", + ], + income: ["incomeUnder299", "income300to599", "income600to899", "income900Plus"], +}; + +/** ✅ 기존 상수 대신: 호출할 때마다 “결정적 랜덤” 분포 생성 */ +export const makeBannerDistDefault = (seedKey: string, range?: RandRange): Record => { + const seed = (hash32(seedKey) ^ DUMMY_SEED) >>> 0; + const r = mulberry32(seed); + + const minEach = range?.min ?? 1; + const maxEach = range?.max ?? 60; + + const out = {} as Record; + + (Object.keys(BANNER_GROUPS) as Array).forEach((groupName) => { + const keys = BANNER_GROUPS[groupName]; + const parts = splitTo100(r, keys.length, minEach, maxEach); // ✅ min/max 적용 + for (let i = 0; i < keys.length; i++) out[keys[i]] = parts[i]; + }); + + return out; +}; + +export const bannerRow = ( + year: number, + rowLabel: string, + total: number, + range: RandRange = { min: null, max: null }, + extra?: Partial>, +): ServerBannerRow => ({ year, rowLabel, total, - ...BANNER_DIST_DEFAULT, + ...makeBannerDistDefault(`${year}|${rowLabel}`, range), // ✅ min/max 적용 ...(extra ?? {}), }); @@ -197,21 +270,36 @@ export const apiOwnShareOfTotalPurchase: ServerProductRow[] = [ ]; export const apiLifeStageByProduct: ServerBannerRow[] = [ - bannerRow(26, "냉장고", 1200, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "세탁기", 1100, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "에어컨", 900, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "TV", 950, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "청소기", 1000, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "김치 냉장고", 700, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "공기 청정기", 800, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "가습기", 650, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "제습기", 600, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "건조기", 500, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "식기세척기", 450, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "의류 관리기", 320, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), - bannerRow(26, "로봇 청소기", 420, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }), + bannerRow(26, "냉장고", 1200), + bannerRow(26, "세탁기", 1100), + bannerRow(26, "에어컨", 900), + bannerRow(26, "TV", 950), + bannerRow(26, "청소기", 1000), + bannerRow(26, "김치 냉장고", 700), + bannerRow(26, "공기 청정기", 800), + bannerRow(26, "가습기", 650), + bannerRow(26, "제습기", 600), + bannerRow(26, "건조기", 500), + bannerRow(26, "식기세척기", 450), + bannerRow(26, "의류 관리기", 320), + bannerRow(26, "로봇 청소기", 420), ]; +export const apiLifeStageByProductForGauge: ServerBannerRow[] = [ + bannerRow(26, "냉장고", 1200, {min:10, max:99}), + bannerRow(26, "세탁기", 1100, {min:10, max:99}), + bannerRow(26, "에어컨", 900, {min:10, max:99}), + bannerRow(26, "TV", 950, {min:10, max:99}), + bannerRow(26, "청소기", 1000, {min:10, max:99}), + bannerRow(26, "김치 냉장고", 700, {min:10, max:99}), + bannerRow(26, "공기 청정기", 800, {min:10, max:99}), + bannerRow(26, "가습기", 650, {min:10, max:99}), + bannerRow(26, "제습기", 600, {min:10, max:99}), + bannerRow(26, "건조기", 500, {min:10, max:99}), + bannerRow(26, "식기세척기", 450, {min:10, max:99}), + bannerRow(26, "의류 관리기", 320, {min:10, max:99}), + bannerRow(26, "로봇 청소기", 420, {min:10, max:99}), +]; /** --------------------------- * API #6 * year rowLabel total banner diff --git a/src/const/lgConst.ts b/src/const/lgConst.ts index fc524c2..3b9f0f9 100644 --- a/src/const/lgConst.ts +++ b/src/const/lgConst.ts @@ -3,4 +3,11 @@ import {PRODUCT_KEY_MAP} from "@/components/lge-dashboard"; export const PRODUCT_KEYS = Object.keys(PRODUCT_KEY_MAP) as Array; export const PRODUCTS = Object.values(PRODUCT_KEY_MAP) as Array; export const YEARS = [24, 25, 26]; -export const BRAND_LIST = ['Cbrand', 'Samsung', 'LG']; \ No newline at end of file +export const BRAND_LIST = ['Cbrand', 'Samsung', 'LG']; + +/** X 축 패딩 없앤 GridOption*/ +export const GRID_X_NOT_PADDING = { left: 0, right: 0, top: 50, bottom: 10, containLabel: false } as const; +/** T 축 패딩 없앤 GridOption*/ +export const GRID_Y_NOT_PADDING = { left: 10, right: 10, top: 0, bottom: 0, containLabel: false } as const; +/** 축 스타일 감춤 */ +export const AXIS_HIDE_STYLE = { axisLabel: { show: false }, axisTick: { show: false }, axisLine: { show: false }} as const; \ No newline at end of file
+ {c.header}
-
-
- {showValue && ( -
- {v === null ? "-" : fmt(v)} -
- )} -
+ {v === null ? "-" : fmt(v)} +
+ {v === null ? "-" : fmt(v)}