Donut Chart in C#
Build donut charts in C# with DonutHole and DonutCenter — a total in the middle, labelled slices around it, rendered as self-contained SVG.
Donut Chart
Pie chart with DonutHolePercent = 0.55 creating a donut hole.
Donut — Center Label
DonutCenter: auto total · title caption · font size.
Monthly Sales — USD Donut
Donut chart with USD data labels and DonutCenter total.
When to use a donut chart
Reach for it when
- A part-of-whole breakdown where the total itself is worth stating — put it in the hole with DonutCenter.
- Dashboard tiles, where the ring reads as a compact shape at small sizes.
- The same cases as a pie chart, when the centre space is useful rather than empty.
Use something else when
- The comparisons a pie chart is already bad at. Removing the centre makes angle judgement slightly harder, not easier.
- Many slices — the ring is thinner than a pie, so small slices disappear sooner.
- A single percentage. Use a data ring or a gauge, which are built for one value.
Donut Chart in C#
Lifted verbatim from the chart types reference, so it compiles against the shipped API. See the API reference for every overload and the exact data types each series method accepts.
// Donut with center label
string svg = ChartBuilder.Create()
.AsPie()
.Title("Revenue by Region")
.Size(620, 460)
.Labels("North America","Europe","Asia-Pacific","Rest of World")
.Legend(l => l.AtBottom())
.AsAnimated()
.Series(s => s
.Add("Revenue %", new double[] { 42, 28, 22, 8 },
cfg =>
{
cfg.DonutHole(0.55); // 55 % hole radius
cfg.DataLabel.Show().Radius(1.0).Format("{value}%");
cfg.DonutCenter.Show().Title("Total");
}))
.RenderToSvg();Install
dotnet add package TerraFluent.Chart.Reporting
- MIT licensed — free for commercial use, no chart limits, no watermarks.
- Zero dependencies — nothing but the .NET base class library.
- netstandard2.0 through net10.0 — .NET Framework 4.6.1+, .NET Core 2.0+, and every modern release.
- Output is one SVG string — embed it in HTML, a PDF, or a Word document.