260225_01_ENH: 실제 Data 통계 API와 연결 및 일부 페이지 축소
This commit is contained in:
@@ -15,10 +15,11 @@ import { GroupedOverlayBarData, ShowLabel} from "../types";
|
||||
import {getIsShowLabel, roundedRectIcon} from "@/components/lge-dashboard/chart/utill";
|
||||
import {AXIS_HIDE_STYLE} from "@/const/lgConst";
|
||||
import { CHART_HEIGHTS, LEGEND_ITEM_SIZE } from "@/const/chartConst";
|
||||
import {makeTotalBasePct} from "@/lib/lg-dashboard";
|
||||
|
||||
type Props = {
|
||||
data: GroupedOverlayBarData;
|
||||
height?: number;
|
||||
height?: number | string;
|
||||
|
||||
tooltip?: TooltipComponentOption;
|
||||
grid?: GridComponentOption;
|
||||
@@ -111,7 +112,7 @@ const GroupedOverlayBar = ({
|
||||
for (let yi = 0; yi < years.length; yi++) {
|
||||
const year = years[yi];
|
||||
const yearLabel = `${year}년`;
|
||||
const isOn = yearSelected[yearLabel] !== false;
|
||||
const isOn = yearSelected[yearLabel];
|
||||
|
||||
const totalRow = data.total?.[yi] ?? [];
|
||||
const focusRow = data.focus?.[yi] ?? [];
|
||||
@@ -227,8 +228,9 @@ const GroupedOverlayBar = ({
|
||||
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}`;
|
||||
const pct = makeTotalBasePct(t, f);
|
||||
const pctStr = pct > 0 ? ` (${pct}%)` : "";
|
||||
return `${totalName} ${t} 중 ${focusName} ${f}${pctStr}`;
|
||||
});
|
||||
|
||||
return [header, ...lines].join("<br/>");
|
||||
|
||||
@@ -14,11 +14,11 @@ import { GroupedStackBarData, ShowLabel} from "../types";
|
||||
import { buildLgPalette } from "@/components/lge-dashboard/color";
|
||||
import {getIsShowLabel, roundedRectIcon} from "@/components/lge-dashboard/chart/utill";
|
||||
import {AXIS_HIDE_STYLE} from "@/const/lgConst";
|
||||
import { CHART_HEIGHTS, LEGEND_ITEM_SIZE } from "@/const/chartConst";
|
||||
import { LEGEND_ITEM_SIZE } from "@/const/chartConst";
|
||||
|
||||
type Props = {
|
||||
data: GroupedStackBarData;
|
||||
height?: number;
|
||||
height?: number | string;
|
||||
|
||||
tooltip?: TooltipComponentOption;
|
||||
grid?: GridComponentOption;
|
||||
@@ -34,7 +34,7 @@ type Props = {
|
||||
|
||||
const GroupedStackBar = ({
|
||||
data,
|
||||
height = CHART_HEIGHTS.DEFAULT,
|
||||
height,
|
||||
tooltip,
|
||||
grid,
|
||||
xAxis,
|
||||
@@ -61,6 +61,7 @@ const GroupedStackBar = ({
|
||||
const defaultYAxis: EChartsOption["yAxis"] = { type: "value", ...AXIS_HIDE_STYLE };
|
||||
|
||||
const latestYear = years.at(-1);
|
||||
console.log(yearBrandPalette, String(latestYear), yearBrandPalette?.[String(latestYear)])
|
||||
const latestPalette = buildLgPalette(yearBrandPalette?.[String(latestYear)]);
|
||||
|
||||
const yearLegendTokens = years.map((y) => {
|
||||
@@ -111,7 +112,7 @@ const GroupedStackBar = ({
|
||||
const brand = brands[bi];
|
||||
const row = data.values?.[yi]?.[bi] ?? [];
|
||||
|
||||
const isYearOn = yearSelected[yearLabel] !== false;
|
||||
const isYearOn = yearSelected[yearLabel];
|
||||
const showLabel = getIsShowLabel(showFocusLabel, yi, years.length);
|
||||
|
||||
realSeries.push({
|
||||
|
||||
@@ -50,13 +50,11 @@ const StackBar = ({
|
||||
isReverse = false,
|
||||
}: Props) => {
|
||||
|
||||
// ✅ 렌더링용 데이터만 뒤집기
|
||||
const renderData = useMemo(
|
||||
() => (isReverse ? reverseSeries(data) : data),
|
||||
[data, isReverse]
|
||||
);
|
||||
|
||||
// ✅ 팔레트도 뒤집어줘야 "시리즈 이름별" 색이 유지됨
|
||||
const palette = useMemo(() => {
|
||||
const temp = buildLgPalette(paletteVarNames);
|
||||
const n = data.series.length; // 원본 기준
|
||||
@@ -67,7 +65,7 @@ const StackBar = ({
|
||||
const option: EChartsOption = useMemo(() => {
|
||||
const fmt = valueFormatter ?? ((v: number) => String(v));
|
||||
const isV = orientation === "vertical";
|
||||
console.log(isReverse)
|
||||
|
||||
return {
|
||||
color: palette,
|
||||
tooltip: tooltip ?? (isReverse ? createReverseTooltip(data, fmt) : createDefaultTooltip(fmt)),
|
||||
|
||||
Reference in New Issue
Block a user