Charts - Axes

Configure X and Y axes with full control over type, title, tick formatting, grid lines, domain, scale, grouping, and multi-axis layouts.

#Usage

import { ChartAxisCategory, ChartAxisGroup, ChartSvg, ChartXAxis, ChartYAxis } from '@primeui/vue-chart';
<ChartSvg>
    <!-- series -->
    <ChartXAxis />
    <ChartYAxis />
</ChartSvg>

Axes are opt-in children of the chart root. Add ChartXAxis for horizontal labels and gridlines, ChartYAxis for vertical. Both default to a category axis with auto-calculated ticks. Place multiple ChartYAxis components with unique id values for multi-axis layouts.

#Basic

Add ChartXAxis and ChartYAxis to render axes and gridlines. Both default to a category axis with auto-calculated tick labels and a linear scale.

Loading Demo...

#Time Axis

Set type="time" on ChartXAxis to enable continuous date and timestamp parsing. Tick labels format themselves based on the visible range: seconds and minutes for short ranges, hours and days for medium ranges, months and years for long ranges. Pass Unix timestamps, JavaScript Date objects, or ISO date strings as category values.

Loading Demo...

#Linear Axis

Set type="linear" on ChartXAxis to treat category values as continuous numbers rather than discrete labels. Use this for numeric X/Y scatter data where the X axis represents a continuous numeric dimension.

Loading Demo...

#Logarithmic

Set type="logarithmic" on ChartYAxis to use a log scale. Each tick represents a power of ten. Use this for data spanning multiple orders of magnitude. Also supported on ChartXAxis for horizontal bar charts.

Loading Demo...

#Axis Title

Set label to display a title alongside the axis.

Loading Demo...

#Tick Formatting

Set tickFormat to a function (value, index) => string to customize how tick values are displayed. Use this for currency, percentages, units, and abbreviated large numbers. Set tickInterval to force a specific step between ticks instead of the auto-calculated interval.

Loading Demo...

#Tick Styling

Use tickStyle to customize tick mark and label appearance. Pass an object for uniform styling across all ticks, or a function (value, index) => TickStyle for per-tick styling. The function form allows specific values to be highlighted. Set tickRotation to rotate labels, or use autoRotate to let the chart rotate them when they would otherwise overlap.

Loading Demo...

#Grid Lines

Set gridLines to false to hide major gridlines. Use gridColor, gridStrokeWidth, gridStyle, and gridOpacity to customize their appearance. Set minorGridLines to show additional grid lines between major ticks. Use alternateGridColor to fill alternating bands between grid lines.

Loading Demo...

#Domain

Set min and max to fix the axis domain. Set startFromZero to force the axis to always include zero. Use softMin and softMax as soft limits. They extend the domain only when the data doesn't already reach those values, which prevents unwanted whitespace.

Loading Demo...

#Reversed

Set reversed to flip the axis direction. On ChartYAxis, higher values appear at the bottom, which is the natural direction for depth or ranking data. On ChartXAxis, categories run right to left.

Loading Demo...

#Hidden Axis

Set visible to false to hide the entire axis including labels, ticks, the axis line, and gridlines. To hide individual parts while keeping the rest, set showLine (axis line), showTicks (tick marks), or showLabels (tick labels) to false.

Loading Demo...

#Custom Tick Render

Set render to replace default tick labels with custom content. The callback receives the tick value, formatted label, pixel position, and index. In SVG mode return a VNode. In Canvas mode draw to ctx and return null. Use renderTick to replace the tick mark itself independently.

Loading Demo...

#Axis Grouping

Nest ChartAxisGroup inside ChartXAxis or ChartYAxis to add category group headers below the tick labels. Each group takes a label and lists the categories it spans, given either as a categories prop or as nested ChartAxisCategory children. Nest multiple ChartAxisGroup components for multi-level grouping. Depth increases from outermost to innermost. Use bracket, separator, fill, and tickSeparator to add visual dividers between groups. A range prop, or two numeric ChartAxisCategory children, instead defines a value range group across [from, to]. Axis groups apply to bar, line, scatter, and candlestick series on a category axis.

Loading Demo...

#Multiple Axes

