'use client'; import { useEffect, useState } from 'react'; import type { ApexOptions } from 'apexcharts'; import { cn } from '@/lib/utils'; interface ApexChartProps { type: 'line' | 'area' | 'bar' | 'pie' | 'donut' | 'radialBar' | 'scatter' | 'bubble' | 'heatmap' | 'candlestick' | 'boxPlot' | 'radar' | 'polarArea' | 'rangeBar' | 'rangeArea' | 'treemap'; series: ApexOptions['series']; options: ApexOptions; height?: number | string; width?: string | number; className?: string; } export function ApexChart({ type, series, options, height = 280, width = '100%', className }: ApexChartProps) { const [Chart, setChart] = useState(null); useEffect(() => { let cancelled = false; import('react-apexcharts').then((mod) => { if (!cancelled) setChart(() => mod.default); }); return () => { cancelled = true; }; }, []); if (!Chart) { return (
); } return (
); }