'use client';
import {
LineChart as RechartsLineChart,
Line,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
ResponsiveContainer,
Legend,
} from 'recharts';
import { ChartContainer, ChartEmptyState } from './chart-container';
interface LineChartDataPoint {
name: string;
[key: string]: string | number;
}
interface LineChartSeries {
dataKey: string;
name: string;
color: string;
strokeWidth?: number;
dot?: boolean;
dashed?: boolean;
}
interface LineChartProps {
/** Chart title */
title: string;
/** Optional description */
description?: string;
/** Data points to display */
data: LineChartDataPoint[];
/** Series configuration */
series: LineChartSeries[];
/** Whether data is loading */
isLoading?: boolean;
/** Chart height */
height?: number;
/** Whether to show grid lines */
showGrid?: boolean;
/** Whether to show legend */
showLegend?: boolean;
/** Whether to use curved lines */
curved?: boolean;
/** Additional CSS classes */
className?: string;
}
/**
* Line Chart component using Recharts
* Supports single or multiple series with various styling options
*/
export function LineChart({
title,
description,
data,
series,
isLoading = false,
height = 300,
showGrid = true,
showLegend = true,
curved = true,
className,
}: LineChartProps) {
if (!isLoading && data.length === 0) {
return (
);
}
return (
{showGrid && (
)}
{showLegend && }
{series.map((s) => (
))}
);
}