Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Nested donut chart

Since 0.1.0-alpha.22
Shows how the same items split two or three totals, such as a country's exports and imports.

Use rings to compare how the same items split two or three totals, such as exports and imports. They show the overall mix, not exact shares. The same share looks bigger on the outer ring. For exact comparisons, use 100% stacked bars.

A ring per measure

Give NestedDonutChart the Items, each slice's name as Argument, and a DonutRing for each measure, with its Value and Name. The first ring is the outer one, and each item keeps its color in every ring.

Static

Preview

Revenue by region

Outside: 2025, Inside: 2024

  • North America
  • Europe
  • Asia Pacific
  • Latin America
Left and Right move along a ring, Up and Down between rings; Escape hides the tooltip.

Code

Usage.razor
@* A company's revenue by region this year, outside, against last year, inside. *@
<NestedDonutChart Items="_regions" Argument="r => r.Region" Title="Revenue by region" ValueFormat="C0">
    <DonutRing Value="r => r.ThisYear" Name="2025" />
    <DonutRing Value="r => r.LastYear" Name="2024" />
</NestedDonutChart>

@code {
    private record RegionRevenue(string Region, decimal ThisYear, decimal LastYear);

    private readonly RegionRevenue[] _regions =
    [
        new("North America", 18_400_000, 17_900_000),
        new("Europe", 11_200_000, 12_600_000),
        new("Asia Pacific", 9_700_000, 6_800_000),
        new("Latin America", 3_100_000, 2_900_000),
    ];
}

Add this example to a page with the izzy CLI:

bash
izzy add component NestedDonutChart --at <file>:<line>

The line under the title names each ring by its place.

Details

The first ring is the outer one; each item has one color in every ring and one row in the legend. A line under the title says which ring is which.

Rings compare poorly: the same share is a longer arc on the outer ring. To compare how two wholes split, a Chart with 100% stacked bars reads better; use rings for two, at most three.

Parts

Written inside NestedDonutChart. The API page lists their parameters.

  • DonutRing<TItem>: one ring of a NestedDonutChart<T>: a measure of the chart's items, such as <DonutRing Value="c => c.Exports" Name="Exports" />.

Mode support

What works in each mode, Nested donut chart
FeatureStaticInteractive
A ring for each measure, the first outside, with the rings named under the titleYesYes
One color and one legend row per item, in every ringYesYes
Legend items that hide and show an item's slices in every ringYesYes
A table of each ring's values and shares in a "Show data" disclosureYesYes
Tooltips on hover and from the keyboard, along a ring and between ringsYesYes

Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.

Without JavaScript

Every page starts as plain HTML: before IzzyBlazor's script loads on a static page, while an interactive page prerenders, and with JavaScript off.

  • Legend items that hide and show an item's slices in every ring: waits for the script
  • Tooltips on hover and from the keyboard, along a ring and between rings: waits for the script

Accessibility

  • The chart is a figure captioned by Title, or named by a heading on the page with TitledBy.
  • The circle is one image named by the caption and described by the line naming the rings.
  • The legend is text: each item's name, read in order.
  • "Show data" under the chart opens a table of every ring's values and shares (DataTable).
  • With script, the circle is one Tab stop: Left and Right move along a ring, Up and Down between rings, and each slice is said with its ring.

Keyboard navigation

On the circle

NestedDonutChart keys, On the circle
Press this keyTo do this
Right or LeftShow the next or previous slice in the same ring
Down or UpMove to the same item on the ring inside or outside
Home or EndGo to the ring's first or last slice
EscapeHide the tooltip

Parameters

NestedDonutChart parameters
PropTypeDefault
ChildContentThe rings, as DonutRing<T> items: the first is the outer one.RenderFragment?
CenterContent in the hole, such as a total.RenderFragment?
ItemsThe items, one slice each (in each ring, on a NestedDonutChart<T>).IEnumerable<TItem>?Required
ArgumentEach slice's name, such as p => p.Plan.Expression<Func<TItem, object?>>?
TitleThe chart's title, such as "Customers by plan", shown above it as its caption.string?
HideTitleHides the title, which still names the chart for screen readers.boolfalse
DownloadShows a button across from the title that saves the chart as a PNG, named after its title, in the color scheme on screen.boolfalse
TitleAlignWhere the title sits: at the start, over the chart's first label, by default (the left, in a left-to-right page); ChartAlign.Center or ChartAlign.End.ChartAlignChartAlign.Start
TitledByThe id of a heading already on the page that titles the chart, such as a card's, in place of Title: the chart takes its name from it and shows no title of its own.string?
StartAngleWhere the first slice starts, in degrees clockwise from the top: 90 starts it at the right, so it runs down that side.double0
SweepHow far round the slices go, in degrees: 360 (the default) for a whole circle, 180 for a half.double360
SizeThe circle's largest size.Length?computed
ValueFormatA .NET format string for the values, such as C0 or N0.string?
TooltipShows a tooltip with the slice's value and share under the pointer or keyboard focus, with script.booltrue
PaletteThe colors in order: Colors (the theme's eight, the default), Shades of one color for slices in an order, Diverging for slices either side of a middle, or your own with Of.ChartPalette?
LegendThe legend: each slice's name by its color, with its value and share on a PieChart<T> (names only on a NestedDonutChart<T>, whose values differ ring by ring).ChartLegendChartLegend.Auto
LegendAlignWhere the legend sits along its edge: centered on the circle, by default (beside it or under it); ChartAlign.Start for the left above or below (in a left-to-right page) or the top beside it, ChartAlign.End for the right or the bottom.ChartAlign?
DataTableThe values as a table: by default behind a "Show data" button that opens it over the chart; ChartDataTable.Collapsed puts it in a disclosure under the chart.ChartDataTableChartDataTable.Popover
RefreshHow often the chart reads its data again, at least a second, such as Refresh="TimeSpan.FromSeconds(30)".TimeSpan?
RefreshFromOn a static page with Refresh: a lighter page to fetch than this one, which renders the same chart with the same id.string?
OnRefreshOn an interactive page with Refresh: raised at each interval, to load new data.EventCallback

See also

  • PieChart: shows how one total splits into a few shares, such as customers by plan, each labeled with its share.
  • Chart: draws a chart on the server from a list of items, with axes, value labels, reference lines, trends and a table of the values, for every chart type.

Connection lost

Rejoining the server…