260127_01_ENH: 커스텀 컴포넌트들 1차 완성 및 일부페이지에 SampleData 적용

This commit is contained in:
2026-01-27 16:59:24 +09:00
parent 76c2626507
commit 8bfa8fa7c4
33 changed files with 3035 additions and 35 deletions

View File

@@ -0,0 +1,282 @@
"use client";
import React, { useMemo, useState } from "react";
import type {
GridComponentOption,
LegendComponentOption,
TooltipComponentOption,
XAXisComponentOption,
YAXisComponentOption,
SeriesOption, EChartsOption,
} from "echarts";
import BaseEChart from "../BaseEChart";
import { buildLgPalette } from "../color";
import {AXIS_HIDE_STYLE, GroupedOverlayBarData, ShowLabel} from "../types";
import {getIsShowLabel, roundedRectIcon} from "@/components/lge-dashboard/chart/utill";
type Props = {
data: GroupedOverlayBarData;
height?: number;
tooltip?: TooltipComponentOption;
grid?: GridComponentOption;
xAxis?: XAXisComponentOption;
yAxis?: YAXisComponentOption;
legend?: LegendComponentOption;
barMaxWidth?: number;
showFocusLabel?: ShowLabel;
// 연도 legend(좌측)
showYearLegend?: boolean;
yearTotalColor?: Record<string, string>;
yearFocusColor?: Record<string, string>;
};
const GroupedOverlayBar = ({
data,
height = 260,
tooltip,
grid,
xAxis,
yAxis,
showYearLegend = true,
legend,
yearTotalColor,
yearFocusColor,
barMaxWidth,
showFocusLabel = "all",
}: Props) => {
const years = data.years;
const totalName = data.totalName ?? "전체";
const focusName = data.focusName ?? "LG";
const yearLabels = useMemo(() => years.map((y) => `${y}년`), [years]);
const [yearSelected, setYearSelected] = useState<Record<string, boolean>>(() =>
Object.fromEntries(yearLabels.map((yl) => [yl, true]))
);
const option = useMemo(() => {
const defaultGrid: EChartsOption["grid"] = {left: 10, right: 10, top: 40, bottom: 10, containLabel: true};
const defaultYAxis: EChartsOption["yAxis"] = { type: "value", ...AXIS_HIDE_STYLE };
const expandedCategories: string[] = [];
data.categories.forEach((cat, catIdx) => {
years.forEach(year => {
expandedCategories.push(`${year}년 ${cat}`);
});
// 카테고리 사이에 빈 공간 추가 (마지막 제외)
if (catIdx < data.categories.length - 1) {
expandedCategories.push(''); // 빈 항목
}
});
const defaultXAxis: EChartsOption["xAxis"] = {
type: "category",
data: expandedCategories,
...AXIS_HIDE_STYLE
};
// 연도별 색: 없으면 기본값(전체=회색, LG=빨강 계열)
const totalTokens = years.map((y, i) => {
const t = yearTotalColor?.[String(y)];
return t ?? (["--lg-gray-200", "--lg-gray-300", "--lg-gray-400", "--lg-gray-500"][i] ?? "--lg-gray-300");
});
const focusTokens = years.map((y, i) => {
const t = yearFocusColor?.[String(y)];
return t ?? (["--lg-red-300", "--lg-red-400", "--lg-red-500", "--lg-red-600"][i] ?? "--lg-red-500");
});
const totalColors = buildLgPalette(totalTokens);
const focusColors = buildLgPalette(focusTokens);
// 연도 legend가 실제로 렌더되려면 "name=24년" series가 있어야 함 (bar가 아닌 line으로)
const yearLegendSeries: SeriesOption[] = showYearLegend
? years.map((y, yi) => ({
id: `__year__|${y}`,
name: `${y}년`,
type: "line",
data: [],
showSymbol: false,
silent: true,
tooltip: { show: false },
emphasis: { disabled: true },
lineStyle: { color: focusColors[yi], width: 6 },
itemStyle: { color: focusColors[yi] },
}))
: [];
const series: SeriesOption[] = [];
for (let yi = 0; yi < years.length; yi++) {
const year = years[yi];
const yearLabel = `${year}년`;
const isOn = yearSelected[yearLabel] !== false;
const totalRow = data.total?.[yi] ?? [];
const focusRow = data.focus?.[yi] ?? [];
// 각 카테고리별로 데이터 배치
const totalData: (number | null)[] = [];
const focusData: (number | null)[] = [];
data.categories.forEach((cat, ci) => {
years.forEach((y, yIdx) => {
if (yIdx === yi) {
totalData.push(isOn ? (totalRow[ci] ?? null) : null);
focusData.push(isOn ? (focusRow[ci] ?? null) : null);
} else {
totalData.push(null);
focusData.push(null);
}
});
// 카테고리 사이에 null 추가 (마지막 제외)
if (ci < data.categories.length - 1) {
totalData.push(null);
focusData.push(null);
}
});
// (1) 전체(회색)
series.push({
id: `total|${year}`,
name: `${year}년-${totalName}`,
type: "bar",
z: 1,
barMaxWidth: 42,
emphasis: { disabled: true },
itemStyle: { color: totalColors[yi] },
data: totalData,
});
const showLabel = getIsShowLabel(showFocusLabel, yi, years.length);
// (2) LG(빨강) - 같은 위치에 겹침
series.push({
id: `focus|${year}`,
name: `${year}년-${focusName}`,
type: "bar",
z: 2,
barMaxWidth: 42,
barGap: "-100%",
emphasis: { disabled: true },
itemStyle: { color: focusColors[yi] },
label: showLabel
? ({
show: true,
position: "top",
formatter: (p: any) => (p?.value ?? "") as any,
} as any)
: undefined,
data: focusData,
});
}
const YEAR_ITEM_W = 25;
const YEAR_ITEM_H = 14;
const YEAR_RADIUS = 4;
let yearLegendOpt: LegendComponentOption | undefined = showYearLegend
? ({
top: 0,
left: "center",
orient: "horizontal",
data: yearLabels,
selected: yearSelected,
icon: roundedRectIcon(YEAR_ITEM_W, YEAR_ITEM_H, YEAR_RADIUS),
itemWidth: YEAR_ITEM_W,
itemHeight: YEAR_ITEM_H,
itemGap: 8,
...legend,
} as LegendComponentOption)
: undefined;
if(yearLegendOpt === undefined && legend !== undefined){
yearLegendOpt = legend;
}
return {
tooltip:
tooltip ??
({
trigger: "axis",
axisPointer: { type: "shadow" },
formatter: (params: any) => {
const arr = Array.isArray(params) ? params : [params];
const header = arr?.[0]?.axisValueLabel ?? "";
// bar만
const barItems = arr
.filter((p: any) => p?.seriesType === "bar")
.filter((p: any) => p?.value !== null && p?.value !== undefined);
// year -> {total, focus}
const map = new Map<number, { total?: number; focus?: number }>();
for (const p of barItems) {
const sid = String(p.seriesId ?? ""); // total|24, focus|24
const [kind, yStr] = sid.split("|");
const y = Number(yStr);
const e = map.get(y) ?? {};
if (kind === "total") e.total = Number(p.value);
if (kind === "focus") e.focus = Number(p.value);
map.set(y, e);
}
const lines = [...map.keys()]
.sort((a, b) => a - b)
.map((y) => {
const v = map.get(y)!;
const t = v.total ?? 0;
const f = v.focus ?? 0;
const pct = t > 0 ? ` (${Math.round((f / t) * 100)}%)` : "";
return `${totalName} ${t} 중 ${focusName} ${f}${pct}`;
});
return [header, ...lines].join("<br/>");
},
} as TooltipComponentOption),
legend: yearLegendOpt ?? undefined,
grid: grid ?? defaultGrid,
xAxis: xAxis ?? defaultXAxis,
yAxis: yAxis ?? defaultYAxis,
series: [...yearLegendSeries, ...series],
};
}, [
years,
data.categories,
data.total,
data.focus,
totalName,
focusName,
tooltip,
grid,
xAxis,
yAxis,
showYearLegend,
legend,
yearTotalColor,
yearFocusColor,
barMaxWidth,
showFocusLabel,
yearLabels,
yearSelected,
]);
const onEvents = useMemo(
() => ({
legendselectchanged: (e: any) => {
const name = String(e?.name ?? "");
if (!yearLabels.includes(name)) return;
const selected = e?.selected as Record<string, boolean>;
setYearSelected((prev) => ({
...prev,
[name]: selected?.[name] ?? true,
}));
},
}),
[yearLabels]
);
return <BaseEChart option={option} height={height} onEvents={onEvents} />;
}
export default GroupedOverlayBar;

