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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#Negative Values

Bars extend below the zero line for negative values. Pass a function to color to color positive and negative bars differently.

Loading Demo...

#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'.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

#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.

Loading Demo...

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.

Loading Demo...

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.

Loading Demo...

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.

Loading Demo...

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.

Loading Demo...
Loading Demo...

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.

Loading Demo...

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.

Loading Demo...

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.

Loading Demo...

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.

Loading Demo...

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.

PropTypeDefaultDescription
dataT[]-Data array. Mutually exclusive with ChartItem children
categoryXFieldaccessor → string'category'Category field for the X axis (vertical bars). Use categoryYField for horizontal bars
categoryYFieldaccessor → string-Category field for the Y axis (horizontal bars). Use instead of categoryXField to render bars horizontally
valueYFieldaccessor → number'value'Value field for the Y axis (vertical bars). Use valueXField for horizontal bars
valueXFieldaccessor → number-Value field for the X axis (horizontal bars). Use with categoryYField
coloraccessor → FillValuedefault paletteBar fill color. Static color, per-item array (cycles by index), field name, or callback
opacityaccessor → number1Bar fill opacity in [0, 1]. Per-bar via array/callback/field-name. Multiplies into hover/dim effects
namestring-Series name, used in legend and tooltip
keyFieldstring-Field name for stable item identity. Used for animation matching when data is reordered
idstringautoUnique dataset identifier
barThicknessnumber-Fixed bar thickness in pixels. Overrides auto-calculated width
maxBarThicknessnumber-Maximum bar width cap (px). Ignored when barThickness is set
minBarLengthnumber-Minimum bar length (px). Ensures very small values remain visible
barGap0–10.02Gap between bars within a group, as a fraction of the category band width
categoryGap0–10.1Gap 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
borderRadiusaccessor → BorderRadius0Corner radius. Number, { topLeft, topRight, bottomLeft, bottomRight }, per-item array, or callback
borderStrokeWidthaccessor → number-Border stroke width (px)
borderColoraccessor → FillValue-Border stroke color
borderDashaccessor → number[]-Dash pattern [dashLength, gapLength]. Also accepts named shortcuts ('solid', 'dashed', 'dotted', 'dashdot', 'longdash')
borderDashOffsetaccessor → number0Offset 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
borderSkippedaccessor → (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
hoverColoraccessor → FillValue-Per-bar fill color on hover. Short-circuits the global ChartHover.brightness cascade
hoverBorderColoraccessor → FillValue-Per-bar border color on hover
openFieldaccessor → 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
weightFieldaccessor → 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
connectNullsboolean | '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
xAxisIdstring-Bind to a specific X-axis by ID
yAxisIdstring-Bind to a specific Y-axis by ID
ordernumberautoStacking 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.

FieldTypeDescription
datumTOriginal data row
valuenumber | nullResolved numeric value (when applicable)
indexnumberPosition within the dataset
seriesIndexnumberOrder of this series within the chart
seriesIdstringDataset id
categorystring?Resolved category label, when applicable

#BarShapeInfo

FieldTypeDescription
xnumberBar x position
ynumberBar y position. Top of bar for positive values
widthnumberBar width in pixels
heightnumberBar height in pixels
valuenumberData value
categorystringCategory label
dataIndexnumberOriginal data index
isNegativebooleanWhether 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.

PropTypeDefaultDescription
mode'normal' | 'percent''normal'normal = absolute values stacked (negative values naturally stack downward). percent = normalized to 100%
gapnumber0Pixel gap between stacked bar segments
idstringautoStack group identifier

#ChartWaterfall

Wrap ChartBar inside ChartWaterfall to create a waterfall chart. Composable with ChartStacked for stacked waterfall charts.

PropTypeDefaultDescription
totalFieldstring-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.

PropTypeDescription
category-xstringX-axis category
value-ynumberY-axis value, bar height
category-ystringY-axis category
value-xnumberX-axis value, bar length
opennumberBar start value, used for floating bars and declarative waterfall charts
colorstringOverride color for this bar
borderRadiusBorderRadiusPer-bar corner radius
borderColorstringPer-bar border color
borderStrokeWidthnumberPer-bar border width