260202_01_ENH: route 구조 초창기 기획으로 다시 변경 및 Category 별 하위 페이지에 샘플 데이터 모두 적용

This commit is contained in:
2026-02-02 11:32:50 +09:00
parent 4b40c43962
commit 6f8e09bcf3
60 changed files with 1750 additions and 464 deletions

View File

@@ -1,9 +1,10 @@
"use client";
import React, { useMemo } from "react";
import { cn } from "@/lib/utils";
import { cn, parseNumber } from "@/lib/utils";
import type { ChartData, SignStyle, TopChartTableRow } from "../types";
import SectionTitle from "../SectionTitle";
import { CHART_HEIGHTS, TABLE_DIMENSIONS } from "@/const/chartConst";
type BaseProps = {
title?: string;
@@ -49,17 +50,7 @@ type ChartDataModeProps = BaseProps & {
export type TopChartTableProps = HtmlModeProps | ChartDataModeProps;
function toNumber(v: unknown): number | null {
if (v === null || v === undefined) return null;
if (typeof v === "number") return Number.isFinite(v) ? v : null;
if (typeof v === "string") {
const s = v.trim();
if (s === "" || s === "-") return null;
const n = Number(s.replaceAll(",", ""));
return Number.isFinite(n) ? n : null;
}
return null;
}
// toNumber는 utils.ts의 parseNumber로 통합됨
function formatSignedNumber(n: number, zeroText: string, showPlus: boolean) {
if (n === 0) return zeroText;
@@ -78,8 +69,8 @@ export default function TopChartTable(props: TopChartTableProps) {
const {
title,
chart,
chartHeight = 260,
minWidthPx = 1600,
chartHeight = CHART_HEIGHTS.DEFAULT,
minWidthPx = TABLE_DIMENSIONS.MIN_WIDTH.STANDARD,
tableClassName,
wrapperClassName,
signStyle,
@@ -122,7 +113,7 @@ export default function TopChartTable(props: TopChartTableProps) {
categories,
series: rows.map((r) => ({
name: r.label,
data: r.values.map((v) => toNumber(v) ?? null),
data: r.values.map((v) => parseNumber(v) ?? null),
})),
}),
[categories, rows]
@@ -174,7 +165,7 @@ export default function TopChartTable(props: TopChartTableProps) {
{categories.map((_, ci) => {
const raw = r.values?.[ci];
const n = toNumber(raw);
const n = parseNumber(raw);
// 일반 행
if (!isSignRow) {