'use client'; import { Bar, BarChart, CartesianGrid, Cell, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; import { TodayChartFrame } from '@/components/today/TodayChartFrame'; import type { TodayChartBucket } from '@/types/today'; import { chartRankColor, TODAY_CHART_AXIS_COLOR, TODAY_CHART_GRID_COLOR, TODAY_CHART_TOOLTIP_STYLE, } from '@/components/today/chart-theme'; interface TodayHorizontalBarChartProps { data: TodayChartBucket[]; } export function TodayHorizontalBarChart({ data }: TodayHorizontalBarChartProps) { const chartData = data.map((item) => ({ ...item, shortLabel: truncateLabel(item.label, 18), })); return ( { const row = payload?.[0]?.payload as TodayChartBucket | undefined; return row?.label ?? ''; }} /> {chartData.map((entry, index) => ( ))} ); } function truncateLabel(label: string, max = 18): string { if (label.length <= max) return label; return `${label.slice(0, max - 1)}…`; }