Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • Footer
  • MenuNew
  • Navbar
  • On This PageNew
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Button
  • Checkbox
  • Color Picker
    • Date
    • Date Range
    • Datetime
    • Datetime Range
    • Time
    • Time Range
  • File Upload
  • NumericNew
  • Radio Button
  • RatingNew
  • Select
  • Slider
  • Switch
  • Textfield
  • Alert
  • Avatar
  • Chip
  • Icon
  • Progress
  • Skeleton
  • Spinner
  • TooltipNew
  • Data Table
  • Pagination
  • Pick List
  • BarcodeNew
  • QR CodeNew
  • CalendarNew
  • Table
  • Overview
  • Area
  • Bar
  • Box Plot
  • Bullet
  • Bump
  • Candlestick
  • Column
  • Dot Plot
  • Dumbbell
  • Funnel
  • Gantt
  • Gauge
  • Heatmap
  • Histogram
  • Icon
  • Line
  • Lollipop
  • Matrix
  • Nightingale
  • Parallel Coordinates
  • Pie
  • Quadrant
  • Radar
  • Radial Bar
  • Range
  • Scatter
  • Slope
  • Small Multiples
  • Strip Plot
  • Treemap
  • Waffle
  • Waterfall
  • Arc Diagram
  • Barcode
  • Beeswarm
  • Bump Area
  • Categorical Scatter
  • Chord Diagram
  • Circular Treemap
  • Contour
  • Convex Treemap
  • Density Plot
  • Dendrogram
  • Euler Diagram
  • Flowchart
  • Hexagonal Binning
  • Horizon
  • Marimekko
  • Network Diagram
  • Radial Histogram
  • Ridgeline
  • Sankey
  • Stream Graph
  • Sunburst
  • Venn Diagram
  • Violin Plot
  • Word Cloud
  • Dialog Service
  • Toast Service
API DocumentationAI Agents & Skills
Home Get Started

Charts

TwPieChart

TwPieChart is a Blazor pie chart for parts of a whole. Set an inner radius for a donut chart, or draw it as a semicircle.

Last updated 18 October 2026

Please be aware this component is new, may have bugs and/or be subject to change. Please report any bugs at https://github.com/twblazor/twblazor/issues.

Basic usage

TwPieChart sizes each slice by its share of the whole. Pass a list of ChartValue. Slices large enough to hold a label show their share, and the legend names every slice.
Traffic by source
  • Search
  • Direct
  • Social
  • Email
  • Referral
Search: 430 (43%)Direct: 260 (26%)Social: 170 (17%)Email: 90 (9%)Referral: 50 (5%)43%26%17%9%
SearchValue 430Share 43%
DirectValue 260Share 26%
SocialValue 170Share 17%
EmailValue 90Share 9%
ReferralValue 50Share 5%
RAZOR
<TwChart Title="Traffic by source">
    <TwPieChart Data="@_sources" />
</TwChart>
CSHARP
@code {
    private readonly ChartValue[] _sources =
    [
        new("Search", 430),
        new("Direct", 260),
        new("Social", 170),
        new("Email", 90),
        new("Referral", 50)
    ];
}

Donut

Set InnerRadius between 0 and 0.9 to open a hole in the middle, and CenterText to put a headline figure in it.
Traffic by source
  • Search
  • Direct
  • Social
  • Email
  • Referral
Search: 430 (43%)Direct: 260 (26%)Social: 170 (17%)Email: 90 (9%)Referral: 50 (5%)43%26%17%9%1,000
SearchValue 430Share 43%
DirectValue 260Share 26%
SocialValue 170Share 17%
EmailValue 90Share 9%
ReferralValue 50Share 5%
RAZOR
<TwChart Title="Traffic by source">
    <TwPieChart Data="@_sources" InnerRadius="0.6" CenterText="1,000" />
</TwChart>

Semicircle

Set Semicircle for a half donut, which takes less vertical space.
Traffic by source
  • Search
  • Direct
  • Social
  • Email
  • Referral
Search: 430 (43%)Direct: 260 (26%)Social: 170 (17%)Email: 90 (9%)Referral: 50 (5%)43%26%17%9%1,000
SearchValue 430Share 43%
DirectValue 260Share 26%
SocialValue 170Share 17%
EmailValue 90Share 9%
ReferralValue 50Share 5%
RAZOR
<TwChart Title="Traffic by source">
    <TwPieChart Data="@_sources" InnerRadius="0.6" Semicircle="true" CenterText="1,000" />
</TwChart>

Many values

A pie works for a handful of parts. Past eight values, the smallest are folded into one slice named by OtherLabel so a color is never reused. The table view still lists every value.
Visits by country
  • United Kingdom
  • United States
  • Germany
  • France
  • Spain
  • Italy
  • Canada
  • Rest of world
United Kingdom: 320 (27.1%)United States: 280 (23.7%)Germany: 150 (12.7%)France: 120 (10.2%)Spain: 90 (7.6%)Italy: 70 (5.9%)Canada: 60 (5.1%)Rest of world: 90 (7.6%)
United KingdomValue 320Share 27.1%
United StatesValue 280Share 23.7%
GermanyValue 150Share 12.7%
FranceValue 120Share 10.2%
SpainValue 90Share 7.6%
ItalyValue 70Share 5.9%
CanadaValue 60Share 5.1%
Rest of worldValue 90Share 7.6%
RAZOR
<TwChart Title="Visits by country">
    <TwPieChart Data="@_countries" OtherLabel="Rest of world" ShowPercentages="false" />
</TwChart>
CSHARP
@code {
    private readonly ChartValue[] _countries =
    [
        new("United Kingdom", 320), new("United States", 280), new("Germany", 150), new("France", 120),
        new("Spain", 90), new("Italy", 70), new("Canada", 60), new("Japan", 40), new("Brazil", 30), new("India", 20)
    ];
}

Labels

ShowPercentages turns the share labels off. LabelHeader and ValueHeader name the table columns, and ValueHeader also names the value in tooltips.

Summary

Tooltips and the table view give the value of each slice. Tooltips also give its share of the whole.

Shared features

The legend, tooltips, keyboard navigation, table view, value formatting, height and empty state work the same on every chart. See TwChart for those options.

Keyboard navigation

The plot is a single Tab stop. Each data point is announced with its series and value as focus reaches it, and the table view presents the same data without the plot.
Key What it does
Tab Moves focus into the plot, onto the data point last visited.
Arrow Right or Arrow Down Moves to the next data point.
Arrow Left or Arrow Up Moves to the previous data point.
Home or End Moves to the first or last data point.
Escape Hides the tooltip of the focused data point.
Enter or Space On a legend item: shows or hides that series. On the table button: switches between the chart and its data table.

On this page

  • Basic usage
  • Donut
  • Semicircle
  • Many values
  • Labels
  • Summary
  • Shared features
  • Keyboard navigation
Discord (opens in a new tab) • GitHub (opens in a new tab) • Documentation (opens in a new tab) • MIT License (opens in a new tab) • llms.txt (opens in a new tab)

twblazor is and always will be free and open source.

An unhandled error has occurred. Reload