260319_01_ENH: 17일자 수정사항 적용

This commit is contained in:
2026-03-19 14:05:19 +09:00
parent c66b51ca53
commit b2cf1b846f
13 changed files with 115 additions and 19 deletions

View File

@@ -237,6 +237,7 @@ const LGPenetrationPage = () => {
chart={ chart={
<GroupedOverlayBar <GroupedOverlayBar
data={productChartData} data={productChartData}
questionText={"보급률"}
yearTotalColor={CHART_COLOR_BY_YEAR} yearTotalColor={CHART_COLOR_BY_YEAR}
yearFocusColor={CHART_FOCUS_COLOR_BY_YEAR} yearFocusColor={CHART_FOCUS_COLOR_BY_YEAR}
showFocusLabel={"last"} showFocusLabel={"last"}

View File

@@ -162,6 +162,7 @@ const LGPurchasePage = () => {
chart={ chart={
<GroupedOverlayBar <GroupedOverlayBar
data={purchaseChartData} data={purchaseChartData}
questionText={"구매율"}
yearTotalColor={CHART_COLOR_BY_YEAR} yearTotalColor={CHART_COLOR_BY_YEAR}
yearFocusColor={CHART_FOCUS_COLOR_BY_YEAR} yearFocusColor={CHART_FOCUS_COLOR_BY_YEAR}
showFocusLabel={"last"} showFocusLabel={"last"}

View File

@@ -80,10 +80,12 @@ const PurchasePage = () => {
const description = useMemo(() => { const description = useMemo(() => {
return "Q. 다음 중 귀댁에서 보유하고 계신 가전/전자 제품은 무엇입니까? 모두 선택해주세요.<br/>" + return "Q. 다음 중 귀댁에서 보유하고 계신 가전/전자 제품은 무엇입니까? 모두 선택해주세요.<br/>" +
"* 구독/렌탈/선물/경품/아파트 내 빌트인 제품을 모두 포함하여 선택해주세요.<br/>" + "* 구독/렌탈/선물/경품/아파트 내 빌트인 제품을 모두 포함하여 선택해주세요.<br/>" +
"Q. 보유하고 계신 (제품)을 언제 구입하셨습니까?<br/>" + "Q. 보유하고 계신 (제품)을 언제 구입하셨습니까?<br/>";
/*
"* 새 상품을 선물 받은 경우, 선물 받은 연도로 입력해주세요.<br/>" + "* 새 상품을 선물 받은 경우, 선물 받은 연도로 입력해주세요.<br/>" +
"** 중고 제품인 경우, 중고 제품을 구입한 연도로 입력해주세요.<br/>" + "** 중고 제품인 경우, 중고 제품을 구입한 연도로 입력해주세요.<br/>" +
"*** 신규 입주 시 빌트인되어 있던 제품은 입주한 연도를 입력해주세요."; "*** 신규 입주 시 빌트인되어 있던 제품은 입주한 연도를 입력해주세요.";
*/
}, []); }, []);
useEffect(() => { useEffect(() => {
@@ -113,7 +115,7 @@ const PurchasePage = () => {
paletteVarNames={["--chart-3", "--chart-2", "--chart-1"]} paletteVarNames={["--chart-3", "--chart-2", "--chart-1"]}
grid={GRID_X_NOT_PADDING} grid={GRID_X_NOT_PADDING}
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", min:0, max:100, ...AXIS_HIDE_STYLE }}
showFocusLabel={"last"} showFocusLabel={"last"}
height={260} height={260}
/> />

View File

@@ -1,6 +1,6 @@
"use client"; "use client";
import {ReactNode, useEffect, useRef, useState} from "react"; import {ReactNode, useEffect, useMemo, useRef, useState} from "react";
import {usePathname, useRouter} from "next/navigation"; import {usePathname, useRouter} from "next/navigation";
import {cn} from "@/lib/utils"; import {cn} from "@/lib/utils";
import {SelectedMap} from "@/types/common"; import {SelectedMap} from "@/types/common";
@@ -16,6 +16,7 @@ import {LayoutFilterProvider} from "./LayoutFilterContext";
import {LAST_YEAR, PRODUCTS_FILTER_ITEM} from "@/const/lgConst"; import {LAST_YEAR, PRODUCTS_FILTER_ITEM} from "@/const/lgConst";
import {ProductsFilterItem} from "@/types/lg"; import {ProductsFilterItem} from "@/types/lg";
import {ArrowUp, Filter} from "lucide-react"; import {ArrowUp, Filter} from "lucide-react";
import {Button} from "@/components/ui/button";
type MainLayoutProps = { type MainLayoutProps = {
children: ReactNode; children: ReactNode;
@@ -103,6 +104,21 @@ const MainLayout = ({ children }: MainLayoutProps) => {
scrollRef.current?.scrollTo({ top: 0, behavior: "smooth" }); scrollRef.current?.scrollTo({ top: 0, behavior: "smooth" });
}; };
const isDefaultTotalFilter = useMemo(() => {
if(!isTotal) return false;
return Object.values(totalValue).every(value => value === "0");
},[isTotal, totalValue])
const setDefaletTotalFilter = () => {
if(isTotal && !isDefaultTotalFilter){
setTotalValue(prev =>
Object.fromEntries(
Object.keys(prev).map(key => [key, "0"])
)
);
}
}
useEffect(() => { useEffect(() => {
const prevIsTotal = prevIsTotalRef.current; const prevIsTotal = prevIsTotalRef.current;
@@ -161,8 +177,17 @@ const MainLayout = ({ children }: MainLayoutProps) => {
필터 <span className="text-sm leading-none mb-1">{isFilterOpen ? "▲" : "▼"}</span> 필터 <span className="text-sm leading-none mb-1">{isFilterOpen ? "▲" : "▼"}</span>
</button> </button>
{isTotal && ( {isTotal && (
<div className={"ml-5 content-text-sm"} dangerouslySetInnerHTML={{__html: totalPartDescription}}> <>
</div> <Button
variant={isDefaultTotalFilter ? "secondary" : "default"}
onClick={setDefaletTotalFilter}
className="h-6 rounded-sm px-3 ml-3 text-sm font-semibold content-text-sm"
>
초기화
</Button>
<div className={"ml-5 content-text-sm"} dangerouslySetInnerHTML={{__html: totalPartDescription}}>
</div>
</>
)} )}
</div> </div>
<ExcelDownloadButton/> <ExcelDownloadButton/>

View File

@@ -59,7 +59,6 @@ const normalizeSeries = (series?: EChartsOption["series"]): EChartsOption["serie
return Array.isArray(series) ? series.map(normalizeOne) : normalizeOne(series); return Array.isArray(series) ? series.map(normalizeOne) : normalizeOne(series);
}; };
const BaseEChart = ({ const BaseEChart = ({
option, option,
height = CHART_HEIGHTS.DEFAULT, height = CHART_HEIGHTS.DEFAULT,

View File

@@ -13,14 +13,14 @@ import BaseEChart from "../BaseEChart";
import { buildLgPalette } from "../color"; import { buildLgPalette } from "../color";
import { GroupedOverlayBarData, ShowLabel} from "../types"; import { GroupedOverlayBarData, ShowLabel} from "../types";
import {getIsShowLabel, roundedRectIcon} from "@/components/lge-dashboard/chart/utill"; import {getIsShowLabel, roundedRectIcon} from "@/components/lge-dashboard/chart/utill";
import {AXIS_HIDE_STYLE} from "@/const/lgConst"; import {AXIS_HIDE_STYLE, AXIS_HIDE_Y_STYLE} from "@/const/lgConst";
import { CHART_HEIGHTS, LEGEND_ITEM_SIZE } from "@/const/chartConst"; import { CHART_HEIGHTS, LEGEND_ITEM_SIZE } from "@/const/chartConst";
import {makeTotalBasePct} from "@/lib/lg-dashboard"; import {makeTotalBasePct} from "@/lib/lg-dashboard";
type Props = { type Props = {
data: GroupedOverlayBarData; data: GroupedOverlayBarData;
height?: number | string; height?: number | string;
questionText: string;
tooltip?: TooltipComponentOption; tooltip?: TooltipComponentOption;
grid?: GridComponentOption; grid?: GridComponentOption;
xAxis?: XAXisComponentOption; xAxis?: XAXisComponentOption;
@@ -36,6 +36,7 @@ type Props = {
const GroupedOverlayBar = ({ const GroupedOverlayBar = ({
data, data,
questionText,
height = CHART_HEIGHTS.DEFAULT, height = CHART_HEIGHTS.DEFAULT,
tooltip, tooltip,
grid, grid,
@@ -60,7 +61,7 @@ const GroupedOverlayBar = ({
const option = useMemo(() => { const option = useMemo(() => {
const defaultGrid: EChartsOption["grid"] = {left: 10, right: 10, top: 40, bottom: 10, containLabel: true}; const defaultGrid: EChartsOption["grid"] = {left: 10, right: 10, top: 40, bottom: 10, containLabel: true};
const defaultYAxis: EChartsOption["yAxis"] = { type: "value", ...AXIS_HIDE_STYLE }; const defaultYAxis: EChartsOption["yAxis"] = { type: "value", ...AXIS_HIDE_Y_STYLE };
const expandedCategories: string[] = []; const expandedCategories: string[] = [];
data.categories.forEach((cat, catIdx) => { data.categories.forEach((cat, catIdx) => {
years.forEach(year => { years.forEach(year => {
@@ -204,6 +205,7 @@ const GroupedOverlayBar = ({
formatter: (params: any) => { formatter: (params: any) => {
const arr = Array.isArray(params) ? params : [params]; const arr = Array.isArray(params) ? params : [params];
const header = arr?.[0]?.axisValueLabel ?? ""; const header = arr?.[0]?.axisValueLabel ?? "";
//header += ` ${questionText}`;
// bar만 // bar만
const barItems = arr const barItems = arr
@@ -231,7 +233,8 @@ const GroupedOverlayBar = ({
const pct = makeTotalBasePct(t, f); const pct = makeTotalBasePct(t, f);
//const pctStr = pct > 0 ? ` (${pct}%)` : ""; //const pctStr = pct > 0 ? ` (${pct}%)` : "";
//return `${totalName} ${t} 중 ${focusName} ${f}${pctStr}`; //return `${totalName} ${t} 중 ${focusName} ${f}${pctStr}`;
return `${totalName} ${t} 중 ${focusName} ${f}`; //return `${totalName} ${t} 중 ${focusName} ${f}`;
return `${questionText} ${totalName} ${t} 중 ${focusName} ${f}`;
}); });
return [header, ...lines].join("<br/>"); return [header, ...lines].join("<br/>");

View File

@@ -13,7 +13,7 @@ import BaseEChart from "../BaseEChart";
import { GroupedStackBarData, ShowLabel} from "../types"; import { GroupedStackBarData, ShowLabel} from "../types";
import { buildLgPalette } from "@/components/lge-dashboard/color"; import { buildLgPalette } from "@/components/lge-dashboard/color";
import {getIsShowLabel, roundedRectIcon} from "@/components/lge-dashboard/chart/utill"; import {getIsShowLabel, roundedRectIcon} from "@/components/lge-dashboard/chart/utill";
import {AXIS_HIDE_STYLE} from "@/const/lgConst"; import {AXIS_HIDE_STYLE, AXIS_HIDE_Y_STYLE} from "@/const/lgConst";
import { LEGEND_ITEM_SIZE } from "@/const/chartConst"; import { LEGEND_ITEM_SIZE } from "@/const/chartConst";
type Props = { type Props = {
@@ -58,7 +58,7 @@ const GroupedStackBar = ({
const option = useMemo(() => { const option = useMemo(() => {
const defaultGrid: EChartsOption["grid"] = {left: 10, right: 10, top: 60, bottom: 10, containLabel: true}; const defaultGrid: EChartsOption["grid"] = {left: 10, right: 10, top: 60, bottom: 10, containLabel: true};
const defaultXAxis: EChartsOption["xAxis"] = { type: "category", data: data.categories, ...AXIS_HIDE_STYLE }; const defaultXAxis: EChartsOption["xAxis"] = { type: "category", data: data.categories, ...AXIS_HIDE_STYLE };
const defaultYAxis: EChartsOption["yAxis"] = { type: "value", ...AXIS_HIDE_STYLE }; const defaultYAxis: EChartsOption["yAxis"] = { type: "value", ...AXIS_HIDE_Y_STYLE };
const latestPalette = buildLgPalette(yearBrandPalette); const latestPalette = buildLgPalette(yearBrandPalette);

View File

@@ -66,13 +66,26 @@ const StackBar = ({
const fmt = valueFormatter ?? ((v: number) => String(v)); const fmt = valueFormatter ?? ((v: number) => String(v));
const isV = orientation === "vertical"; const isV = orientation === "vertical";
const seriseSum: number[] = new Array(renderData.categories.length).fill(0);
renderData.categories.forEach((c, i) => {
renderData.series.forEach((s) => {
seriseSum[i] += Number(s.data[i]);
})
});
const seriesSumMax = Math.max(...seriseSum);
const valueAxis: { min: number; max?: number } = { min: 0 };
if (seriesSumMax > 100) {
valueAxis.max = Math.ceil(seriesSumMax / 5) * 5;
}
return { return {
color: palette, color: palette,
tooltip: tooltip ?? (isReverse ? createReverseTooltip(data, fmt) : createDefaultTooltip(fmt)), tooltip: tooltip ?? (isReverse ? createReverseTooltip(data, fmt) : createDefaultTooltip(fmt)),
legend: legend ?? (isReverse ? createReverseLegend(data) : createDefaultLegend()), legend: legend ?? (isReverse ? createReverseLegend(data) : createDefaultLegend()),
grid: grid ?? createDefaultGrid(), grid: grid ?? createDefaultGrid(),
xAxis: xAxis ?? (isV ? createCategoryAxis(renderData.categories) : createValueAxis()), xAxis: xAxis ?? (isV ? createCategoryAxis(renderData.categories) : createValueAxis(false, valueAxis)),
yAxis: yAxis ?? (isV ? createValueAxis() : createCategoryAxis(renderData.categories)), yAxis: yAxis ?? (isV ? createValueAxis(false, valueAxis) : createCategoryAxis(renderData.categories)),
series: renderData.series.map((s) => series: renderData.series.map((s) =>
createBarSeries(s.name, s.data, { createBarSeries(s.name, s.data, {

View File

@@ -1,4 +1,5 @@
import { import {
CategoryByDataBanner,
CategoryTargetData, CategoryTargetData,
CategoryTargetItem, CategoryTargetItem,
CategoryTargetType, CategoryTargetType,
@@ -146,3 +147,38 @@ export const categoryTarget: CategoryTargetItem[] = [
] ]
}, },
] ]
export const categoryByDataBanner:CategoryByDataBanner[] = [
{
variable:"lifeStage",
variableName:"라이프 스테이지",
},
{
variable:"age",
variableName:"연령대",
},
{
variable:"household",
variableName:"가구원 수",
},
{
variable:"occupancy",
variableName:"입주 형태",
},
{
variable:"housing",
variableName:"주거 형태",
},
{
variable:"houseSize",
variableName:"거주 평형",
},
{
variable:"income",
variableName:"월 소득 규모",
},
{
variable:"region",
variableName:"지역",
},
]

View File

@@ -25,6 +25,11 @@ export enum CategoryTargetData {
PAYMENT_METHOD = 15, PAYMENT_METHOD = 15,
} }
export type CategoryByDataBanner = {
variable: string;
variableName: string;
};
export type CategoryTargetTypeItem = { export type CategoryTargetTypeItem = {
label: string; label: string;
value: CategoryTargetType; value: CategoryTargetType;

View File

@@ -141,8 +141,8 @@ export const PRODUCTS_FILTER_ITEM = [
path: "living", path: "living",
items: [ items: [
"KPRODUCT#7", // 세탁기 "KPRODUCT#7", // 세탁기
"KPRODUCT#8", // 청소기
"KPRODUCT#9", // 건조기 "KPRODUCT#9", // 건조기
"KPRODUCT#8", // 청소기
"KPRODUCT#10", // 로봇 청소기 "KPRODUCT#10", // 로봇 청소기
"KPRODUCT#11", // 의류 관리기 "KPRODUCT#11", // 의류 관리기
], ],
@@ -270,6 +270,7 @@ export const QID_SURVEY_TITLE: Record<string, string> = {
"KQX3_10": "Q. 귀하께서 [#YEAR#]년에 구매하신 제품의 스크린 사이즈는 어떻게 되십니까?", "KQX3_10": "Q. 귀하께서 [#YEAR#]년에 구매하신 제품의 스크린 사이즈는 어떻게 되십니까?",
"KQX3_11": "Q. 귀하께서 [#YEAR#]년에 구매하신 제품의 가장 주된 용도는 무엇입니까?", "KQX3_11": "Q. 귀하께서 [#YEAR#]년에 구매하신 제품의 가장 주된 용도는 무엇입니까?",
"KQX3_12": "Q. 귀하께서 [#YEAR#]년에 구매하신 제품은 스마트 모니터(자체적으로 OS를 가지고 있어, 기타 기기 연결 없이 작동이 가능한 모니터) 입니까?", "KQX3_12": "Q. 귀하께서 [#YEAR#]년에 구매하신 제품은 스마트 모니터(자체적으로 OS를 가지고 있어, 기타 기기 연결 없이 작동이 가능한 모니터) 입니까?",
"KQX3_13": "Q. 보유하고 계신 제품의 구동 방식은 어떻게 되십니까?",
"KQB2": "Q. 귀하께서는 [#YEAR#]년에 제품을 신규로 구입하신 건가요? 교체/추가 구입하신 건가요? 한 가지만 선택해주세요", "KQB2": "Q. 귀하께서는 [#YEAR#]년에 제품을 신규로 구입하신 건가요? 교체/추가 구입하신 건가요? 한 가지만 선택해주세요",
"KQB3": "Q. 귀하께서 [#YEAR#]년에 제품을 구입하신 이유/계기(상황)는 무엇입니까? 가장 주요한 이유/계기를 한 가지만 선택해주세요", "KQB3": "Q. 귀하께서 [#YEAR#]년에 제품을 구입하신 이유/계기(상황)는 무엇입니까? 가장 주요한 이유/계기를 한 가지만 선택해주세요",
"KQB4_NET": "Q. 최종적으로 제품을 구매하신 곳은 어디십니까? 한 가지만 선택해주세요", "KQB4_NET": "Q. 최종적으로 제품을 구매하신 곳은 어디십니까? 한 가지만 선택해주세요",
@@ -285,6 +286,7 @@ export const QID_SURVEY_TITLE: Record<string, string> = {
"KQA3_10": "Q. 보유하고 계신 제품의 스크린 사이즈는 어떻게 되십니까?", "KQA3_10": "Q. 보유하고 계신 제품의 스크린 사이즈는 어떻게 되십니까?",
"KQA3_11": "Q. 보유하고 계신 제품의 가장 주된 용도는 무엇입니까?", "KQA3_11": "Q. 보유하고 계신 제품의 가장 주된 용도는 무엇입니까?",
"KQA3_12": "Q. 보유하고 계신 제품은 스마트 모니터(자체적으로 OS를 가지고 있어, 기타 기기 연결 없이 작동이 가능한 모니터) 입니까?", "KQA3_12": "Q. 보유하고 계신 제품은 스마트 모니터(자체적으로 OS를 가지고 있어, 기타 기기 연결 없이 작동이 가능한 모니터) 입니까?",
"KQA3_13": "Q. 보유하고 계신 제품의 구동 방식은 어떻게 되십니까?",
"KQA3_1": "Q. 보유하고 계신 제품을 구매 또는 보유하게 된 경로가 어떻게 되십니까? ", "KQA3_1": "Q. 보유하고 계신 제품을 구매 또는 보유하게 된 경로가 어떻게 되십니까? ",
"KQA3_2_1": "Q. 귀하께서는 제품을 어떤 방식으로 구입하셨습니까? ", "KQA3_2_1": "Q. 귀하께서는 제품을 어떤 방식으로 구입하셨습니까? ",
"KQC2": "Q. 귀하께서 [#NEXT_YEAR#]년 이내 구입을 고려하시는 제품의 브랜드로 고려하고 계신 것은 무엇입니까? 모두 선택해주세요", "KQC2": "Q. 귀하께서 [#NEXT_YEAR#]년 이내 구입을 고려하시는 제품의 브랜드로 고려하고 계신 것은 무엇입니까? 모두 선택해주세요",
@@ -483,6 +485,15 @@ export const CATEGORY_PAGE_FIELDS: Record<CategoryTargetData, CategoryFieldSpec[
[CategoryTargetType.PURCHASE]: "KQX3_12" [CategoryTargetType.PURCHASE]: "KQX3_12"
} }
}, },
{
title: "음식물처리기 구동 방식",
requestKey: "category_${keyBase}_driveMethod",
chartMode: "horizontal",
qidByMode: {
[CategoryTargetType.PENETRATION]: "KQA3_13",
[CategoryTargetType.PURCHASE]: "KQX3_13"
}
},
], ],
[CategoryTargetData.BEHAVIOR]: [ [CategoryTargetData.BEHAVIOR]: [
@@ -551,6 +562,7 @@ export const GRID_X_NOT_PADDING = { left: 0, right: 0, top: 50, bottom: 10, cont
export const GRID_Y_NOT_PADDING = { left: 10, right: 10, top: 0, bottom: 0, containLabel: false } as const; 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; export const AXIS_HIDE_STYLE = { axisLabel: { show: false }, axisTick: { show: false }, axisLine: { show: false }} as const;
export const AXIS_HIDE_Y_STYLE = { min:0, max:100, axisLabel: { show: false }, axisTick: { show: false }, axisLine: { show: false }} as const;
export const CHART_COLOR_BY_YEAR = Object.fromEntries( export const CHART_COLOR_BY_YEAR = Object.fromEntries(
YEARS.map((year, i) => [ YEARS.map((year, i) => [

View File

@@ -1,5 +1,6 @@
import { CHART_GRID_DEFAULTS, BAR_WIDTHS } from "@/const/chartConst"; import { CHART_GRID_DEFAULTS, BAR_WIDTHS } from "@/const/chartConst";
import {ChartData, NewNumber} from "@/components/lge-dashboard"; import {ChartData, NewNumber} from "@/components/lge-dashboard";
import {AXIS_HIDE_Y_STYLE} from "@/const/lgConst";
export function reverseCategories<T extends ChartData>(data: T): T { export function reverseCategories<T extends ChartData>(data: T): T {
const categories = [...data.categories].reverse(); const categories = [...data.categories].reverse();
@@ -180,9 +181,7 @@ export function createValueAxis(
if (hideStyle) { if (hideStyle) {
return { return {
...base, ...base,
axisLabel: { show: false }, ...AXIS_HIDE_Y_STYLE,
axisTick: { show: false },
axisLine: { show: false },
splitLine: { show: false }, splitLine: { show: false },
...overrides, ...overrides,
}; };

View File

@@ -469,7 +469,7 @@ export const makeTotalBasePct = (t:number|string, f:number|string):number => {
export const calcTotalBaseRow = (label:string, totalRow: ProductRow, targetRow: ProductRow): ProductRow => { export const calcTotalBaseRow = (label:string, totalRow: ProductRow, targetRow: ProductRow): ProductRow => {
const out: ProductRow = { const out: ProductRow = {
year: targetRow?.year ?? "", year: targetRow?.year ?? "",
rowLabel: `전체 ${label} 중 자사제품 비율`, rowLabel: `조사 년도 ${label} 중 자사제품 비율`,
total: fixedDecimalPoint(makeTotalBasePct(totalRow.total, targetRow.total)) total: fixedDecimalPoint(makeTotalBasePct(totalRow.total, targetRow.total))
}; };