View File

@@ -0,0 +1,259 @@
"use client";
import React, { useMemo, useState } from "react";
import type {
GridComponentOption,
LegendComponentOption,
TooltipComponentOption,
XAXisComponentOption,
YAXisComponentOption,
SeriesOption, EChartsOption,
} from "echarts";
import BaseEChart from "../BaseEChart";
import {AXIS_HIDE_STYLE, GroupedStackBarData, ShowLabel} from "../types";
import { buildLgPalette } from "@/components/lge-dashboard/color";
import {getIsShowLabel, roundedRectIcon} from "@/components/lge-dashboard/chart/utill";
type Props = {
data: GroupedStackBarData;
height?: number;
tooltip?: TooltipComponentOption;
grid?: GridComponentOption;
xAxis?: XAXisComponentOption;
yAxis?: YAXisComponentOption;
legend?: LegendComponentOption;
barMaxWidth?: number;
showFocusLabel?: ShowLabel;
showYearLegend?: boolean;
yearBrandPalette?: Record<string, string[]>;
};
const GroupedStackBar = ({
data,
height = 260,
tooltip,
grid,
xAxis,
yAxis,
legend,
barMaxWidth,
showFocusLabel = "all",
showYearLegend = true,
yearBrandPalette,
}: Props) => {
const years = data.years;
const brands = data.brands;
const yearLabels = useMemo(() => years.map((y) => `${y}년`), [years]);
const [yearSelected, setYearSelected] = useState<Record<string, boolean>>(() =>
Object.fromEntries(yearLabels.map((yl) => [yl, true]))
);
const option = useMemo(() => {
const defaultGrid: EChartsOption["grid"] = {left: 10, right: 10, top: 60, bottom: 10, containLabel: true};
const defaultXAxis: EChartsOption["xAxis"] = { type: "category", data: data.categories, ...AXIS_HIDE_STYLE };
const defaultYAxis: EChartsOption["yAxis"] = { type: "value", ...AXIS_HIDE_STYLE };
const latestYear = years.at(-1);
const latestPalette = buildLgPalette(yearBrandPalette?.[String(latestYear)]);
const yearLegendTokens = years.map((y) => {
const tokens = yearBrandPalette?.[String(y)];
const last = tokens?.[tokens.length - 1];
return last ?? "--lg-gray-500";
});
const yearLegendColors = buildLgPalette(yearLegendTokens);
const yearLegendSeries: SeriesOption[] = showYearLegend
? years.map((y, yi) => ({
id: `__year__|${y}`,
name: `${y}년`,
type: "line",
data: [], // 렌더링 없음(legend만)
showSymbol: false,
silent: true,
tooltip: { show: false },
emphasis: { disabled: true },
lineStyle: { color: yearLegendColors[yi], width: 6 },
itemStyle: { color: yearLegendColors[yi] },
}))
: [];
const brandLegendSeries: SeriesOption[] = brands.map((brand, bi) => ({
id: `__legend__|${brand}`,
name: brand,
type: "line",
data: [], // 렌더링 없음(legend만)
showSymbol: false,
silent: true,
tooltip: { show: false },
emphasis: { disabled: true },
lineStyle: { color: latestPalette[bi], width: 6 },
itemStyle: { color: latestPalette[bi] },
}));
// 2) 실제 bar series (연도 스택 3개) × (브랜드 N개)
const realSeries: SeriesOption[] = [];
for (let yi = 0; yi < years.length; yi++) {
const year = years[yi];
const yearLabel = `${year}년`;
const palette = buildLgPalette(yearBrandPalette?.[String(year)]);
for (let bi = 0; bi < brands.length; bi++) {
const brand = brands[bi];
const row = data.values?.[yi]?.[bi] ?? [];
const isYearOn = yearSelected[yearLabel] !== false;
const showLabel = getIsShowLabel(showFocusLabel, yi, years.length);
realSeries.push({
id: `${year}|${brand}`,
name: brand,
type: "bar",
stack: `Y${year}`,
emphasis: { disabled: true },
barMaxWidth: barMaxWidth ?? 42,
itemStyle: { color: palette?.[bi] },
label: showLabel
? ({
show: true,
position: "top",
formatter: (p: any) => (p?.value ?? "") as any,
} as any)
: undefined,
data: data.categories.map((_, ci) => (isYearOn ? (row[ci] ?? null) : null)),
});
}
}
const YEAR_ITEM_W = 25;
const YEAR_ITEM_H = 14;
const YEAR_RADIUS = 4;
// 3) legend 2개: (좌)연도, (우)브랜드
let yearLegendOpt: LegendComponentOption | undefined = showYearLegend
? ({
top: 0,
left: "center",
orient: "horizontal",
data: yearLabels, // yearLegendSeries name과 일치
selected: yearSelected,
icon: roundedRectIcon(YEAR_ITEM_W, YEAR_ITEM_H, YEAR_RADIUS),
itemWidth: YEAR_ITEM_W,
itemHeight: YEAR_ITEM_H,
itemGap: 8,
...legend,
} as LegendComponentOption)
: undefined;
if(yearLegendOpt === undefined && legend !== undefined){
yearLegendOpt = legend;
}
const brandLegendOpt: LegendComponentOption = ({
top: 25,
right: "center",
orient: "horizontal",
data: brands,
icon: roundedRectIcon(YEAR_ITEM_W, YEAR_ITEM_H, YEAR_RADIUS),
itemWidth: YEAR_ITEM_W,
itemHeight: YEAR_ITEM_H,
itemGap: 8,
...legend,
} as LegendComponentOption);
const legends = yearLegendOpt ? [yearLegendOpt, brandLegendOpt] : brandLegendOpt;
return {
tooltip:
tooltip ??
({
trigger: "axis",
axisPointer: { type: "shadow" },
formatter: (params: any) => {
const arr = Array.isArray(params) ? params : [params];
const header = arr?.[0]?.axisValueLabel ?? "";
const yearMap = new Map<number, Array<{ brand: string; value: number }>>();
// bar series만 + 값 있는 것만
const barItems = arr
.filter((p: any) => p?.seriesType === "bar")
.filter((p: any) => p?.value !== null && p?.value !== undefined);
barItems.forEach((p: any) => {
const sid = String(p.seriesId ?? "");
const [y, brand] = sid.split("|");
const year = Number(y);
if (!yearMap.has(year)) {
yearMap.set(year, []);
}
yearMap.get(year)!.push({ brand, value: p.value });
});
const lines = Array.from(yearMap.entries())
.sort((a, b) => a[0] - b[0])
.map(([year, brands]) => {
const brandTexts = brands
.toReversed() // 브랜드 역순
.map(item => `${item.brand}: ${item.value}`)
.join(", ");
return `${year}년- ${brandTexts}`;
});
return [header, ...lines].join("<br/>");
},
} as TooltipComponentOption),
legend: legends,
grid: grid ?? defaultGrid,
xAxis: xAxis ?? defaultXAxis,
yAxis: yAxis ?? defaultYAxis,
series: [...yearLegendSeries, ...brandLegendSeries, ...realSeries],
};
}, [
years,
brands,
data.categories,
data.values,
tooltip,
grid,
xAxis,
yAxis,
legend,
showFocusLabel,
showYearLegend,
yearBrandPalette,
yearLabels,
yearSelected,
barMaxWidth,
]);
// 연도 legend 토글 이벤트만 가로채서 yearSelected에 반영
const onEvents = useMemo(
() => ({
legendselectchanged: (e: any) => {
const name = String(e?.name ?? "");
if (!yearLabels.includes(name)) return; // 브랜드 토글은 ECharts 기본 동작 사용
const selected = e?.selected as Record<string, boolean>;
setYearSelected((prev) => ({
...prev,
[name]: selected?.[name] ?? true,
}));
},
}),
[yearLabels]
);
return <BaseEChart option={option} height={height} onEvents={onEvents} />;
};
export default GroupedStackBar;

