"use client"; import { memo } from "react"; import { Area, AreaChart, CartesianGrid, YAxis, Tooltip, ResponsiveContainer, } from "recharts"; import { cls, shouldUseInvertedText } from "@/lib/utils"; import { useTheme } from "@/providers/themeProvider/ThemeProvider"; import { formatNumber, calculateYAxisWidth, type ChartDataItem } from "./utils"; import CustomTooltip from "./CustomTooltip"; import type { InvertedBackground } from "@/providers/themeProvider/config/constants"; interface BentoLineChartProps { data?: ChartDataItem[]; dataKey?: string; metricLabel?: string; isPercentage?: boolean; useInvertedBackground: InvertedBackground; className?: string; } const defaultData: ChartDataItem[] = [ { value: 120 }, { value: 180 }, { value: 150 }, { value: 280 }, { value: 220 }, { value: 350 }, { value: 300 }, { value: 250 }, ]; const BentoLineChart = memo( ({ data = defaultData, dataKey = "value", metricLabel = "Value", isPercentage = false, useInvertedBackground, className = "", }) => { const theme = useTheme(); const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle); const yAxisWidth = calculateYAxisWidth(data, isPercentage); const strokeColor = "var(--primary-cta)"; const gridColor = "color-mix(in srgb, var(--background-accent) 30%, transparent)"; const tickColor = shouldUseLightText ? "var(--background)" : "var(--foreground)"; return (
isPercentage ? `${value}%` : formatNumber(value) } /> } cursor={{ stroke: gridColor, }} />
); } ); BentoLineChart.displayName = "BentoLineChart"; export default BentoLineChart;