260819_01_ENH: 사이트 타이틀 폰트 사이즈 키움, 차트 레이블 가변 줄바꿈 처리, 네비게이션 파트 가변 줄바꿈 적용
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { ChevronDown } from "lucide-react";
|
import { ChevronDown } from "lucide-react";
|
||||||
import { useParams, useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { KriBarChart } from "@/components/chart";
|
import { KriBarChart } from "@/components/chart";
|
||||||
import { AppPageTitle } from "@/components/app-shell/AppPageTitle";
|
import { AppPageTitle } from "@/components/app-shell/AppPageTitle";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
@@ -58,13 +58,35 @@ function buildHiddenCategoryNote(group: ResultGroup): string | null {
|
|||||||
return `※ ${parts.join(isSingleSeries ? ", " : " | ")}`;
|
return `※ ${parts.join(isSingleSeries ? ", " : " | ")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// x축 카테고리 라벨 폭을 컨테이너 실측 폭 기준으로 계산한다(카테고리당 슬롯 폭에 여유를 둔 값).
|
||||||
|
// 고정값을 쓰면 화면이 넓을 때는 불필요하게 줄바꿈되고, 좁을 때는 라벨이 겹치는 문제가 생긴다.
|
||||||
|
const MIN_AXIS_LABEL_WIDTH = 48;
|
||||||
|
|
||||||
function ResultGroupChart({ group }: { group: ResultGroup }) {
|
function ResultGroupChart({ group }: { group: ResultGroup }) {
|
||||||
const chartData = toChartData(group.categories, group.series);
|
const chartData = toChartData(group.categories, group.series);
|
||||||
const hasChartData = chartData.categories.length > 0 && chartData.series.length > 0;
|
const hasChartData = chartData.categories.length > 0 && chartData.series.length > 0;
|
||||||
|
const chartWrapperRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [axisLabelWidth, setAxisLabelWidth] = useState<number>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const el = chartWrapperRef.current;
|
||||||
|
if (!el || chartData.categories.length === 0) return;
|
||||||
|
|
||||||
|
const updateAxisLabelWidth = () => {
|
||||||
|
const width = (el.clientWidth / chartData.categories.length) * 0.85;
|
||||||
|
setAxisLabelWidth(Math.max(MIN_AXIS_LABEL_WIDTH, width));
|
||||||
|
};
|
||||||
|
|
||||||
|
updateAxisLabelWidth();
|
||||||
|
const observer = new ResizeObserver(updateAxisLabelWidth);
|
||||||
|
observer.observe(el);
|
||||||
|
return () => observer.disconnect();
|
||||||
|
}, [chartData.categories.length]);
|
||||||
|
|
||||||
if (!hasChartData) return null;
|
if (!hasChartData) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div ref={chartWrapperRef}>
|
||||||
<KriBarChart
|
<KriBarChart
|
||||||
categories={chartData.categories}
|
categories={chartData.categories}
|
||||||
series={chartData.series.map((item) => ({
|
series={chartData.series.map((item) => ({
|
||||||
@@ -82,11 +104,18 @@ function ResultGroupChart({ group }: { group: ResultGroup }) {
|
|||||||
}))}
|
}))}
|
||||||
legend={{ left: 0, top: 0, textStyle: { fontSize: CHART_FONT_SIZE } }}
|
legend={{ left: 0, top: 0, textStyle: { fontSize: CHART_FONT_SIZE } }}
|
||||||
grid={{ top: 55, right: 25, bottom: 5, left: 0, containLabel: true }}
|
grid={{ top: 55, right: 25, bottom: 5, left: 0, containLabel: true }}
|
||||||
xAxis={{ axisLabel: { fontSize: CHART_FONT_SIZE, interval: 0 } }}
|
xAxis={{
|
||||||
|
axisLabel: {
|
||||||
|
fontSize: CHART_FONT_SIZE,
|
||||||
|
interval: 0,
|
||||||
|
...(axisLabelWidth ? { width: axisLabelWidth, overflow: "break" as const } : {}),
|
||||||
|
},
|
||||||
|
}}
|
||||||
yAxis={{ min: 0, max: 100, interval: 25, axisLabel: { fontSize: CHART_FONT_SIZE } }}
|
yAxis={{ min: 0, max: 100, interval: 25, axisLabel: { fontSize: CHART_FONT_SIZE } }}
|
||||||
barMaxWidth={CHART_BAR_MAX_WIDTH}
|
barMaxWidth={CHART_BAR_MAX_WIDTH}
|
||||||
height={CHART_HEIGHT}
|
height={CHART_HEIGHT}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export function AppHeader({ menuOpen, showMenuButton, activeMenuId, topMenus, us
|
|||||||
className="h-6 w-auto object-contain brightness-0 invert"
|
className="h-6 w-auto object-contain brightness-0 invert"
|
||||||
priority
|
priority
|
||||||
/>
|
/>
|
||||||
<span className="text-lg font-bold tracking-tight text-white">2026년 에너지 국민인식조사</span>
|
<span className="text-2xl font-bold tracking-tight text-white">2026년 에너지 국민인식조사</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
menus={topMenus}
|
menus={topMenus}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export function KriSidebar({
|
|||||||
onClick={() => item.path && onNavigate?.(item.path, item)}
|
onClick={() => item.path && onNavigate?.(item.path, item)}
|
||||||
>
|
>
|
||||||
{Icon ? <Icon className="size-4 shrink-0" /> : null}
|
{Icon ? <Icon className="size-4 shrink-0" /> : null}
|
||||||
<span className="min-w-0 flex-1">{item.label}</span>
|
<span className="min-w-0 flex-1 whitespace-normal break-keep break-words">{item.label}</span>
|
||||||
<span className="shrink-0 text-xs whitespace-nowrap text-muted-foreground">{questionCount}문항</span>
|
<span className="shrink-0 text-xs whitespace-nowrap text-muted-foreground">{questionCount}문항</span>
|
||||||
<ChevronDown className={cn('size-4 shrink-0 transition-transform', opened && 'rotate-180')} />
|
<ChevronDown className={cn('size-4 shrink-0 transition-transform', opened && 'rotate-180')} />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user