View File

@@ -0,0 +1,86 @@
"use client";
import { useMemo } from "react";
import type { EChartsOption } from "echarts";
import BaseEChart from "../BaseEChart";
import {ChartData, ShowLabel, ValueFormatter} from "../types";
import { buildLgPalette } from "../color";
import {getIsShowLabel} from "@/components/lge-dashboard/chart/utill";
type Props = {
data: ChartData;
height?: number | string;
className?: string;
paletteVarNames?: string[];
valueFormatter?: ValueFormatter;
tooltip?: EChartsOption["tooltip"];
legend?: EChartsOption["legend"];
grid?: EChartsOption["grid"];
xAxis?: EChartsOption["xAxis"];
yAxis?: EChartsOption["yAxis"];
barMaxWidth?: number;
showFocusLabel?:ShowLabel;
};
const HorizontalBar = ({
data,
height,
className,
paletteVarNames,
valueFormatter,
tooltip,
legend,
grid,
xAxis,
yAxis,
barMaxWidth,
showFocusLabel = "all",
}: Props) => {
const palette = useMemo(() => buildLgPalette(paletteVarNames), [paletteVarNames]);
const option: EChartsOption = useMemo(() => {
const fmt = valueFormatter ?? ((v: number) => String(v));
const defaultTooltip: EChartsOption["tooltip"] = {
trigger: "axis",
axisPointer: { type: "shadow" },
valueFormatter: (v: unknown) => (typeof v === "number" ? fmt(v) : String(v)),
};
const defaultLegend: EChartsOption["legend"] = { top: 0 };
const defaultGrid: EChartsOption["grid"] = { left: 16, right: 16, top: 36, bottom: 12, containLabel: true };
const defaultXAxis: EChartsOption["xAxis"] = { type: "value" };
const defaultYAxis: EChartsOption["yAxis"] = { type: "category", data: data.categories };
return {
color: palette,
tooltip: tooltip ?? defaultTooltip,
legend: legend ?? defaultLegend,
grid: grid ?? defaultGrid,
xAxis: xAxis ?? defaultXAxis,
yAxis: yAxis ?? defaultYAxis,
series: data.series.map((s, index) => {
const showLabel = getIsShowLabel(showFocusLabel, index, data.series.length);
return {
name: s.name,
type: "bar",
data: s.data,
emphasis: { disabled: true },
barMaxWidth: barMaxWidth ?? 42,
label: showLabel
? {
show: true,
position: "right",
formatter: (p: any) => (p?.value ?? "") as any,
}
: undefined,
};
}),
};
}, [data, palette, valueFormatter, tooltip, legend, grid, xAxis, yAxis, barMaxWidth, showFocusLabel]);
return <BaseEChart option={option} height={height} className={className} />;
}
export default HorizontalBar;

