Sunburst

SunburstChartControl

Explore a hierarchy ring by ring: click to drill in, click the center to zoom out.

Overview

SunburstChartControl is a Blazor sunburst chart: a hierarchy drawn as concentric rings, where each segment's size shows its share of the parent. Use it for any breakdown with levels, such as sales by region and country: users click a segment to drill in and the center to zoom out. The data here is COVID-19 cases and deaths for 210 countries, after an article on Toward Data Science.

Examples

#Cases and deaths by continent and country

Switch the metric, filter a continent, search a country or open the data table underneath; the chart, stats and leaderboard share one selection.

Continents:
🔍
Interactive Radial Sunburst Partition Showing Total Cases
AsiaIndiaIraEuropeFranceGerItalyPolRussiaUkrUnit…Afr…SouNorth AmericaMex…United StatesSouth AmericaArge…BrazilCol…Per TOTAL CASES 56,956,080 Across the World
Global Pandemic Key Metrics
Total Cases
56,956,080
Total Deaths
1,397,672
Case Fatality Rate
2.45%
Territories
210 Countries
Region Inspector
World
Total Confirmed Cases: 56,956,080
Total Reported Deaths: 1,397,672
Case Fatality Rate: 2.45%
Share of Global Cases: 100.0%
Top 10 Highest Cases Click to highlight
Underlying COVID-19 Dataset Explorer
Tabulated country records powered by FlexCore GridControl with sorting, filtering, and paging

Documentation

Written from SunburstChartControl.razor, its scoped CSS and SunburstModels.cs. The control has no public methods: its surface is the parameters and two events below plus the SunburstNode tree it is given. Build that tree with AddChild, because the drawing reads Parent, Depth and the two totals rather than Value directly. There is no JavaScript interop in the control; hover and the tooltip position come from Blazor mouse events on the container.

ParameterTypeDefaultDescription
RootNodeSunburstNode?nullThe tree to draw; ring 1 is its children, ring 2 their children, and deeper levels appear after a drill-down. A new tree that does not contain the node drilled into resets the view to its root; otherwise the drill position is kept. Nothing is drawn when the root is null, has no children, or their totals sum to zero.
Titlestring?nullText in a fx-sunburst-title line above the breadcrumb; nothing is rendered when empty.
Widthstring"100%"Inline width of the root element, capped at 100 percent; the drawing inside is capped again at 680 px square by fx-sunburst-viewport.
Heightstring"620px"Declared, but never read: the drawing is square and sized by its width. This page passes 620px and it has no effect.
CenterRadiusRatiodouble0.28Radius of the center hub as a share of the 325-unit drawing radius, clamped to 0.15 to 0.45; the rings share what is left.
ValueFormatstring"N0"Numeric format of the hub value and of the two totals in the tooltip, in the current culture.
MetricNamestring"Cases"Label of the first total in the tooltip, as Total Cases:. Used nowhere else.
SecondaryMetricNamestring"Deaths"Label of the second total in the tooltip, shown only when the node has a SecondaryValue or its TotalSecondaryValue is above zero.
CenterTitlestring"TOTAL CASES"Upper line of the hub while the view is at RootNode; after a drill-down the hub shows the current node's Name upper-cased instead.
CenterColorstring"#38bdf8"Fill of the hub when the current node, the root included, has no Color; a node with a color wins. Hovering a hub that can zoom out darkens the fill 15 percent.
EnableDrilldownbooltrueTrue: clicking a segment that has children makes it the current root, clicking the hub goes up one level, and the tooltip adds a drill hint. False: segment clicks still raise OnNodeClick and the hub does nothing. The breadcrumb buttons navigate either way.
ShowBreadcrumbbooltrueRenders the pill above the drawing: a root button with RootNode.Name, or World, then one button per ancestor down to the current node. Each button jumps there, with or without EnableDrilldown.
ShowLabelsbooltrueWrites each node's Name along its segment, rotated to the mid angle and turned to stay readable on the left half. Segments under 0.045 radians get no label, 0.065 on ring 2; longer names are cut to about one character per 7.5 units of arc, three at least, with an ellipsis.
HighlightedNodeIdstring?nullThe segment whose node Id matches gets the highlighted class, a white stroke and the glow, and every other segment is dimmed while it is set. The control never changes it; an id that matches nothing dims the whole chart.
CssClassstring?nullExtra classes on the root fx-sunburst-container element.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.