Charts - Column & Bar
Vertical columns, horizontal bars, grouped, stacked, waterfall, and custom-shaped bar charts.
#Usage
import { ChartBar, ChartCanvas, ChartItem, ChartOverlap, ChartStacked, ChartSvg, ChartWaterfall, ChartXAxis, ChartYAxis } from '@primeui/vue-chart';<ChartSvg>
<!-- or <ChartCanvas> -->
<ChartBar :data="data" category-x-field="categoryXField" value-y-field="valueYField" />
<ChartXAxis />
<ChartYAxis />
</ChartSvg>Bar charts compare categories by length and work well for rankings, period breakdowns, and distributions. Data and styling live on ChartBar; axes frame the scale. Wrapper components like ChartStacked, ChartWaterfall, and ChartOverlap add composite behavior without changing the bar's own props.
#Basic
Set categoryXField and valueYField to bind data. Add ChartXAxis and ChartYAxis for axes and gridlines.
#Colors
Pass an array to color to assign a custom palette. Bars cycle through colors by index. For conditional coloring, pass a function that receives each data item and returns a color string.
#Gradient Color
Pass a linear gradient object to the color prop to apply a gradient fill across all bars. For per-bar gradients, pass an array of gradient objects to color.
#Grouped
Place multiple ChartBar components as siblings. Each series positions itself within the category group. barGap and categoryGap both accept a fraction between 0 and 1, relative to the category band width.
#Horizontal
Bind categoryYField and valueXField instead of categoryXField and valueYField to render bars horizontally. The category axis moves to Y, which keeps long labels readable without rotation.
#Sorted
Set sort to reorder bars before rendering. value-desc places the highest value first; value-asc reverses it. label-asc and label-desc sort alphabetically by category name. For multi-series charts, sortAggregate controls how series values combine to determine rank. The default is sum.
#Negative Values
Bars extend below the zero line for negative values. Pass a function to color to color positive and negative bars differently.
#Null Values
By default, null values leave an empty category slot with no bar drawn ('gap'). Set connectNulls="zero" to treat nulls as zero and draw a bar at the baseline instead. Unlike line charts, there is no path-bridging mode for bars. 'connect' behaves the same as 'zero'.
#Floating / Range
Set openField to anchor each bar at a specific starting value instead of zero. The bar spans from openField to valueYField. This is the standard approach for Gantt-style timelines and range charts.
#Variwide
Set weightField to a numeric data field to make each bar's width proportional to that value. Wider bars represent larger weight values. Useful for Marimekko charts where two dimensions are encoded at once.
#Custom Shape
Set renderShape to replace the default rectangle with a custom SVG path. The callback receives the computed bar geometry (x, y, width, height, value, category, dataIndex, and isNegative) and returns an SVG path d string. Works in both SVG and Canvas renderers via Path2D.
#Border
Set borderStrokeWidth and borderColor to stroke each bar. borderRadius rounds the corners: pass a number for uniform rounding or { topLeft, topRight, bottomLeft, bottomRight } for per-corner control. Use borderDash for a dashed stroke and borderSkipped to drop the border on specific edges.
#Bar Sizing
Set barThickness to fix bar width in pixels. maxBarThickness caps the auto-calculated width when the chart is wide. minBarLength ensures bars for very small values stay visible. Use categoryGap to control spacing between groups.
#Stacked
Wrap multiple ChartBar components inside ChartStacked to stack bars vertically. Each series accumulates on top of the previous one. Negative values stack downward from zero.
#Percent Stacked
Set mode="percent" on ChartStacked to normalize each category to 100%. The axis always spans 0–100% regardless of the underlying data magnitude.
#Waterfall
Wrap ChartBar inside ChartWaterfall to create a waterfall chart. Each bar floats from the running total of previous values. Set totalField to a boolean field on the data items to mark summary bars. Total bars reset from zero and display the cumulative sum.
#Overlap
Wrap multiple ChartBar components inside ChartOverlap to layer bars at the same category position. The first child renders widest at the back, the last renders narrowest at the front. This creates target vs. actual comparisons without side-by-side grouping.
#Declarative
Define bars inline using ChartItem children instead of a data array. Each ChartItem accepts category-x and value-y, or category-y and value-x for horizontal bars, and optionally open for floating bar definitions.
#Title & Caption
Add ChartTitle to display a title above the chart and ChartCaption for a descriptive line beneath it. Adding both reduces the available chart area.
For full configuration see Title & Caption.
#Hover
ChartHover brightens the hovered bar while the rest stay at normal opacity. Category snapping keeps the selected category obvious when the chart is dense.
For full configuration see Hover.
#Tooltip
Add ChartTooltip to show data details on hover. Shared tooltips are useful when grouped bars compare values at the same category.
For full configuration see Tooltip.
#Legend
Add ChartLegend to display an interactive legend. Use a legend when grouped, stacked, overlap, or percent-stacked bars need series toggles.
For full configuration see Legend.
#Axes
Use label on ChartXAxis and ChartYAxis to add axis titles. Use a secondary Y axis when mixed units would otherwise flatten one series. Reverse the value axis for depth, ranking, or scorecards where the visual direction has domain meaning.
For full configuration see Axes.
#Data Labels
Add ChartDataLabels to display values on each bar. Label bars when the exact value is the point of the chart. Dense rankings and stacked segments usually read better with tooltip access.
For full configuration see Data Labels.
#Zoom & Navigator
Add ChartZoom and ChartNavigator to control a category window when the chart has more bars than can be read at once.
For full configuration see Zoom & Pan and Navigator.
#Annotation
Use ChartAnnotation to render custom content overlaid on the chart area. Use for targets, capacity limits, and callouts tied to category groups or value thresholds.
For full configuration see Annotation.
#Reference Lines & Bands
Add ChartReferenceLine for threshold and divider lines. Add ChartReferenceBand to highlight value ranges such as targets, capacity limits, or threshold zones.
For full configuration see Reference Lines & Bands.
#Animation
Pass the chart-root animation prop to control entrance and update transitions. Bars create one mark per category, so large category sets often benefit from Canvas rendering.
For full configuration see Animation.
#Export
Add ChartExportMenu to let users download the chart as PNG, SVG, or PDF.
See Export for format options and programmatic export.
#Responsive
See Responsive for container sizing, aspect ratio, and breakpoint configuration.
#Accessibility
See Accessibility for ARIA labels, keyboard navigation, and screen reader support.
#API
#ChartBar
Visual styling props with type accessor → R accept a static value, a per-item array, a field name (keyof T), or a callback (ctx: ItemContext<T>) => R | undefined. Color-family arrays cycle modulo length; other accessor arrays clip and fall back to the series default.
| Prop | Type | Default | Description |
|---|---|---|---|
data | T[] | - | Data array. Mutually exclusive with ChartItem children |
categoryXField | accessor → string | 'category' | Category field for the X axis (vertical bars). Use categoryYField for horizontal bars |
categoryYField | accessor → string | - | Category field for the Y axis (horizontal bars). Use instead of categoryXField to render bars horizontally |
valueYField | accessor → number | 'value' | Value field for the Y axis (vertical bars). Use valueXField for horizontal bars |
valueXField | accessor → number | - | Value field for the X axis (horizontal bars). Use with categoryYField |
color | accessor → FillValue | default palette | Bar fill color. Static color, per-item array (cycles by index), field name, or callback |
opacity | accessor → number | 1 | Bar fill opacity in [0, 1]. Per-bar via array/callback/field-name. Multiplies into hover/dim effects |
name | string | - | Series name, used in legend and tooltip |
keyField | string | - | Field name for stable item identity. Used for animation matching when data is reordered |
id | string | auto | Unique dataset identifier |
barThickness | number | - | Fixed bar thickness in pixels. Overrides auto-calculated width |
maxBarThickness | number | - | Maximum bar width cap (px). Ignored when barThickness is set |
minBarLength | number | - | Minimum bar length (px). Ensures very small values remain visible |
barGap | 0–1 | 0.02 | Gap between bars within a group, as a fraction of the category band width |
categoryGap | 0–1 | 0.1 | Gap between category groups, as a fraction of the category band width |
sort | 'value-asc' | 'value-desc' | 'label-asc' | 'label-desc' | - | Bar ordering before render |
sortAggregate | 'sum' | 'max' | 'min' | 'first' | 'sum' | How multi-series values are combined when sorting by value. Only used when sort is set |
borderRadius | accessor → BorderRadius | 0 | Corner radius. Number, { topLeft, topRight, bottomLeft, bottomRight }, per-item array, or callback |
borderStrokeWidth | accessor → number | - | Border stroke width (px) |
borderColor | accessor → FillValue | - | Border stroke color |
borderDash | accessor → number[] | - | Dash pattern [dashLength, gapLength]. Also accepts named shortcuts ('solid', 'dashed', 'dotted', 'dashdot', 'longdash') |
borderDashOffset | accessor → number | 0 | Offset for the dash pattern |
borderJoinStyle | 'round' | 'bevel' | 'miter' | 'miter' | How border segments connect at bar corners |
borderAlign | 'center' | 'inner' | 'center' | Border alignment relative to the bar edge |
borderSkipped | accessor → (false | 'start' | 'end' | 'top' | 'bottom' | 'left' | 'right') | - | Which bar edge(s) skip the border stroke. Orientation-aware: 'start' is always the baseline edge. Per-bar via array/callback enables waterfall/floating-bar effects |
hoverColor | accessor → FillValue | - | Per-bar fill color on hover. Short-circuits the global ChartHover.brightness cascade |
hoverBorderColor | accessor → FillValue | - | Per-bar border color on hover |
openField | accessor → number | - | Start value for floating/range bars. Bar spans from openField to valueYField. Named openField to match the shared ChartItem interface (same field used for candlestick open price), but semantically means "bar base value" in this context |
weightField | accessor → number | - | Proportional bar width field. Creates Variwide/Marimekko charts |
renderShape | (bar: BarShapeInfo) => string | - | Custom shape per bar. Receives computed geometry, returns an SVG path d string. Works in both SVG and Canvas via Path2D |
connectNulls | boolean | 'gap' | 'connect' | 'zero' | 'gap' | Null value handling. false/'gap' = category slot preserved but no bar drawn (default). 'zero'/'connect'/true = treat null as zero and draw at baseline. For line-specific bridging behavior, see Line & Area |
xAxisId | string | - | Bind to a specific X-axis by ID |
yAxisId | string | - | Bind to a specific Y-axis by ID |
order | number | auto | Stacking order within ChartStacked. 0 = bottom of stack. No effect outside a stacked context |
#ItemContext
Passed to every accessor → R callback. Return undefined to fall back to the series-level default for that item.
| Field | Type | Description |
|---|---|---|
datum | T | Original data row |
value | number | null | Resolved numeric value (when applicable) |
index | number | Position within the dataset |
seriesIndex | number | Order of this series within the chart |
seriesId | string | Dataset id |
category | string? | Resolved category label, when applicable |
#BarShapeInfo
| Field | Type | Description |
|---|---|---|
x | number | Bar x position |
y | number | Bar y position. Top of bar for positive values |
width | number | Bar width in pixels |
height | number | Bar height in pixels |
value | number | Data value |
category | string | Category label |
dataIndex | number | Original data index |
isNegative | boolean | Whether the value is negative |
#ChartStacked
Wrap ChartBar children inside ChartStacked to stack bars. Without this wrapper, multiple ChartBar components render as grouped side-by-side bars.
| Prop | Type | Default | Description |
|---|---|---|---|
mode | 'normal' | 'percent' | 'normal' | normal = absolute values stacked (negative values naturally stack downward). percent = normalized to 100% |
gap | number | 0 | Pixel gap between stacked bar segments |
id | string | auto | Stack group identifier |
#ChartWaterfall
Wrap ChartBar inside ChartWaterfall to create a waterfall chart. Composable with ChartStacked for stacked waterfall charts.
| Prop | Type | Default | Description |
|---|---|---|---|
totalField | string | - | Field name that resolves to true for summary bars. Total bars reset from zero and display the cumulative sum |
#ChartOverlap
Wrap multiple ChartBar components inside ChartOverlap to layer them at the same category position. No configuration required. Render order determines depth: first child renders widest (background), last child renders narrowest (foreground).
#ChartItem
Use ChartItem as children of ChartBar instead of a data array for inline bar definitions.
| Prop | Type | Description |
|---|---|---|
category-x | string | X-axis category |
value-y | number | Y-axis value, bar height |
category-y | string | Y-axis category |
value-x | number | X-axis value, bar length |
open | number | Bar start value, used for floating bars and declarative waterfall charts |
color | string | Override color for this bar |
borderRadius | BorderRadius | Per-bar corner radius |
borderColor | string | Per-bar border color |
borderStrokeWidth | number | Per-bar border width |