View File

@@ -0,0 +1,78 @@
"use client";
import { useMemo } from "react";
import type { EChartsOption } from "echarts";
import BaseEChart from "../BaseEChart";
import type { ChartData, ValueFormatter } from "../types";
import { buildLgPalette } from "../color";
type Props = {
data: ChartData;
height?: number | string;
className?: string;
paletteVarNames?: string[];
valueFormatter?: ValueFormatter;
orientation?: "vertical" | "horizontal";
/** series.stack이 없을 때 기본 stack key */
defaultStackKey?: string;
tooltip?: EChartsOption["tooltip"];
legend?: EChartsOption["legend"];
grid?: EChartsOption["grid"];
xAxis?: EChartsOption["xAxis"];
yAxis?: EChartsOption["yAxis"];
barMaxWidth?: number;
};
const StackBar = ({
data,
height,
className,
paletteVarNames,
valueFormatter,
orientation = "vertical",
defaultStackKey = "total",
tooltip,
legend,
grid,
xAxis,
yAxis,
barMaxWidth,
}: Props) => {
const palette = useMemo(() => buildLgPalette(paletteVarNames), [paletteVarNames]);
const option: EChartsOption = useMemo(() => {
const fmt = valueFormatter ?? ((v: number) => String(v));
const isV = orientation === "vertical";
const defaultTooltip: EChartsOption["tooltip"] = {
trigger: "axis",
axisPointer: { type: "shadow" },
valueFormatter: (v: unknown) => (typeof v === "number" ? fmt(v) : String(v)),
};
const defaultLegend: EChartsOption["legend"] = { top: 0 };
const defaultGrid: EChartsOption["grid"] = { left: 16, right: 16, top: 36, bottom: 12, containLabel: true };
const defaultXAxis: EChartsOption["xAxis"] = isV ? { type: "category", data: data.categories } : { type: "value" };
const defaultYAxis: EChartsOption["yAxis"] = isV ? { type: "value" } : { type: "category", data: data.categories };
return {
color: palette,
tooltip: tooltip ?? defaultTooltip,
legend: legend ?? defaultLegend,
grid: grid ?? defaultGrid,
xAxis: xAxis ?? defaultXAxis,
yAxis: yAxis ?? defaultYAxis,
series: data.series.map((s) => ({
name: s.name,
type: "bar",
stack: s.stack ?? defaultStackKey,
data: s.data,
emphasis: { disabled: true },
barMaxWidth: barMaxWidth ?? 42,
})),
};
}, [data, palette, valueFormatter, orientation, defaultStackKey, tooltip, legend, grid, xAxis, yAxis, barMaxWidth]);
return <BaseEChart option={option} height={height} className={className} />;
}
export default StackBar;

