hydroxy

Nested donut chart

Concentric rings, innermost first: one per series over the same categories, built with `series`, or one per level of a tree, built with `levels`, where children sit under their parent's sweep. The whole chart sweeps in clockwise as one motion.

Sessions by source

Thousands of sessions a year, 2023 in the middle and 2025 outside. Social has more than doubled its share.

Website sessions by source, 2023 to 2025
RingPartValueShare
2023Search412k52%
2023Direct186k24%
2023Social94k12%
2023Referral61k8%
2023Email38k5%
2024Search455k50%
2024Direct204k23%
2024Social141k16%
2024Referral58k6%
2024Email47k5%
2025Search468k45%
2025Direct231k22%
2025Social212k21%
2025Referral52k5%
2025Email66k6%

Usage

use hydroxy_leptos::chart_frame::ChartFrame;
use hydroxy_leptos::nested_donut_chart::*;
use leptos::prelude::*;

pub fn demo() -> AnyView {
    // Website sessions by source, in thousands, one ring per year.
    let year = |name: &str, values: [f64; 5]| {
        let sources = ["Search", "Direct", "Social", "Referral", "Email"];
        (name.to_string(), sources.iter().zip(values).map(|(s, v)| Datum::new(*s, v)).collect::<Vec<_>>())
    };
    let rings = series(&[
        year("2023", [412.0, 186.0, 94.0, 61.0, 38.0]),
        year("2024", [455.0, 204.0, 141.0, 58.0, 47.0]),
        year("2025", [468.0, 231.0, 212.0, 52.0, 66.0]),
    ]);

    view! {
        <ChartFrame title="Sessions by source" description="Thousands of sessions a year, 2023 in the middle and 2025 outside. Social has more than doubled its share.">
            <NestedDonutChart rings=rings label="Website sessions by source, 2023 to 2025" format=|v: f64| format!("{v:.0}k") />
        </ChartFrame>
    }
    .into_any()
}

Anatomy

Componentdata-partRenders
NestedDonutChartrootfigure; `data-active` while a segment is picked
plotFocusable square holding the rings, centre and tooltip
ringOne ring's segments; `data-ring` counts from 0 at the centre
segmentOne part, a stroked arc; `data-active` when picked
centerThe picked part's value and name, or the outer ring's total
legendCategories in colour order
ring-keyRing names from the centre out, when there are two or more
sr-tableEvery segment with its ring, value and share, for screen readers and CSV export

Keyboard

KeyDoes
Arrow keysStep through the segments, ring by ring from the centre
Home / EndFirst or last segment
EscapeClear the picked segment

Props

PropTypeNotes
ringsVec<Ring>Required. Innermost first; build with series(&[(name, data)]) or levels(&tree, depth)
labelStringRequired. What the chart shows; the accessible name
sizeu16Diameter in px. Default 280
holef64The empty centre's share of the radius. Default 0.42
center_labelStringCaption under the centre figure. Default: the outer ring's name
formatFn(f64) -> StringFormats values in the centre, tooltip and table

Events

PropTypeNotes
on_hoverCallback<Option<Datum>>The mark under the pointer or keyboard focus changes, or is left. Fires only on a change
on_selectCallback<Datum>Click, tap or Enter on a mark
Actions
Button
Icon button
Toolbar
Theme menu
Display
Avatar
Badge
Card
Chip
Code block
Markdown
Doc card
Due pill
Kbd
Priority mark
Source chip
Space icon
Status diamond
Tag
Value diff
Carousel
Reveal
Media timeline
QR code
Transcript viewer
Audio waveform
Audio player
Forms
Calendar
Checkbox
Combobox
Date picker
Color picker
Cron builder
Theme editor
Mention input
Signature pad
Image cropper
Date field
Date range picker
Duration field
Quantity stepper
Filter chip
Input
Markdown editor
Radio group
Search field
Segmented control
Select
Slider
Range slider
Rating
Toggle button
File dropzone
Upload queue
Attachment
Switch
Tags input
Number field
Money field
Phone field
Time field
OTP input
Password field
Questionnaire
Availability picker
Voice input
Recording control
Inline edit
Async validated input
Shortcut recorder
Data
Spreadsheet grid
Week scheduler
Virtual list
Stat card
Step track
Kanban board
Sortable list
Filter builder
Data table
Grid
Access editor
File manager
Gantt chart
Log stream
Diff viewer
JSON inspector
Terminal
Node editor
Whiteboard
Navigation
Table of contents
Breadcrumb
Tabs
Wizard
Nav item
Nav section
Tree view
Pagination
Menubar
Navigation menu
Saved views
Layout
Master detail
App shell
Sidebar layout
Resizable panels
Dashboard layout
Dock layout
Feedback
Callout
Check list
Empty state
Progress bar
Toast
Approval card
Skeleton
Notification center
Bars
Bar chart
Diverging bar chart
Span chart
Pictogram chart
Stacked bar chart
Funnel chart
Bullet chart
Waffle chart
Marimekko chart
Dot plot chart
Error bar chart
Pareto chart
Waterfall chart
Lollipop chart
Grouped bar chart
Bar race chart
KPIs and frames
Chart frame
Metric card
Sparkline
Points
Scatter chart
Smith chart
Strip plot
Beeswarm chart
Parallel coordinates
Ternary chart
Bland-Altman chart
Quiver chart
Connected scatter chart
Grids and tables
Heatmap chart
Chart table
Cohort chart
Radial
Radial charts
Radar chart
Polar area chart
Stat ring
Clock chart
Spiral chart
Lines and areas
Bump chart
Slope chart
Line chart
Composed chart
Small multiples
Cycle plot chart
Horizon chart
Stacked area chart
Threshold chart
Split line chart
Linked charts
Confidence band chart
Forecast fan chart
Step chart
Range area chart
Distributions
Contour chart
Histogram
Box plot
Density chart
Ridgeline chart
Violin chart
Q-Q chart
Survival chart
ECDF chart
Raincloud plot
Forest plot
Maps
Geo map
Bubble map
Hexbin map
Cartogram
Flow map
Parts of a whole
Donut chart
Voronoi treemap
Nested donut chart
Treemap chart
Sunburst chart
Bubble pack chart
Icicle chart
Flame graph chart
Pie chart
Word cloud
Relationships
Sankey chart
Network chart
Chord chart
UpSet chart
Venn chart
Alluvial chart
Adjacency matrix chart
Dependency graph chart
Tree chart
Arc diagram
Hive plot
Edge bundling
Finance
Candlestick chart
OHLC chart
Depth chart
Renko chart
Time
Timeline chart
Calendar heatmap chart
Spectrogram chart
Marey chart
Overlays
Tour
Lightbox
Alert dialog
Command palette
Dialog
Menu
Popover
Tooltip
Sheet
Hover card
Context menu
Utilities
Pacer
Hotkeys
Disclosure
Accordion
Collapsible
Chat
Chat bubble
Voice session
Composer
Thread
Thread list
Assistant composer
Assistant MCP
Assistant modal
Assistant thread
Assistant thread list
Message scroller
Insight note
Emoji picker
Tool trace
Model picker
Citation popover
Activity
Activity feed
Comment thread
Timeline
Presence bar
Live cursors
Reaction bar
Guides
Getting started
All components
All charts