import React from 'react' import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Cell, ResponsiveContainer, } from 'recharts' import { OHLCVPoint } from '../api/stockApi' interface Props { data: OHLCVPoint[] } function formatVolume(v: number): string { if (v >= 1_000_000) return `${(v / 1_000_000).toFixed(1)}M` if (v >= 1_000) return `${(v / 1_000).toFixed(0)}K` return String(v) } const CustomTooltip = ({ active, payload, label }: any) => { if (!active || !payload?.length) return null const vol: number = payload[0]?.value return (

{label}

Vol: {formatVolume(vol)}

) } export const VolumeChart: React.FC = ({ data }) => { const len = data.length return ( { const step = Math.max(1, Math.floor(len / 10)) return idx % step === 0 ? val : '' }} interval={0} /> } /> {data.map((d, i) => ( = d.open ? '#22c55e' : '#ef4444'} fillOpacity={0.8} /> ))} ) }