View File

@@ -0,0 +1,87 @@
"use client";
import { useMemo } from "react";
import type { EChartsOption } from "echarts";
import BaseEChart from "../BaseEChart";
import {ChartData, ShowLabel, ValueFormatter} from "../types";
import { buildLgPalette } from "../color";
import {getIsShowLabel} from "@/components/lge-dashboard/chart/utill";
type Props = {
data: ChartData;
height?: number | string;
className?: string;
paletteVarNames?: string[];
valueFormatter?: ValueFormatter;
tooltip?: EChartsOption["tooltip"];
legend?: EChartsOption["legend"];
grid?: EChartsOption["grid"];
xAxis?: EChartsOption["xAxis"];
yAxis?: EChartsOption["yAxis"];
barMaxWidth?: number;
showFocusLabel?:ShowLabel;
};
const VerticalBar = ({
data,
height,
className,
paletteVarNames,
valueFormatter,
tooltip,
legend,
grid,
xAxis,
yAxis,
barMaxWidth,
showFocusLabel = "all",
}: Props) => {
const palette = useMemo(() => buildLgPalette(paletteVarNames), [paletteVarNames]);
const option: EChartsOption = useMemo(() => {
const fmt = valueFormatter ?? ((v: number) => String(v));
const defaultTooltip: EChartsOption["tooltip"] = {
trigger: "axis",
axisPointer: { type: "shadow" },
valueFormatter: (v: unknown) => (typeof v === "number" ? fmt(v) : String(v)),
};
const defaultLegend: EChartsOption["legend"] = { top: 0 };
const defaultGrid: EChartsOption["grid"] = { left: 16, right: 16, top: 36, bottom: 12, containLabel: true };
const defaultXAxis: EChartsOption["xAxis"] = { type: "category", data: data.categories, axisTick: { alignWithLabel: true } };
const defaultYAxis: EChartsOption["yAxis"] = { type: "value" };
return {
color: palette,
tooltip: tooltip ?? defaultTooltip,
legend: legend ?? defaultLegend,
grid: grid ?? defaultGrid,
xAxis: xAxis ?? defaultXAxis,
yAxis: yAxis ?? defaultYAxis,
series: data.series.map((s, index) => {
const showLabel = getIsShowLabel(showFocusLabel, index, data.series.length);
return {
name: s.name,
type: "bar",
data: s.data,
emphasis: { disabled: true },
barMaxWidth: barMaxWidth ?? 42,
label: showLabel
? {
show: true,
position: "top",
formatter: (p: any) => (p?.value ?? "") as any,
}
: undefined,
}
}),
};
}, [data, palette, valueFormatter, tooltip, legend, grid, xAxis, yAxis, barMaxWidth, showFocusLabel]);
return <BaseEChart option={option} height={height} className={className} />;
}
export default VerticalBar;

View File

@@ -0,0 +1,21 @@
import {ShowLabel} from "@/components/lge-dashboard";
export const roundedRectIcon = (w: number, h: number, r: number) => {
const rr = Math.max(0, Math.min(r, Math.min(w, h) / 2));
// ECharts legend icon은 'path://' 지원
return `path://M${rr},0 H${w - rr} Q${w},0 ${w},${rr} V${h - rr} Q${w},${h} ${w - rr},${h} H${rr} Q0,${h} 0,${h - rr} V${rr} Q0,0 ${rr},0 Z`;
};
export const getIsShowLabel = (showFocusLabel:ShowLabel, i:number, arrayLength: number ):boolean => {
let isShowLabel = false;
if (showFocusLabel === "all") {
isShowLabel = true;
} else if (showFocusLabel === "last") {
isShowLabel = i === arrayLength - 1;
} else if (showFocusLabel === "first") {
isShowLabel = i === 0;
}
return isShowLabel;
}