Components/Asset Allocation

Asset Allocation

Portfolio mix visualization. Donut, bar, or list — same data, three forms. Optional target weights surface rebalance suggestions inline.


Portfolio mix

Total

$92,200

  • US Stocks52.3%$48,200
  • Intl. Stocks19.6%$18,100
  • Bonds16.7%$15,400
  • Crypto6.8%$6,300
  • Cash4.6%$4,200

Installation

npx ajaxui add asset-allocation

Bar variant

Stacked horizontal bar — saves vertical space, great for dashboard headers.

Portfolio mix

  • US Stocks52.3%$48,200
  • Intl. Stocks19.6%$18,100
  • Bonds16.7%$15,400
  • Crypto6.8%$6,300
  • Cash4.6%$4,200

List variant

Drops the chart entirely. Use when the legend itself is the data — e.g. sidebars.

By asset class

  • US Stocks52.3%$48,200
  • Intl. Stocks19.6%$18,100
  • Bonds16.7%$15,400
  • Crypto6.8%$6,300
  • Cash4.6%$4,200

Rebalance hints

Pass a target on each slice and enable showTargets. The chip shows the deviation from target — amber when overweight, sky when underweight.

Rebalance suggestions

Total

$92,200

  • US Stocks52.3%$48,200+2.3%
  • Intl. Stocks19.6%$18,100-0.4%
  • Bonds16.7%$15,400-3.3%
  • Crypto6.8%$6,300+1.8%
  • Cash4.6%$4,200-0.4%

Custom colors

Total

$100

  • Stocks60.0%$60
  • Bonds30.0%$30
  • Cash10.0%$10

Slice shape

interface AllocationSlice {
  label:  string
  value:  number          // absolute amount in the chosen currency
  color?: string          // any CSS color; cycles through palette when omitted
  target?: number         // 0..1 — enables rebalance diff when showTargets is on
}

Props

PropTypeDefaultDescription
allocationsAllocationSlice[]Slices to render.
totalValuenumberautoOverride the sum used for percentages.
currencystring"USD"ISO 4217 currency code.
localestring"en-US"Locale for currency formatting.
variant"donut" | "bar" | "list""donut"Visual form.
sizenumber180Donut diameter in px (donut only).
showLegendbooleantrueShow the legend next to the chart.
showTargetsbooleanfalseShow rebalance diffs from `target`.
titlestringOptional header inside the card.