import { PieChart, Pie, Cell, Tooltip } from 'recharts' import { formatUsdValue, tokenPrecision } from 'utils' import * as MonoIcons from '../icons' import { QuestionMarkCircleIcon } from '@heroicons/react/solid' import { useTheme } from 'next-themes' export const CHART_COLORS = (theme) => { return { All: '#ff7c43', spacer: theme === 'Light' ? 'rgba(0,0,0,0.1)' : 'rgba(255,255,255,0.1)', ADA: '#404C5E', AVAX: '#E84142', BNB: '#F3BA2F', BTC: '#F7931A', ETH: '#627EEA', FTT: '#02A6C2', GMT: '#CBA74A', MNGO: '#FBB31F', MSOL: '#C8ECE1', RAY: '#4CA2DA', SOL: '#916CE0', SRM: '#58D4E3', USDC: '#2775CA', USDT: '#50AF95', } } const LongShortChart = ({ chartData }: { chartData: any[] }) => { const { theme } = useTheme() const CustomToolTip = () => { const renderIcon = (symbol) => { const iconName = `${symbol.slice(0, 1)}${symbol .slice(1, 4) .toLowerCase()}MonoIcon` const SymbolIcon = MonoIcons[iconName] || QuestionMarkCircleIcon return (
) } const showTooltip = chartData.find((d) => d.symbol !== 'spacer') return chartData.length && showTooltip ? (
{chartData .filter((d) => d.symbol !== 'spacer') .sort((a, b) => b.value - a.value) .map((entry, index) => { const { amount, asset, symbol, value } = entry return (
{renderIcon(symbol)}

{asset}

{amount.toLocaleString(undefined, { maximumFractionDigits: tokenPrecision[symbol], })}

{formatUsdValue(value)}

) })}
) : null } return chartData.length ? ( {chartData .sort((a, b) => a.symbol.localeCompare(b.symbol)) .map((entry, index) => ( ))} } position={{ x: 48, y: 0 }} wrapperStyle={{ zIndex: 10 }} /> ) : null } export default LongShortChart