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

@@ -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) => {
필터 <span className="text-sm leading-none mb-1">{isFilterOpen ? "▲" : "▼"}</span>
</button>
{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>
<ExcelDownloadButton/>

View File

@@ -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,

View File

@@ -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("<br/>");

View File

@@ -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);

View File

@@ -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, {