import React from 'react' import { ComposedChart, Bar, Line, Cell, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ReferenceLine, ResponsiveContainer, } from 'recharts' import { OHLCVPoint } from '../api/stockApi' interface Props { data: OHLCVPoint[] } const CustomTooltip = ({ active, payload, label }: any) => { if (!active || !payload?.length) return null const d: OHLCVPoint = payload[0]?.payload return (

{label}

{d.macd != null && (

MACD: {d.macd.toFixed(3)}

)} {d.macd_signal != null && (

Signal: {d.macd_signal.toFixed(3)}

)} {d.macd_hist != null && (

Hist:{' '} = 0 ? 'text-green-400' : 'text-red-400'}> {d.macd_hist.toFixed(3)}

)}
) } export const MACDChart: React.FC = ({ data }) => { const len = data.length return ( { const step = Math.max(1, Math.floor(len / 10)) return idx % step === 0 ? val : '' }} interval={0} /> v.toFixed(1)} width={40} /> } /> {value}} /> {/* MACD Histogram */} {data.map((d, i) => ( = 0 ? '#22c55e' : '#ef4444'} fillOpacity={0.7} /> ))} {/* MACD Line */} {/* Signal Line */} ) }