Activity rings

Up to four concentric rings, each progress toward a goal of its own: calories, minutes and hours on one day, or each region against its target. SVG circles with a round-capped dash, each on a faint track of its own colour, outermost first.

Anatomy

← x-ds-chart only when `interactive`
← the progress …
the `centre` slot
    legend: swatch, name, "420 / 600 · 70%"
Ring, Value, Goal, Share
PartTokenWhy
Ringsseries-1 … series-4 by position; a row's tone or seriesspecs/chart-series.md
Trackthe ring's own colour at 20%; 40% while it is being readOne ring reads as one thing, done and still to do.
Sizesm 128, md 160, lg 208pxas the donut
Thicknesssm 7, md 10, lg 13 (of 100), 2 between ringsnarrowed by Chart::rings() when the rings would leave a hole under 16

Geometry

Chart::rings() gives the radii, outermost first, and one width for all; Chart::ring() gives each the dash. A round cap reaches half the stroke's width past each end of a dash, so the dash is shortened by one width and started half a width in: the drawn ring runs from twelve o'clock to exactly its share. A sliver shorter than its caps is a dot. Zero draws no progress, only the track.

Past the goal, the ring is drawn full and no further. A second lap would need a darker overlap to be seen, a cue only colour gives; so the real figure is said instead, in the legend ("14 / 12 · 117%"), the readout, the summary and the table. This is the simpler of the two honest options and is documented as such.

There is no entry animation: optional in the brief, and a ring that sweeps in says nothing the static one does not.

Data

CaseResult
rows with label, value, max (default 100), tone / series, formatone ring each; a row's format is merged over the chart's
['North' => 82, …]value against 100
a negative or non-numeric valuethrows, naming the ring
a max of zero or lessthrows
more than four ringsthrows: past four each is too thin to read and the middle has no room
[]ds::empty-state, bare

The summary

Every ring, since there are at most four and they are the point: "Today: Move 420 kcal of 600 kcal (70%), Exercise 25 of 30 (83%), Stand 14 of 12 (117%)." summary replaces it; table adds ring, value, goal and share.

Accessibility

Without the scriptWith it
Roleimggroup, keeping the name; each ring's track img, "Stand: 14 of 12 (117%)"
Keyboardnoneone Tab stop; any arrow moves ring to ring, Home / End, Escape
Focus ring—round the whole set (has-focus-visible), as on the donut; the read ring's track brightens
Readout—on hover anywhere on a ring, tap and focus

The track is the mark, so a ring at zero is still reachable and the pointer reads a ring anywhere on it.

The centre slot is not hidden: put in it only what the summary or legend also says, or it is read twice.

Do not

  • Do not compare rings with each other. Each is against its own goal; the outer ring is longer at the same share.
  • Do not use it for parts of a whole. That is a donut.
  • Do not use it for one reading in a range. That is ds::gauge; one task's completion is ds::progress.

From the package repo: edit this page on GitHub.

Was this page helpful?