import React from 'react' import { Bar, CartesianGrid, Cell, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis, ComposedChart, Line, ReferenceLine, } from 'recharts' import { OHLCVPoint } from '../api/stockApi' interface Props { data: OHLCVPoint[] } function formatShares(v: number): string { const abs = Math.abs(v) const sign = v < 0 ? '-' : '' if (abs >= 1_000_000) return `${sign}${(abs / 1_000_000).toFixed(1)}M` if (abs >= 1_000) return `${sign}${(abs / 1_000).toFixed(0)}K` return `${v.toFixed(0)}` } const CustomTooltip = ({ active, payload, label }: any) => { if (!active || !payload?.length) return null const d: OHLCVPoint = payload[0]?.payload return (
{label}
外資: = 0 ? 'text-green-400' : 'text-red-400'}>{formatShares(Number(d.foreign_net ?? 0))}
投信: = 0 ? 'text-green-400' : 'text-red-400'}>{formatShares(Number(d.trust_net ?? 0))}
自營商: = 0 ? 'text-green-400' : 'text-red-400'}>{formatShares(Number(d.dealer_net ?? 0))}
合計: = 0 ? 'text-green-300' : 'text-red-300'}>{formatShares(Number(d.institutional_net ?? 0))}
{d.institutional_as_of && (資料日: {d.institutional_as_of}
)}