Add multiple ChartYAxis components with unique id values to create independent Y scales. Bind each dataset to its axis using yAxisId. Set position="right" on the secondary axis to render it on the opposite side.

Loading Demo...

#Time Zone

Set timezone on a time axis to display tick labels in a specific IANA timezone instead of UTC. Use dateTimeFormats to override how each time unit (second, minute, hour, day, month, year) is formatted.

Loading Demo...

#Data Grouping

Set grouping on a time axis to aggregate large datasets by time interval. The aggregation runs before the renderer, reducing years of data to a manageable density without rendering thousands of individual points.

Loading Demo...

#API

#ChartXAxis

Extends BaseAxisProps with position: 'top' | 'bottom' (default 'bottom').

#ChartYAxis

Extends BaseAxisProps with position: 'left' | 'right' (default 'left').

#BaseAxisProps

All props are shared by both ChartXAxis and ChartYAxis unless noted.

PropTypeDefaultDescription
idstring'default'Unique axis identifier. Matched by xAxisId / yAxisId on datasets
type'category' | 'time' | 'linear' | 'logarithmic''category'Axis scale type
minnumber | Date | string | 'auto'autoFixed axis minimum. Accepts Date or ISO string on time axes
maxnumber | Date | string | 'auto'autoFixed axis maximum
startFromZerobooleantrue for bar, false for lineForce domain to always include zero
softMinnumber-Soft minimum. Extends domain only when data minimum exceeds this value
softMaxnumber-Soft maximum. Extends domain only when data maximum falls below this value
reversedbooleanfalseFlip axis direction
labelstring-Axis title displayed alongside the axis
tickFormatIntl.NumberFormatOptions | (value, index?) => stringautoTick label formatter. An options object merges over the axis default; a function replaces formatting entirely.
tickCountnumberautoApproximate number of ticks
tickIntervalnumber-Explicit tick step. Bypasses the auto-tick algorithm
tickRotationdegrees0Tick label rotation
tickPosition'inside' | 'outside''outside'Draw tick marks inside or outside the chart area
tickStyleTickStyle | (value, index) => TickStyle-Tick mark and label styling. Object for uniform, function for per-tick
autoRotatebooleantrueAuto-rotate labels when they would overlap. X axes only
autoRotateAngledegrees-45Angle used when auto-rotation is triggered
autoSkipbooleantrueAuto-skip labels to prevent overlap. Set to false to force all labels visible
minGridDistancepxautoMinimum pixel distance between ticks when autoSkip is on. Computed from the rendered label size when unset; set a number to force fixed spacing
labelMinSpacingpx6Minimum pixel gap between adjacent labels after collision resolution
showFirstLabelbooleantrueShow the first tick label
showLastLabelbooleantrueShow the last tick label
showLinebooleantrueShow the axis line
showTicksbooleantrueShow tick marks on the axis
showLabelsbooleantrueShow tick labels on the axis
visiblebooleantrueShow the entire axis including line, ticks, labels, and gridlines
colorstringthemeAxis line, tick marks, title, and label color (unless overridden by tickStyle.color)
scale'band' | 'point''band'Category scale type. Only applies when type is 'category'. band = bar chart style with gaps, point = line chart style with equal spacing. Meaningful on ChartXAxis for vertical charts and on ChartYAxis when the Y axis is the category axis (horizontal bar charts)
gridLinesbooleanautoShow major gridlines. Enabled on the primary value axis by default; set per-axis to override
gridColorstringthemeMajor gridline color
gridStyle'solid' | 'dashed' | 'dotted''solid'Major gridline dash style
gridStrokeWidthnumber1Major gridline stroke width
gridOpacity0–11Major gridline opacity
minorGridLinesbooleanfalseShow minor gridlines between major ticks
minorGridColorstringsame as gridColorMinor gridline color
minorGridStrokeWidthnumber0.5Minor gridline stroke width
minorGridOpacity0–10.15Minor gridline opacity
minorGridCountnumber4Number of minor subdivisions between major ticks
minorGridStyle'solid' | 'dashed' | 'dotted''solid'Minor gridline dash style
minorTicksbooleanfalseShow minor tick marks at minor grid positions
minorTickLengthpx3Minor tick mark length
minorTickColorstringaxis colorMinor tick mark color
minorTickStrokeWidthnumber1Minor tick mark stroke width
alternateGridColorstring-Fill color for alternating bands between grid lines
alternateGridOpacity0–10.05Alternating band fill opacity
gaplessbooleanfalseOrdinal mode. Maps time data to ordinal indices, skipping gaps (financial data)
groupingDataGroupingConfig-Aggregate large datasets by time interval
timezonestring'UTC'IANA timezone for time axis labels (e.g. 'America/New_York')
dateTimeFormatsDateTimeFormatConfig-Per-unit date format overrides for time axes
tickConfigTimeTickConfig-Time tick configuration: forced interval, minimum spacing
minUnitTimeUnit-Minimum time unit for zoom depth. Prevents zooming below this granularity
chartPaddingMinnumber0.05 category, 0 continuous/heatmapEdge padding at the axis minimum side as a fraction of the pixel range (-1..1). Positive adds breathing room, negative clips data at the edge. Heatmap defaults to 0 so its cells fill the plot; set a value to inset the grid
chartPaddingMaxnumber0.05 category, 0 continuous/heatmapEdge padding at the axis maximum side as a fraction of the pixel range (-1..1)
render(context: AxisTickRenderContext) => unknown-Custom tick label renderer
renderTick(context: AxisTickMarkRenderContext) => unknown-Custom tick mark renderer

