Skip to content
↑↓ to navigate↵ to openesc to close

Menu

Donut Chart

Preview

$115,150

Monthly revenue

Select a plan to filter

Install

Add it with your package manager, or copy the source manually.

Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide

bunx --bun shadcn-vue@latest add @beui-vue/donut-chart

Import the shared styles once in your application.

TSUsage
import DonutChart from '@/components/beui/charts/DonutChart.vue'
import '@/components/beui/styles.css'

API Reference

DonutChart

segments
readonly DonutSegment[]
Default—
thickness?
number

Ring thickness in viewBox units; the chart is 200 wide.

Default—
gap?
number

Degrees of empty space between neighbouring segments.

Default—
v-model:activeId?
string | null

Focused segment, shared by the ring, center, and legend.

Default—
defaultActiveId?
string | null
Default—
@active-change?
(id: string | null) => void
Default—
@select?
(id: string) => void

Called when a legend item is clicked.

Default—
selectedId?
string | null

Marks a legend item as pressed.

Default—
formatValue?
(value: number) => string
Default—
label?
string

Accessible name for the chart.

Default—
labels?
Partial<DonutChartMessages>

Override any built-in string.

Default—
class?
string
Default—
#default?
slot

Compose `DonutChartPlot` and `DonutChartLegend`; omit it for the complete chart. ```vue <DonutChart :segments="segments" :format-value="usd"> <DonutChartPlot><DonutChartCenter total-label="Monthly revenue" /></DonutChartPlot> <DonutChartLegend /> </DonutChart> ```

Default—

DonutChartCenter

#default?
{ segment: DonutPlacedSegment | null; total: number }

Custom content for the hole. Receives the focused segment, or null when nothing is focused, and the total.

Default—
totalLabel?
string

Caption under the total when nothing is focused.

Default—
class?
string
Default—
#totalLabel?
slot

Caption under the total when nothing is focused.

Default—

DonutChartLegend

#renderDetail?
{ segment: DonutPlacedSegment }

Extra line under each name, such as terms or a note.

Default—
#renderValue?
{ segment: DonutPlacedSegment }

Trailing value. Defaults to the share and formatted value.

Default—
class?
string
Default—

DonutChartPlot

#default?
slot

Centered overlay, usually `DonutChartCenter`.

Default—
class?
string
Default—

Updated