Skip to content
All components

Components

Donut

A donut is a ChartModel of kind Donut: the first series' values are its segments and x_ticks names them. Values of zero or less are left out, the total sits in the centre over the series' name, and the legend lists every part with its value. Use it for a few parts of one whole; for change over time use a line or area chart.

Share of a whole

Parts of one total, each named in the legend.

Email: 58Chat: 27Phone: 15
Email58Chat27Phone15
ChartModel {
    kind: ChartKind::Donut,
    series: vec![
        Series { name: "Channels".into(), values: vec![58.0, 27.0, 15.0], hue: 1 },
    ],
    x_ticks: ["Email", "Chat", "Phone"].map(String::from).to_vec(),
    title: Some("Tickets by channel".into()),
}

Two parts

A pair reads as done and left.

Spent: 6.4kLeft: 3.6k
Spent6.4kLeft3.6k
ChartModel {
    kind: ChartKind::Donut,
    series: vec![
        Series { name: "Budget".into(), values: vec![6420.0, 3580.0], hue: 1 },
    ],
    x_ticks: ["Spent", "Left"].map(String::from).to_vec(),
    title: Some("Monthly budget".into()),
}

Five parts

Keep to five; the theme has five chart colours.

Claude: 40GPT: 25Gemini: 15Llama: 12Other: 8
Claude40GPT25Gemini15Llama12Other8
ChartModel {
    kind: ChartKind::Donut,
    series: vec![
        Series {
            name: "Models".into(),
            values: vec![40.0, 25.0, 15.0, 12.0, 8.0],
            hue: 1,
        },
    ],
    x_ticks: ["Claude", "GPT", "Gemini", "Llama", "Other"].map(String::from).to_vec(),
    title: Some("Calls by model".into()),
}

On the Mac

The same vocabulary drawn by Ocean UI's native face (egui on Metal), as the gallery's snapshot.

Donut drawn by Ocean UI's native face, darkDonut drawn by Ocean UI's native face, light

Use it

Web

use ocean_ui_core::chart::{ChartKind, ChartModel, Series};
let tickets = Series { name: "Tickets".into(), values: vec![12.0, 5.0, 3.0], hue: 1 };
ChartModel { kind: ChartKind::Donut, series: vec![tickets], x_ticks: vec!["Open".into(), "Pending".into(), "Closed".into()], title: Some("Tickets by state".into()) }

Native

use ocean_ui_native::{Show, charts::Donut, egui::Id};
let parts: Vec<(String, f64, u8)> = [("ocean-git", 42.0, 1), ("studio", 23.0, 2), ("cnl-engine", 12.0, 3), ("agent-core", 7.0, 5)].map(|(n, v, h)| (n.to_string(), v, h)).to_vec();
Donut { total: "84", parts: &parts, id: Id::unique("gallery.donut"), size: 160.0 }.show(ui)

Cargo feature charts of ocean-ui-core, ocean-ui-web and ocean-ui-native; available since 2026-10-29.

In App UI, the chart block draws it from YAML.

Props

NameTypeDefaultWhat
kindChartKind—Donut.
seriesVec<Series>—One Series { name, values, hue } whose values are the parts and whose name sits under the total; the parts take the five chart hues in turn.
x_ticksVec<String>—The parts' names, in the order of the values.
titleOption<String>NoneThe ring's accessible name, Chart when absent.

Accessibility

  • The ring's SVG is role="img" with the title as its aria-label.
  • Each segment carries a title with its name and value, and the legend repeats both as text.
  • The total in the centre is aria-hidden; the legend's values carry the figures.

Related

Markdown

The same page as Markdown, for an agent or a pull request.

Search

esc

Components

Blocks

Screens built from blocks

The Ocean app

Ocean Base console