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

Menu

Bar Chart

Preview

Revenue by region

Demo data, in thousands of dollars

Illustrative revenue by region data
CategorySubscriptionsServicesMarketplace
North America$66K$75K$31K
Europe$102K$61K$36K
Asia Pacific$72K$50K$36K
Latin America$29K$23K$25K
Middle East$51K$16K$13K
Africa$23K$18K$6K

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/bar-chart

Import the shared styles once in your application.

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

API Reference

BarChart

series
readonly LineChartSeries[]

Nonnegative values aligned with categories. Missing or negative values leave a gap.

Default—
categories
readonly string[]

Unique category labels in display order.

Default—
layout?
"grouped" | "stacked"
Default—
orientation?
"vertical" | "horizontal"
Default—
sort?
"none" | "ascending" | "descending"

Order categories by their visible total. Bars glide to their new place when it changes.

Default—
max?
number

Fixed top of the value axis. Defaults to a rounded value above the tallest bar.

Default—
v-model:activeId?
string | null

Inspected category, by label.

Default—
defaultActiveId?
string | null
Default—
@active-change?
(id: string | null) => void
Default—
v-model:hiddenSeries?
readonly string[]

Series ids hidden through the legend.

Default—
defaultHiddenSeries?
readonly string[]
Default—
formatValue?
(value: number) => string
Default—
formatTick?
(value: number) => string

Axis tick labels. Defaults to compact notation (1.2K).

Default—
label?
string
Default—
labels?
Partial<BarChartMessages>

Override any built-in string, including the shared `xyChart` ones.

Default—
class?
string
Default—
@hidden-series-change?
(ids: string[]) => void
Default—
#default?
slot

Compose `BarChartPlot`, `BarChartTooltip` and `BarChartLegend`; omit it for the complete chart.

Default—

BarChartLegend

class?
string
Default—

BarChartPlot

height?
number

Plot height in px. Horizontal charts default to 36px per category.

Default—
labelWidth?
number

Width of the category label gutter for horizontal bars, in px.

Default96
showGrid?
boolean
Defaulttrue
class?
string
Default—

BarChartTooltip

class?
string
Default—
side?
"top" | "right" | "bottom" | "left"
Defaulttop
#default?
BarChartTooltipData

Replaces the default content. Receives the inspected category, its index, its rows and their total.

Default—

Updated