Data Pure CSS

Donut chart

A pure-CSS donut: the slices sweep in one after another as the chart enters view, the centre number and the legend percents roll, and the same data ships as a visually-hidden table for screen readers.

Real scenarios

The component as it is used in a product — not a specimen grid.

Conversations by channel

The week on the support desk, as the dashboard shows it: as the card enters view the slices sweep in one after another, the percents and the centre total roll — all in the page language’s digits and percent mark. Hover a legend row and it brightens while its siblings step back; underneath, a visually-hidden table hands the same data to screen readers.

Conversations this week

Every workspace · last 7 days

  • WhatsApp 4,700 44%
  • Telegram 3,300 31%
  • Web 1,800 17%
  • Email 900 8%
Conversations this week
ValueShare
WhatsApp4,70044%
Telegram3,30031%
Web1,80017%
Email9008%

A widget-sized storage donut

size sets the ring’s diameter and thickness its share of the radius — together they tune the chart down to a sidebar widget. The centre’s caption is yours (center-label); with fractional values the whole settles on one decimal.

Workspace storage

  • Documents 4.6 37%
  • Conversations 3.2 26%
  • Media 2.7 22%
  • Backups 1.8 15%
Workspace storage
ValueShare
Documents4.637%
Conversations3.226%
Media2.722%
Backups1.815%

The hole carries its own KPI

Percents in the slices and legend, the full count in the hole: center-value seats any number in place of the sum and center-label names it. Left out, the data’s own total lands there with the page language’s word for it — and an empty center-label hides the caption while the number keeps rolling.

How the week’s conversations ended

1,240 conversations · last 7 days

  • Auto-answered 68 68%
  • Agent-assisted 24 24%
  • Handed to a human 8 8%
How the week’s conversations ended
ValueShare
Auto-answered6868%
Agent-assisted2424%
Handed to a human88%

Important props

Important props
Prop Type Default What it does
data array [] ['Label' => value, …] — each slice’s share is computed from the sum, and colours land in the fixed --nx-chart-1…7 order.
title / subtitle string null The card’s title and subtitle; the title also names the chart for screen readers.
centerValue / centerLabel number / string null The number in the hole (the data’s sum by default) and its caption (the core i18n word for “Total” by default; an empty string hides it).
size / thickness string | number null (12rem / 14%) The ring’s diameter and thickness; a number means px for the diameter and % of the radius for thickness, and any other CSS length works too.
locale string null The locale for digits, the percent mark and the built-in words (the app’s by default).

Snippet

<x-nx::donut-chart title="گفت‌وگوها به تفکیک کانال" :data="[
    'واتساپ' => 4700, 'تلگرام' => 3300, 'وب' => 1800, 'ایمیل' => 900,
]" />

{{-- ویجت کوچک با برچسب مرکزی دلخواه --}}
<x-nx::donut-chart title="فضای ورک‌اسپیس" size="9rem" thickness="20%"
    center-label="گیگابایت" :data="$storage" />

{{-- عدد و برچسب دلخواه در چاه مرکزی، به‌جای جمع --}}
<x-nx::donut-chart :center-value="1240" center-label="گفت‌وگو" :data="$outcomes" />