diff --git a/src/app/(pages)/(main)/total/lg-penetration/page.tsx b/src/app/(pages)/(main)/total/lg-penetration/page.tsx index d28964a..3e88984 100644 --- a/src/app/(pages)/(main)/total/lg-penetration/page.tsx +++ b/src/app/(pages)/(main)/total/lg-penetration/page.tsx @@ -237,6 +237,7 @@ const LGPenetrationPage = () => { chart={ { chart={ { const description = useMemo(() => { return "Q. 다음 중 귀댁에서 보유하고 계신 가전/전자 제품은 무엇입니까? 모두 선택해주세요.
" + "* 구독/렌탈/선물/경품/아파트 내 빌트인 제품을 모두 포함하여 선택해주세요.
" + - "Q. 보유하고 계신 (제품)을 언제 구입하셨습니까?
" + + "Q. 보유하고 계신 (제품)을 언제 구입하셨습니까?
"; + /* "* 새 상품을 선물 받은 경우, 선물 받은 연도로 입력해주세요.
" + "** 중고 제품인 경우, 중고 제품을 구입한 연도로 입력해주세요.
" + "*** 신규 입주 시 빌트인되어 있던 제품은 입주한 연도를 입력해주세요."; + */ }, []); useEffect(() => { @@ -113,7 +115,7 @@ const PurchasePage = () => { 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 }} + yAxis={{ type: "value", min:0, max:100, ...AXIS_HIDE_STYLE }} showFocusLabel={"last"} height={260} /> diff --git a/src/components/layout/MainLayout.tsx b/src/components/layout/MainLayout.tsx index 3ca876f..7cd500a 100644 --- a/src/components/layout/MainLayout.tsx +++ b/src/components/layout/MainLayout.tsx @@ -1,6 +1,6 @@ "use client"; -import {ReactNode, useEffect, useRef, useState} from "react"; +import {ReactNode, useEffect, useMemo, useRef, useState} from "react"; import {usePathname, useRouter} from "next/navigation"; import {cn} from "@/lib/utils"; import {SelectedMap} from "@/types/common"; @@ -16,6 +16,7 @@ import {LayoutFilterProvider} from "./LayoutFilterContext"; import {LAST_YEAR, PRODUCTS_FILTER_ITEM} from "@/const/lgConst"; import {ProductsFilterItem} from "@/types/lg"; import {ArrowUp, Filter} from "lucide-react"; +import {Button} from "@/components/ui/button"; type MainLayoutProps = { children: ReactNode; @@ -103,6 +104,21 @@ const MainLayout = ({ children }: MainLayoutProps) => { 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(() => { const prevIsTotal = prevIsTotalRef.current; @@ -161,8 +177,17 @@ const MainLayout = ({ children }: MainLayoutProps) => { 필터 {isFilterOpen ? "▲" : "▼"} {isTotal && ( -
-
+ <> + +
+
+ )} diff --git a/src/components/lge-dashboard/BaseEChart.tsx b/src/components/lge-dashboard/BaseEChart.tsx index 57a7cde..2e0675c 100644 --- a/src/components/lge-dashboard/BaseEChart.tsx +++ b/src/components/lge-dashboard/BaseEChart.tsx @@ -59,7 +59,6 @@ const normalizeSeries = (series?: EChartsOption["series"]): EChartsOption["serie return Array.isArray(series) ? series.map(normalizeOne) : normalizeOne(series); }; - const BaseEChart = ({ option, height = CHART_HEIGHTS.DEFAULT, diff --git a/src/components/lge-dashboard/chart/GroupedOverlayBar.tsx b/src/components/lge-dashboard/chart/GroupedOverlayBar.tsx index 516dea0..ea0ea41 100644 --- a/src/components/lge-dashboard/chart/GroupedOverlayBar.tsx +++ b/src/components/lge-dashboard/chart/GroupedOverlayBar.tsx @@ -13,14 +13,14 @@ import BaseEChart from "../BaseEChart"; import { buildLgPalette } from "../color"; import { GroupedOverlayBarData, ShowLabel} from "../types"; 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 {makeTotalBasePct} from "@/lib/lg-dashboard"; type Props = { data: GroupedOverlayBarData; height?: number | string; - + questionText: string; tooltip?: TooltipComponentOption; grid?: GridComponentOption; xAxis?: XAXisComponentOption; @@ -36,6 +36,7 @@ type Props = { const GroupedOverlayBar = ({ data, + questionText, height = CHART_HEIGHTS.DEFAULT, tooltip, grid, @@ -60,7 +61,7 @@ const GroupedOverlayBar = ({ const option = useMemo(() => { 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[] = []; data.categories.forEach((cat, catIdx) => { years.forEach(year => { @@ -204,6 +205,7 @@ const GroupedOverlayBar = ({ formatter: (params: any) => { const arr = Array.isArray(params) ? params : [params]; const header = arr?.[0]?.axisValueLabel ?? ""; + //header += ` ${questionText}`; // bar만 const barItems = arr @@ -231,7 +233,8 @@ const GroupedOverlayBar = ({ const pct = makeTotalBasePct(t, f); //const pctStr = pct > 0 ? ` (${pct}%)` : ""; //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("
"); diff --git a/src/components/lge-dashboard/chart/GroupedStackBar.tsx b/src/components/lge-dashboard/chart/GroupedStackBar.tsx index 906892e..2e93071 100644 --- a/src/components/lge-dashboard/chart/GroupedStackBar.tsx +++ b/src/components/lge-dashboard/chart/GroupedStackBar.tsx @@ -13,7 +13,7 @@ import BaseEChart from "../BaseEChart"; 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"; +import {AXIS_HIDE_STYLE, AXIS_HIDE_Y_STYLE} from "@/const/lgConst"; import { LEGEND_ITEM_SIZE } from "@/const/chartConst"; type Props = { @@ -58,7 +58,7 @@ const GroupedStackBar = ({ const option = useMemo(() => { 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 defaultYAxis: EChartsOption["yAxis"] = { type: "value", ...AXIS_HIDE_STYLE }; + const defaultYAxis: EChartsOption["yAxis"] = { type: "value", ...AXIS_HIDE_Y_STYLE }; const latestPalette = buildLgPalette(yearBrandPalette); diff --git a/src/components/lge-dashboard/chart/StackBar.tsx b/src/components/lge-dashboard/chart/StackBar.tsx index 90c1bcb..eedb6ca 100644 --- a/src/components/lge-dashboard/chart/StackBar.tsx +++ b/src/components/lge-dashboard/chart/StackBar.tsx @@ -66,13 +66,26 @@ const StackBar = ({ const fmt = valueFormatter ?? ((v: number) => String(v)); 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 { color: palette, tooltip: tooltip ?? (isReverse ? createReverseTooltip(data, fmt) : createDefaultTooltip(fmt)), legend: legend ?? (isReverse ? createReverseLegend(data) : createDefaultLegend()), grid: grid ?? createDefaultGrid(), - xAxis: xAxis ?? (isV ? createCategoryAxis(renderData.categories) : createValueAxis()), - yAxis: yAxis ?? (isV ? createValueAxis() : createCategoryAxis(renderData.categories)), + xAxis: xAxis ?? (isV ? createCategoryAxis(renderData.categories) : createValueAxis(false, valueAxis)), + yAxis: yAxis ?? (isV ? createValueAxis(false, valueAxis) : createCategoryAxis(renderData.categories)), series: renderData.series.map((s) => createBarSeries(s.name, s.data, { diff --git a/src/config/filter.data.ts b/src/config/filter.data.ts index 457d3f2..db2a465 100644 --- a/src/config/filter.data.ts +++ b/src/config/filter.data.ts @@ -1,4 +1,5 @@ import { + CategoryByDataBanner, CategoryTargetData, CategoryTargetItem, CategoryTargetType, @@ -145,4 +146,39 @@ export const categoryTarget: CategoryTargetItem[] = [ { value: CategoryTargetData.PAYMENT_METHOD, label: "구매 형식"}, ] }, +] + +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:"지역", + }, ] \ No newline at end of file diff --git a/src/config/filter.types.ts b/src/config/filter.types.ts index 6698c85..03bcd48 100644 --- a/src/config/filter.types.ts +++ b/src/config/filter.types.ts @@ -25,6 +25,11 @@ export enum CategoryTargetData { PAYMENT_METHOD = 15, } +export type CategoryByDataBanner = { + variable: string; + variableName: string; +}; + export type CategoryTargetTypeItem = { label: string; value: CategoryTargetType; diff --git a/src/const/lgConst.ts b/src/const/lgConst.ts index 8bc0b52..01481ef 100644 --- a/src/const/lgConst.ts +++ b/src/const/lgConst.ts @@ -141,8 +141,8 @@ export const PRODUCTS_FILTER_ITEM = [ path: "living", items: [ "KPRODUCT#7", // 세탁기 - "KPRODUCT#8", // 청소기 "KPRODUCT#9", // 건조기 + "KPRODUCT#8", // 청소기 "KPRODUCT#10", // 로봇 청소기 "KPRODUCT#11", // 의류 관리기 ], @@ -270,6 +270,7 @@ export const QID_SURVEY_TITLE: Record = { "KQX3_10": "Q. 귀하께서 [#YEAR#]년에 구매하신 제품의 스크린 사이즈는 어떻게 되십니까?", "KQX3_11": "Q. 귀하께서 [#YEAR#]년에 구매하신 제품의 가장 주된 용도는 무엇입니까?", "KQX3_12": "Q. 귀하께서 [#YEAR#]년에 구매하신 제품은 스마트 모니터(자체적으로 OS를 가지고 있어, 기타 기기 연결 없이 작동이 가능한 모니터) 입니까?", + "KQX3_13": "Q. 보유하고 계신 제품의 구동 방식은 어떻게 되십니까?", "KQB2": "Q. 귀하께서는 [#YEAR#]년에 제품을 신규로 구입하신 건가요? 교체/추가 구입하신 건가요? 한 가지만 선택해주세요", "KQB3": "Q. 귀하께서 [#YEAR#]년에 제품을 구입하신 이유/계기(상황)는 무엇입니까? 가장 주요한 이유/계기를 한 가지만 선택해주세요", "KQB4_NET": "Q. 최종적으로 제품을 구매하신 곳은 어디십니까? 한 가지만 선택해주세요", @@ -285,6 +286,7 @@ export const QID_SURVEY_TITLE: Record = { "KQA3_10": "Q. 보유하고 계신 제품의 스크린 사이즈는 어떻게 되십니까?", "KQA3_11": "Q. 보유하고 계신 제품의 가장 주된 용도는 무엇입니까?", "KQA3_12": "Q. 보유하고 계신 제품은 스마트 모니터(자체적으로 OS를 가지고 있어, 기타 기기 연결 없이 작동이 가능한 모니터) 입니까?", + "KQA3_13": "Q. 보유하고 계신 제품의 구동 방식은 어떻게 되십니까?", "KQA3_1": "Q. 보유하고 계신 제품을 구매 또는 보유하게 된 경로가 어떻게 되십니까? ", "KQA3_2_1": "Q. 귀하께서는 제품을 어떤 방식으로 구입하셨습니까? ", "KQC2": "Q. 귀하께서 [#NEXT_YEAR#]년 이내 구입을 고려하시는 제품의 브랜드로 고려하고 계신 것은 무엇입니까? 모두 선택해주세요", @@ -483,6 +485,15 @@ export const CATEGORY_PAGE_FIELDS: Record [ diff --git a/src/lib/chart-options.ts b/src/lib/chart-options.ts index d299977..601ad18 100644 --- a/src/lib/chart-options.ts +++ b/src/lib/chart-options.ts @@ -1,5 +1,6 @@ import { CHART_GRID_DEFAULTS, BAR_WIDTHS } from "@/const/chartConst"; import {ChartData, NewNumber} from "@/components/lge-dashboard"; +import {AXIS_HIDE_Y_STYLE} from "@/const/lgConst"; export function reverseCategories(data: T): T { const categories = [...data.categories].reverse(); @@ -180,9 +181,7 @@ export function createValueAxis( if (hideStyle) { return { ...base, - axisLabel: { show: false }, - axisTick: { show: false }, - axisLine: { show: false }, + ...AXIS_HIDE_Y_STYLE, splitLine: { show: false }, ...overrides, }; diff --git a/src/lib/lg-dashboard.ts b/src/lib/lg-dashboard.ts index b2b3424..006ebe1 100644 --- a/src/lib/lg-dashboard.ts +++ b/src/lib/lg-dashboard.ts @@ -469,7 +469,7 @@ export const makeTotalBasePct = (t:number|string, f:number|string):number => { export const calcTotalBaseRow = (label:string, totalRow: ProductRow, targetRow: ProductRow): ProductRow => { const out: ProductRow = { year: targetRow?.year ?? "", - rowLabel: `전체 ${label} 중 자사제품 비율`, + rowLabel: `조사 년도 ${label} 중 자사제품 비율`, total: fixedDecimalPoint(makeTotalBasePct(totalRow.total, targetRow.total)) };