Loading...
Loading...
> A versatile bar chart built with Recharts. Supports vertical/horizontal layouts, stacked bars, and color customization.
1import { BarChart, BarChartCard, StackedBarChart } from "@/components/ui/bar-chart"
1<BarChart2 data={data}3 xAxisKey="category"4 series={[5 { dataKey: "value", name: "Actual" },6 { dataKey: "target", name: "Target" },7 ]}8 height={300}9 showLegend={true}10/>
Actual vs Target
1<BarChartCard2 title="Monthly Performance"3 code="0x01"4 icon={<BarChart3 className="h-4 w-4 text-primary" />}5 data={data}6 xAxisKey="category"7 series={[{ dataKey: "value", name: "Value" }]}8/>
1<BarChart2 data={data}3 xAxisKey="category"4 series={[{ dataKey: "value", name: "Value" }]}5 horizontal={true}6/>
1<StackedBarChart2 data={data}3 xAxisKey="month"4 stackKeys={["desktop", "mobile", "tablet"]}5 stackLabels={["Desktop", "Mobile", "Tablet"]}6/>
1<BarChart2 data={data}3 xAxisKey="category"4 series={[{ dataKey: "value" }]}5 colorByIndex={true}6/>
| Prop | Type | Default | Description |
|---|---|---|---|
| data* | BarChartDataPoint[] | - | Chart data array. |
| xAxisKey* | string | - | Data key for X-axis (categories). |
| series* | BarChartSeries[] | - | Bar series configuration. |
| height | number | 300 | Chart height in pixels. |
| horizontal | boolean | false | Use horizontal bar layout. |
| showGrid | boolean | true | Show grid lines. |
| showLegend | boolean | false | Show legend. |
| barSize | number | - | Fixed bar width in pixels. |
| barGap | number | 4 | Gap between bars. |
| colorByIndex | boolean | false | Color each bar differently. |