260202_03_ENH: 페이지 깜빡임 최소화 및 카테고리에서 전체로 이동 시 페이지 렌더링 2회 되는 부분 수정
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import {ChartData, DataColumn, DataTable, HorizontalBar, LeftChartTable, SignStyle} from "@/components/lge-dashboard";
|
||||
import {BannerKey, ServerBannerRow} from "@/types/lg";
|
||||
import {formatRowLabel, isSampleRow} from "@/lib/lg-dashboard";
|
||||
import {formatRowLabel, wrapSampleRow} from "@/lib/lg-dashboard";
|
||||
import {useMemo} from "react";
|
||||
import {BANNER_GROUP, BANNER_KEY_MAP, GRID_Y_NOT_PADDING} from "@/const/lgConst";
|
||||
import {formatNumber, parseNumber} from "@/lib/utils";
|
||||
import {parseNumber} from "@/lib/utils";
|
||||
|
||||
|
||||
type SectionSpec = {
|
||||
@@ -68,7 +68,6 @@ type BannerSummaryProps = {
|
||||
};
|
||||
|
||||
const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
|
||||
|
||||
const buildChartData = (rows: ServerBannerRow[], bannerKeys: BannerKey[]): ChartData => {
|
||||
const categories = rows
|
||||
.filter((r) => r.rowLabel !== "사례수")
|
||||
@@ -86,26 +85,7 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
|
||||
return { categories, series };
|
||||
};
|
||||
|
||||
const rows = useMemo<ServerBannerRow[]>(() => {
|
||||
const allKeys = Array.from(
|
||||
new Set(Object.values(BANNER_GROUP).flatMap((g) => g.keys))
|
||||
) as string[];
|
||||
|
||||
return data.map((r) => {
|
||||
const out: any = { ...r };
|
||||
|
||||
if (isSampleRow(r.rowLabel)) {
|
||||
// total
|
||||
out.total = `(${formatNumber(Number(r.total ?? 0))})`;
|
||||
// banner values
|
||||
allKeys.forEach((k) => {
|
||||
const v = (r as any)[k];
|
||||
if (typeof v === "number") out[k] = `(${formatNumber(v)})`;
|
||||
});
|
||||
}
|
||||
return out as ServerBannerRow;
|
||||
});
|
||||
}, [data]);
|
||||
const rows = useMemo<ServerBannerRow[]>(() => wrapSampleRow(data), [data]);
|
||||
|
||||
const signStyleGap: SignStyle<ServerBannerRow> = {
|
||||
rowSelector: (row) => row.rowLabel === "gap",
|
||||
|
||||
@@ -9,7 +9,12 @@ import BannerButtons from "@/components/lge-dashboard/BannerButtons";
|
||||
import {totalFilters} from "@/config/filter.data";
|
||||
import {useMemo, useState} from "react";
|
||||
import {BannerGroupKey, CategoryChartMode, ServerBannerRow} from "@/types/lg";
|
||||
import {buildRowLabelSeriesChartData, buildYearSeriesChartData, isBannerGroupKey} from "@/lib/lg-dashboard";
|
||||
import {
|
||||
buildRowLabelSeriesChartData,
|
||||
buildYearSeriesChartData,
|
||||
isBannerGroupKey,
|
||||
wrapSampleRow
|
||||
} from "@/lib/lg-dashboard";
|
||||
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR} from "@/const/lgConst";
|
||||
import {createDefaultGrid, createDefaultLegend, reverseCategories} from "@/lib/chart-options";
|
||||
|
||||
@@ -84,7 +89,8 @@ const CategoryByData = ({
|
||||
const v = selectedBanner.variable;
|
||||
return isBannerGroupKey(v) ? buildColumns(v) : [];
|
||||
}, [selectedBanner.variable]);
|
||||
const tableData = useMemo(() => allTableData.filter((row) => row.year === LAST_YEAR), [allTableData, LAST_YEAR])
|
||||
|
||||
const tableData = useMemo(() => wrapSampleRow(allTableData).filter((row) => row.year === LAST_YEAR), [allTableData, LAST_YEAR])
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user