Trading
Portfolio
Asset allocation overview with a donut chart and per-asset legend. Fully presentational — pass anassets array and it computes totals and shares for you.
Preview
Portfolio
Asset allocation
Total
78,711.25 USD
4 assets
BTC
53.55%
42,150.00 USD
+2.40%
ETH
23.28%
18,320.50 USD
-1.10%
SOL
7.93%
6,240.75 USD
+5.80%
USDT
15.25%
12,000.00 USD
+0.00%
Source
Copy this file to components/trading/portfolio.tsx
tsx
'use client'
import * as React from 'react'
import { PieChart, Pie, Cell, ResponsiveContainer } from 'recharts'
import { cn } from '@/lib/utils'
export interface PortfolioAsset {
name: string
value: number
percentage?: number
change?: number
color?: string
}
export interface PortfolioProps {
assets: PortfolioAsset[]
currency?: string
title?: string
subtitle?: string
className?: string
}
// Renders a donut allocation chart plus a legend of asset rows.
// Percentages are auto-computed from values when not provided.Props
| Prop | Type |
|---|---|
| assets* | PortfolioAsset[] |
| currency | string |
| title | string |
| subtitle | string |
| className | string |