Preview Updated 2026-05-10

Donut chart

Hollow pie chart that can show a value or label in the center.

Basic usage

Data is passed in via props. Pure SVG rendering, no third-party chart library dependency. Colors come from the --viz-1..8 tokens and are colorblind-friendly.

<CfDonutChart ... />
<CfDonutChart ... />

Different ring thicknesses

thickness controls the ring thickness (with the same size, thicker is more pie-like, thinner is more ring-like).

<CfDonutChart :segments="data" :thickness="14" center-value="78%" center-label="Completion" />
<CfDonutChart :segments="data" :thickness="22" />
<CfDonutChart :segments="data" :thickness="32" />
<CfDonutChart segments={data} thickness={14} centerValue="78%" centerLabel="Completion" />
<CfDonutChart segments={data} thickness={22} />
<CfDonutChart segments={data} thickness={32} />

API

PropTypeDefaultDescription
segmentsDonutSegment[]{ name, value, colorIndex? }[]
sizenumber180Diameter
thicknessnumber24Ring thickness
centerValue / centerLabelstring | numberCenter text
showLegendbooleantrue

反馈与讨论

Donut chart · Discussion

0
0 / 600
一键发送
正在加载评论...