ShellUI Logo
ShellUI

Donut Chart

Donut charts for part-to-whole data

DonutChart renders a donut chart for part-to-whole data. Built on ApexCharts, with the same custom tooltips and themes as the other ShellUI charts.

Installation

shellui add donut-chart

shellui add also installs chart and its styles, and adds the Blazor-ApexCharts NuGet package to your project.

Usage

<DonutChart TItem="Traffic"
    Data="@_traffic"
    Title="Traffic by source"
    Name="Visits"
    XValue="@(t => t.Source)"
    YValue="@(t => (decimal?)t.Visits)"
    Height="350px" />

@code {
    private List<Traffic> _traffic = new()
    {
        new("Search", 4200), new("Direct", 2100),
        new("Social", 1300), new("Referral", 800)
    };

    record Traffic(string Source, int Visits);
}

API Reference

PropertyTypeDefaultDescription
TItemGeneric type—The data item type
DataIEnumerable<TItem>?nullData collection to visualize
Namestring"Data"Series name shown in the tooltip
XValueFunc<TItem, object>?nullCategory label for each item
YValueFunc<TItem, decimal?>?nullNumeric value for each item
ThemeChartThemeDefaultColor theme (Default, Colorful, Monochrome)
Titlestring?nullChart title
Subtitlestring?nullChart subtitle
Heightstring?"400px"Chart height
Widthstring?"100%"Chart width
ShowLegendbooltrueShow the legend
ShowToolbarboolfalseShow the ApexCharts toolbar
Classstring?nullAdditional CSS classes

On this page