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.
#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.
#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.
#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.
#Axis Title
Set label to display a title alongside the axis.
#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.
#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.
#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.
#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.
#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.
#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.
#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.
#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.
#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.
#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.
#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.
#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.
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | 'default' | Unique axis identifier. Matched by xAxisId / yAxisId on datasets |
type | 'category' | 'time' | 'linear' | 'logarithmic' | 'category' | Axis scale type |
min | number | Date | string | 'auto' | auto | Fixed axis minimum. Accepts Date or ISO string on time axes |
max | number | Date | string | 'auto' | auto | Fixed axis maximum |
startFromZero | boolean | true for bar, false for line | Force domain to always include zero |
softMin | number | - | Soft minimum. Extends domain only when data minimum exceeds this value |
softMax | number | - | Soft maximum. Extends domain only when data maximum falls below this value |
reversed | boolean | false | Flip axis direction |
label | string | - | Axis title displayed alongside the axis |
tickFormat | Intl.NumberFormatOptions | (value, index?) => string | auto | Tick label formatter. An options object merges over the axis default; a function replaces formatting entirely. |
tickCount | number | auto | Approximate number of ticks |
tickInterval | number | - | Explicit tick step. Bypasses the auto-tick algorithm |
tickRotation | degrees | 0 | Tick label rotation |
tickPosition | 'inside' | 'outside' | 'outside' | Draw tick marks inside or outside the chart area |
tickStyle | TickStyle | (value, index) => TickStyle | - | Tick mark and label styling. Object for uniform, function for per-tick |
autoRotate | boolean | true | Auto-rotate labels when they would overlap. X axes only |
autoRotateAngle | degrees | -45 | Angle used when auto-rotation is triggered |
autoSkip | boolean | true | Auto-skip labels to prevent overlap. Set to false to force all labels visible |
minGridDistance | px | auto | Minimum pixel distance between ticks when autoSkip is on. Computed from the rendered label size when unset; set a number to force fixed spacing |
labelMinSpacing | px | 6 | Minimum pixel gap between adjacent labels after collision resolution |
showFirstLabel | boolean | true | Show the first tick label |
showLastLabel | boolean | true | Show the last tick label |
showLine | boolean | true | Show the axis line |
showTicks | boolean | true | Show tick marks on the axis |
showLabels | boolean | true | Show tick labels on the axis |
visible | boolean | true | Show the entire axis including line, ticks, labels, and gridlines |
color | string | theme | Axis 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) |
gridLines | boolean | auto | Show major gridlines. Enabled on the primary value axis by default; set per-axis to override |
gridColor | string | theme | Major gridline color |
gridStyle | 'solid' | 'dashed' | 'dotted' | 'solid' | Major gridline dash style |
gridStrokeWidth | number | 1 | Major gridline stroke width |
gridOpacity | 0–1 | 1 | Major gridline opacity |
minorGridLines | boolean | false | Show minor gridlines between major ticks |
minorGridColor | string | same as gridColor | Minor gridline color |
minorGridStrokeWidth | number | 0.5 | Minor gridline stroke width |
minorGridOpacity | 0–1 | 0.15 | Minor gridline opacity |
minorGridCount | number | 4 | Number of minor subdivisions between major ticks |
minorGridStyle | 'solid' | 'dashed' | 'dotted' | 'solid' | Minor gridline dash style |
minorTicks | boolean | false | Show minor tick marks at minor grid positions |
minorTickLength | px | 3 | Minor tick mark length |
minorTickColor | string | axis color | Minor tick mark color |
minorTickStrokeWidth | number | 1 | Minor tick mark stroke width |
alternateGridColor | string | - | Fill color for alternating bands between grid lines |
alternateGridOpacity | 0–1 | 0.05 | Alternating band fill opacity |
gapless | boolean | false | Ordinal mode. Maps time data to ordinal indices, skipping gaps (financial data) |
grouping | DataGroupingConfig | - | Aggregate large datasets by time interval |
timezone | string | 'UTC' | IANA timezone for time axis labels (e.g. 'America/New_York') |
dateTimeFormats | DateTimeFormatConfig | - | Per-unit date format overrides for time axes |
tickConfig | TimeTickConfig | - | Time tick configuration: forced interval, minimum spacing |
minUnit | TimeUnit | - | Minimum time unit for zoom depth. Prevents zooming below this granularity |
chartPaddingMin | number | 0.05 category, 0 continuous/heatmap | Edge 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 |
chartPaddingMax | number | 0.05 category, 0 continuous/heatmap | Edge 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.
| Field | Type | Default | Description |
|---|---|---|---|
fontSize | number | 12 | Tick label font size |
fontFamily | string | 'system-ui, sans-serif' | Tick label font family |
fontWeight | 'normal' | 'bold' | number | 'normal' | Tick label font weight |
color | string | theme | Tick label text color |
padding | px | 8 | Gap between the tick mark end and the label text |
tickLength | px | 6 | Tick mark length |
tickColor | string | axis color | Tick mark color |
tickStrokeWidth | number | 1 | Tick mark stroke width |
#AxisTickRenderContext
Passed to the render callback for each tick label.
| Field | Type | Description |
|---|---|---|
value | string | number | Date | The raw tick value |
label | string | Formatted label text from tickFormat or auto-format |
index | number | Tick index (0-based) |
position | 'top' | 'bottom' | 'left' | 'right' | Axis position |
x | number | Pixel X coordinate of the tick |
y | number | Pixel Y coordinate of the tick |
ctx | CanvasRenderingContext2D | undefined | Canvas context. Present only in Canvas mode |
drawImage | function | undefined | Draw an image at a URL. Canvas mode only |
animate | function | undefined | Register a continuous animation. Canvas mode only |
#ChartAxisGroup
Nest inside ChartXAxis or ChartYAxis to add group headers to the category axis.
| Prop | Type | Description |
|---|---|---|
label | string | Group header label |
categories | string[] | 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 |
labelStyle | PartitionLabelStyle | Font size, weight, family, and color for this group's label |
bracket | boolean | BracketStyle | Bracket line below the group label. true for defaults |
separator | boolean | SeparatorStyle | Vertical separator line at group boundaries. true for defaults |
fill | boolean | PartitionFillStyle | Alternating background fill for this group's region. true for defaults |
tickSeparator | boolean | SeparatorStyle | Separator lines between individual ticks within this group |
render | (context: AxisGroupRenderContext) => unknown | Custom 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.
| Prop | Type | Description |
|---|---|---|
value | string | number | Category 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.
| Field | Type | Description |
|---|---|---|
label | string | Group label text |
x | number | Pixel X coordinate of the label center |
y | number | Pixel Y coordinate of the label center |
categories | string[] | Category values in this group |
depth | number | Nesting depth. 0 = outermost parent, higher = closer to axis |
ctx | CanvasRenderingContext2D | undefined | Canvas context. Present only in Canvas mode. Pre-translated to (x, y), draw at origin |