For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
0
Sponsor

Bar Chart

Animated, grouped, stacked, percent, and zoomable WebGPU column charts powered by ChartGPU.

Basic Chart
DesktopMobile

Installation

$ pnpm dlx shadcn@latest add @chartcn/bar-chart

Usage

import {
  ChartcnBarChart,
  type ChartConfig,
} from "@/components/chart/bar-chart";
<ChartcnBarChart config={chartConfig} data={data} xDataKey="month">
  <ChartcnBarChart.Grid />
  <ChartcnBarChart.XAxis dataKey="month" />
  <ChartcnBarChart.Brush />
  <ChartcnBarChart.Legend />
  <ChartcnBarChart.Tooltip />
  <ChartcnBarChart.Bar dataKey="desktop" radius={5} />
  <ChartcnBarChart.Bar dataKey="mobile" radius={5} />
</ChartcnBarChart>

Examples

Stacked columns

stackType='stacked'
DesktopMobile

Percent columns

stackType='percent'
DesktopMobile

Loading state

isLoading='true'
DesktopMobile
Loading

API Reference

ChartcnBarChart

PropTypeDefault
dataData[]required
configChartConfigrequired
childrenReactNode-
xDataKeystring-
stackType"default" | "stacked" | "expanded" | "percent""default"
animationboolean | AnimationConfig{ duration: 650, easing: "cubicOut" }
isLoadingbooleanfalse
showBrushbooleanfalse
onBrushChange({ startIndex: number; endIndex: number }) => void-

Bar

PropTypeDefault
dataKeystringrequired
radiusnumber4
barWidthnumber | string-
stackIdstring"chartcn"

Shared parts

Grid, XAxis, YAxis, Brush, Legend, and Tooltip accept the concrete props documented by the Line Chart.