Activity rings
Rings that close when a goal is reached, with a second lap beyond it. Good for daily goals: moving, exercise, steps, sales.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'rings',
data: [
{ name: 'Move', value: 540, goal: 600, unit: ' kcal', color: '#d1495b' },
{ name: 'Exercise', value: 25, goal: 30, unit: ' min', color: '#7cb342' },
{ name: 'Stand', value: 5, goal: 12, unit: ' h', color: '#4f9dde' },
],
};
export default function Example() {
return <Chart spec={spec} style={{ height: 340 }} />;
}Or import this chart alone: what each import weighs.
Options
Beside the fields shared by every chart (title, format, heading, export…), type rings takes:
/** Rings that close when a goal is reached; a second lap shows what goes beyond. */
interface RingsSpec extends Base {
type: 'rings';
/** From the outer ring to the inner one. */
data: { name: string; value: number; goal: number; unit?: string; color?: string }[];
}Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More