260226_05_ENH: 카테고리 파트 옵션으로 ChartLegend, ChartTopMargin 추가
This commit is contained in:
@@ -65,7 +65,7 @@ const StackBar = ({
|
|||||||
const option: EChartsOption = useMemo(() => {
|
const option: EChartsOption = useMemo(() => {
|
||||||
const fmt = valueFormatter ?? ((v: number) => String(v));
|
const fmt = valueFormatter ?? ((v: number) => String(v));
|
||||||
const isV = orientation === "vertical";
|
const isV = orientation === "vertical";
|
||||||
|
console.log(grid)
|
||||||
return {
|
return {
|
||||||
color: palette,
|
color: palette,
|
||||||
tooltip: tooltip ?? (isReverse ? createReverseTooltip(data, fmt) : createDefaultTooltip(fmt)),
|
tooltip: tooltip ?? (isReverse ? createReverseTooltip(data, fmt) : createDefaultTooltip(fmt)),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
import BannerButtons from "@/components/lge-dashboard/BannerButtons";
|
import BannerButtons from "@/components/lge-dashboard/BannerButtons";
|
||||||
import {totalFilters} from "@/config/filter.data";
|
import {totalFilters} from "@/config/filter.data";
|
||||||
import React, {useMemo, useState} from "react";
|
import React, {useMemo, useState} from "react";
|
||||||
import {BannerGroupKey, CategoryChartMode, BannerRow} from "@/types/lg";
|
import {BannerGroupKey, CategoryChartMode, BannerRow, LegendOption} from "@/types/lg";
|
||||||
import {
|
import {
|
||||||
buildRowLabelSeriesChartData,
|
buildRowLabelSeriesChartData,
|
||||||
buildYearSeriesChartData, formatRowLabel,
|
buildYearSeriesChartData, formatRowLabel,
|
||||||
@@ -22,6 +22,8 @@ type CategoryByDataProps = {
|
|||||||
selectedYear: string;
|
selectedYear: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
chartMode: CategoryChartMode;
|
chartMode: CategoryChartMode;
|
||||||
|
chartLegend?: LegendOption;
|
||||||
|
chartTopMargin?: number;
|
||||||
allTableData: BannerRow[];
|
allTableData: BannerRow[];
|
||||||
fillGreaterThan5?: boolean;
|
fillGreaterThan5?: boolean;
|
||||||
chartHeight?: number | string;
|
chartHeight?: number | string;
|
||||||
@@ -44,6 +46,8 @@ const CategoryByData = ({
|
|||||||
selectedYear,
|
selectedYear,
|
||||||
title,
|
title,
|
||||||
chartMode,
|
chartMode,
|
||||||
|
chartLegend,
|
||||||
|
chartTopMargin,
|
||||||
allTableData,
|
allTableData,
|
||||||
fillGreaterThan5,
|
fillGreaterThan5,
|
||||||
chartHeight,
|
chartHeight,
|
||||||
@@ -102,6 +106,7 @@ const CategoryByData = ({
|
|||||||
})
|
})
|
||||||
, [allTableData, selectedYear]);
|
, [allTableData, selectedYear]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="mb-2 flex items-center pr-6">
|
<div className="mb-2 flex items-center pr-6">
|
||||||
@@ -110,11 +115,14 @@ const CategoryByData = ({
|
|||||||
<div className="flex gap-6 p-3">
|
<div className="flex gap-6 p-3">
|
||||||
<div className="flex-shrink-0" style={{ width: `${chartWidth ?? 400}px`}}>
|
<div className="flex-shrink-0" style={{ width: `${chartWidth ?? 400}px`}}>
|
||||||
{(() => {
|
{(() => {
|
||||||
|
console.log(chartTopMargin)
|
||||||
switch (chartMode) {
|
switch (chartMode) {
|
||||||
case "horizontal":
|
case "horizontal":
|
||||||
return (
|
return (
|
||||||
<HorizontalBar
|
<HorizontalBar
|
||||||
data={chartData}
|
data={chartData}
|
||||||
|
legend={chartLegend}
|
||||||
|
grid={chartTopMargin?createDefaultGrid("default", { top: chartTopMargin }):undefined}
|
||||||
height={chartHeight}
|
height={chartHeight}
|
||||||
showFocusLabel="none"
|
showFocusLabel="none"
|
||||||
paletteVarNames={
|
paletteVarNames={
|
||||||
@@ -127,8 +135,9 @@ const CategoryByData = ({
|
|||||||
return (
|
return (
|
||||||
<StackBar
|
<StackBar
|
||||||
data={chartData}
|
data={chartData}
|
||||||
|
legend={chartLegend}
|
||||||
height={chartHeight}
|
height={chartHeight}
|
||||||
grid={createDefaultGrid("default", { top: 52 })}
|
grid={createDefaultGrid("default", { top: chartTopMargin?chartTopMargin:52 })}
|
||||||
isReverse={chartMode === "reverseStack"}
|
isReverse={chartMode === "reverseStack"}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ const CategoryDetail = ({
|
|||||||
return {
|
return {
|
||||||
title: typeof f.title === "string"? f.title : f.title[debouncedFilterValue.type.value],
|
title: typeof f.title === "string"? f.title : f.title[debouncedFilterValue.type.value],
|
||||||
chartMode:f.chartMode,
|
chartMode:f.chartMode,
|
||||||
|
chartLegend:f.chartLegend,
|
||||||
|
chartTopMargin:f.chartTopMargin,
|
||||||
data: dataLength && dataLength > 0 ? dataMap[f.requestKeyResolved] : []
|
data: dataLength && dataLength > 0 ? dataMap[f.requestKeyResolved] : []
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -69,6 +71,8 @@ const CategoryDetail = ({
|
|||||||
selectedYear={filterValue.year}
|
selectedYear={filterValue.year}
|
||||||
title={tableData.title}
|
title={tableData.title}
|
||||||
chartMode={tableData.chartMode}
|
chartMode={tableData.chartMode}
|
||||||
|
chartLegend={tableData.chartLegend}
|
||||||
|
chartTopMargin={tableData.chartTopMargin}
|
||||||
allTableData={tableData.data}
|
allTableData={tableData.data}
|
||||||
chartHeight={tableData.chartHeight}
|
chartHeight={tableData.chartHeight}
|
||||||
chartWidth={tableData.chartWidth}
|
chartWidth={tableData.chartWidth}
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ export const CATEGORY_PAGE_FIELDS: Record<CategoryTargetData, CategoryFieldSpec[
|
|||||||
title: "브랜드",
|
title: "브랜드",
|
||||||
requestKey: "category_${keyBase}_brand",
|
requestKey: "category_${keyBase}_brand",
|
||||||
chartMode:"reverseStack",
|
chartMode:"reverseStack",
|
||||||
|
chartTopMargin: 80,
|
||||||
qidByMode: {
|
qidByMode: {
|
||||||
[CategoryTargetType.PENETRATION]: "KQA3_3",
|
[CategoryTargetType.PENETRATION]: "KQA3_3",
|
||||||
[CategoryTargetType.PURCHASE]: "KQX3_3",
|
[CategoryTargetType.PURCHASE]: "KQX3_3",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {BANNER_GROUP, BANNER_KEY_MAP, PRODUCT_KEY_MAP, PRODUCTS_FILTER_ITEM} from "@/const/lgConst";
|
import {BANNER_GROUP, BANNER_KEY_MAP, PRODUCT_KEY_MAP, PRODUCTS_FILTER_ITEM} from "@/const/lgConst";
|
||||||
import {CategoryTargetType} from "@/config/filter.types";
|
import {CategoryTargetType} from "@/config/filter.types";
|
||||||
|
import {EChartsOption} from "echarts";
|
||||||
|
|
||||||
export type ProductKey = keyof typeof PRODUCT_KEY_MAP;
|
export type ProductKey = keyof typeof PRODUCT_KEY_MAP;
|
||||||
export type BannerKey = keyof typeof BANNER_KEY_MAP;
|
export type BannerKey = keyof typeof BANNER_KEY_MAP;
|
||||||
@@ -77,15 +78,21 @@ export type CategoryChartMode = "none" | "stack" | "reverseStack" | "horizontal"
|
|||||||
export type PageData<T> = {
|
export type PageData<T> = {
|
||||||
title: string;
|
title: string;
|
||||||
chartMode: CategoryChartMode;
|
chartMode: CategoryChartMode;
|
||||||
data: T[];
|
chartLegend?: LegendOption;
|
||||||
|
chartTopMargin?:number;
|
||||||
chartHeight?: number | string;
|
chartHeight?: number | string;
|
||||||
chartWidth?: number;
|
chartWidth?: number;
|
||||||
|
data: T[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type LegendOption = EChartsOption["legend"];
|
||||||
|
|
||||||
export type CategoryFieldSpec = {
|
export type CategoryFieldSpec = {
|
||||||
title: string | Record<CategoryTargetType, string>;
|
title: string | Record<CategoryTargetType, string>;
|
||||||
requestKey: string;
|
requestKey: string;
|
||||||
chartMode:CategoryChartMode;
|
chartMode:CategoryChartMode;
|
||||||
|
chartLegend?: LegendOption;
|
||||||
|
chartTopMargin?:number;
|
||||||
qidByMode: Partial<Record<CategoryTargetType, string>>; // mode별 qid (없으면 숨김/요청 제외)
|
qidByMode: Partial<Record<CategoryTargetType, string>>; // mode별 qid (없으면 숨김/요청 제외)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user