#TickStyle

Passed to tickStyle as an object or returned from a per-tick function.

FieldTypeDefaultDescription
fontSizenumber12Tick label font size
fontFamilystring'system-ui, sans-serif'Tick label font family
fontWeight'normal' | 'bold' | number'normal'Tick label font weight
colorstringthemeTick label text color
paddingpx8Gap between the tick mark end and the label text
tickLengthpx6Tick mark length
tickColorstringaxis colorTick mark color
tickStrokeWidthnumber1Tick mark stroke width

#AxisTickRenderContext

Passed to the render callback for each tick label.

FieldTypeDescription
valuestring | number | DateThe raw tick value
labelstringFormatted label text from tickFormat or auto-format
indexnumberTick index (0-based)
position'top' | 'bottom' | 'left' | 'right'Axis position
xnumberPixel X coordinate of the tick
ynumberPixel Y coordinate of the tick
ctxCanvasRenderingContext2D | undefinedCanvas context. Present only in Canvas mode
drawImagefunction | undefinedDraw an image at a URL. Canvas mode only
animatefunction | undefinedRegister a continuous animation. Canvas mode only

#ChartAxisGroup

Nest inside ChartXAxis or ChartYAxis to add group headers to the category axis.

PropTypeDescription
labelstringGroup header label
categoriesstring[]Category values this group spans. Equivalent to nested ChartAxisCategory children; the prop takes precedence
range[number, number]Value range [from, to] this group spans on a value axis. Equivalent to two numeric ChartAxisCategory children
labelStylePartitionLabelStyleFont size, weight, family, and color for this group's label
bracketboolean | BracketStyleBracket line below the group label. true for defaults
separatorboolean | SeparatorStyleVertical separator line at group boundaries. true for defaults
fillboolean | PartitionFillStyleAlternating background fill for this group's region. true for defaults
tickSeparatorboolean | SeparatorStyleSeparator lines between individual ticks within this group
render(context: AxisGroupRenderContext) => unknownCustom group label renderer. SVG: return a VNode. Canvas: draw to ctx and return null

Declare group membership either with the categories / range props or with nested ChartAxisCategory children. When both are present, the prop wins.

#ChartAxisCategory

Nest inside ChartAxisGroup to declare which categories the group spans. Renders nothing on its own.

PropTypeDescription
valuestring | numberCategory name to include in the group. Two numeric siblings instead define a [from, to] value range for the group.

#AxisGroupRenderContext

Passed to the render callback on each ChartAxisGroup.

FieldTypeDescription
labelstringGroup label text
xnumberPixel X coordinate of the label center
ynumberPixel Y coordinate of the label center
categoriesstring[]Category values in this group
depthnumberNesting depth. 0 = outermost parent, higher = closer to axis
ctxCanvasRenderingContext2D | undefinedCanvas context. Present only in Canvas mode. Pre-translated to (x, y), draw at origin