260205_05_ENH: 1차 lg 수정 요청사항 반영
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
BANNER_GROUP,
|
||||
BANNER_KEY_MAP,
|
||||
GRID_Y_NOT_PADDING,
|
||||
LAST_YEAR,
|
||||
SAMPLE_SIZE_NOTICE, SITE_TITLE,
|
||||
} from "@/const/lgConst";
|
||||
import {parseNumber} from "@/lib/utils";
|
||||
import {
|
||||
@@ -36,11 +36,11 @@ const SEP_R = "lg-table__sep-r";
|
||||
const getSectionBannerKeys = (spec: SectionSpec): BannerKey[] =>
|
||||
spec.groupKeys.flatMap((gk) => BANNER_GROUP[gk].keys);
|
||||
|
||||
const buildColumns = (spec: SectionSpec): DataColumn<ServerBannerRow>[] => {
|
||||
const buildColumns = (spec: SectionSpec, selectedYear:string): DataColumn<ServerBannerRow>[] => {
|
||||
const columns: DataColumn<ServerBannerRow>[] = [
|
||||
{
|
||||
key: "rowLabel",
|
||||
header: "",
|
||||
header: `20${selectedYear}년`,
|
||||
headRowSpan: 2,
|
||||
rowHead: true,
|
||||
cellClassName: "lg-table__rowhead",
|
||||
@@ -79,9 +79,10 @@ const buildColumns = (spec: SectionSpec): DataColumn<ServerBannerRow>[] => {
|
||||
type BannerSummaryProps = {
|
||||
data: ServerBannerRow[];
|
||||
useChart: boolean;
|
||||
useYear: boolean;
|
||||
};
|
||||
|
||||
const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
|
||||
const BannerSummary = ({ data, useChart, useYear }: BannerSummaryProps) => {
|
||||
const {filterValue, registerExcelExporter } = useLayoutFilter();
|
||||
|
||||
const buildChartData = (rows: ServerBannerRow[], bannerKeys: BannerKey[]): ChartData => {
|
||||
@@ -117,10 +118,10 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
|
||||
const specTitle = spec.title;
|
||||
|
||||
const bannerKeys = getSectionBannerKeys(spec);
|
||||
const columns = buildColumns(spec);
|
||||
const columns = buildColumns(spec, useYear? filterValue.year : "");
|
||||
|
||||
// rows가 spec마다 다르면 여기서 가져오도록 구성
|
||||
const rows = wrapSampleRow(data);
|
||||
const rows = wrapSampleRow(useYear? data.filter((d) => d.year === filterValue.year) : data);
|
||||
const chartData = buildChartData(rows, bannerKeys);
|
||||
|
||||
return {
|
||||
@@ -132,7 +133,7 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
|
||||
chartData,
|
||||
};
|
||||
});
|
||||
}, [data]);
|
||||
}, [data, useYear, filterValue.year]);
|
||||
|
||||
useEffect(() => {
|
||||
registerExcelExporter(async (payload) => {
|
||||
@@ -150,7 +151,7 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
|
||||
;
|
||||
|
||||
await exportDashboardExcel({
|
||||
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
|
||||
fileName: `${SITE_TITLE}(${sheetName}).xlsx`,
|
||||
sheetName: sheetName,
|
||||
sections: sections,
|
||||
});
|
||||
@@ -162,35 +163,42 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => {
|
||||
<div className="flex flex-col gap-6">
|
||||
{sectionRows.map((sectionRow) => {
|
||||
return (
|
||||
useChart ?
|
||||
<LeftChartTable<ServerBannerRow>
|
||||
key={sectionRow.specTitle}
|
||||
title={sectionRow.specTitle}
|
||||
columns={sectionRow.columns}
|
||||
rows={sectionRow.rows}
|
||||
signStyle={signStyleGap}
|
||||
chart={
|
||||
<HorizontalBar
|
||||
data={sectionRow.chartData}
|
||||
height="100%"
|
||||
showFocusLabel="none"
|
||||
legend={{ show: false }}
|
||||
grid={GRID_Y_NOT_PADDING}
|
||||
xAxis={{ type: "value", show: false }}
|
||||
yAxis={{ type: "category", data: sectionRow.chartData.categories, show: false }}
|
||||
/>
|
||||
}
|
||||
chartCell={{ key: "total", startRowIndex: 1 }}
|
||||
minWidthPx={1200}
|
||||
/>
|
||||
:
|
||||
<DataTable<ServerBannerRow>
|
||||
key={sectionRow.specTitle}
|
||||
title={sectionRow.specTitle}
|
||||
columns={sectionRow.columns}
|
||||
rows={sectionRow.rows}
|
||||
signStyle={signStyleGap}
|
||||
/>
|
||||
<div key={`div_${sectionRow.specTitle}`}>
|
||||
{
|
||||
useChart ?
|
||||
<LeftChartTable<ServerBannerRow>
|
||||
key={sectionRow.specTitle}
|
||||
title={sectionRow.specTitle}
|
||||
columns={sectionRow.columns}
|
||||
rows={sectionRow.rows}
|
||||
signStyle={signStyleGap}
|
||||
chart={
|
||||
<HorizontalBar
|
||||
data={sectionRow.chartData}
|
||||
height="100%"
|
||||
showFocusLabel="none"
|
||||
legend={{ show: false }}
|
||||
grid={GRID_Y_NOT_PADDING}
|
||||
xAxis={{ type: "value", show: false }}
|
||||
yAxis={{ type: "category", data: sectionRow.chartData.categories, show: false }}
|
||||
/>
|
||||
}
|
||||
chartCell={{ key: "total", startRowIndex: 1 }}
|
||||
minWidthPx={1200}
|
||||
starUnder30Sample={true}
|
||||
/>
|
||||
:
|
||||
<DataTable<ServerBannerRow>
|
||||
key={sectionRow.specTitle}
|
||||
title={sectionRow.specTitle}
|
||||
columns={sectionRow.columns}
|
||||
rows={sectionRow.rows}
|
||||
signStyle={signStyleGap}
|
||||
starUnder30Sample={true}
|
||||
/>
|
||||
}
|
||||
<div className="float-right content-text-sm">{SAMPLE_SIZE_NOTICE}</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user