Skip to main content

Axis Class

The Axis class controls the x-axis, y-axis, and other dimensional axes in a chart. Axes handle scaling, labeling, gridlines, and positioning. Source: ts/Core/Axis/Axis.ts:190

Overview

Axes can be accessed through the chart object:

Constructor

Axes are typically created via chart configuration or chart.addAxis(), not directly instantiated.

Properties

axis.chart

Highcharts.Chart
required
The chart instance this axis belongs to

axis.series

Array<Highcharts.Series>
All series associated with this axis

axis.min

number
Current minimum value of the axis

axis.max

number
Current maximum value of the axis

axis.dataMin

number
Minimum value from all series data on this axis

axis.dataMax

number
Maximum value from all series data on this axis

axis.isXAxis

boolean
Whether this is an X axis (true) or Y axis (false)

axis.categories

Array<string>
Category names for categorical axes

axis.options

AxisOptions
required
The axis configuration options

axis.len

number
Length of the axis in pixels

axis.opposite

boolean
Whether the axis is on the opposite side

Methods

axis.setExtremes()

Set the minimum and maximum values of the axis.
number | null
required
New minimum value (null to auto-calculate)
number | null
required
New maximum value (null to auto-calculate)
boolean
default:"true"
Whether to redraw the chart
boolean | AnimationOptions
Animation options
object
Custom event arguments
Fires: setExtremes event Source: Referenced in ts/Core/Axis/AxisOptions.ts:29

axis.update()

Update the axis with new options.
AxisOptions
required
New axis options to merge
boolean
default:"true"
Whether to redraw the chart

axis.setTitle()

Set the axis title.
AxisTitleOptions
required
New title options
boolean
default:"true"
Whether to redraw
Source: Referenced in ts/Core/Axis/AxisOptions.ts:30

axis.setCategories()

Set the categories for a categorical axis.
Array<string>
required
New category names
boolean
default:"true"
Whether to redraw

axis.remove()

Remove the axis from the chart.
boolean
default:"true"
Whether to redraw the chart

axis.addPlotLine()

Add a plot line to the axis.
PlotLineOptions
required
Plot line configuration
Returns: Highcharts.PlotLineOrBand

axis.addPlotBand()

Add a plot band to the axis.
PlotBandOptions
required
Plot band configuration
Returns: Highcharts.PlotLineOrBand

axis.removePlotLine()

Remove a plot line by ID.
string
required
ID of the plot line to remove

axis.removePlotBand()

Remove a plot band by ID.
string
required
ID of the plot band to remove

axis.toValue()

Translate a pixel position to an axis value.
number
required
Pixel position relative to the axis
boolean
Whether coordinates are pane-relative
Returns: number

axis.toPixels()

Translate an axis value to a pixel position.
number
required
The axis value to convert
boolean
Whether to return pane-relative coordinates
Returns: number

axis.getExtremes()

Get the current extremes of the axis.
Returns: Object with min, max, dataMin, dataMax, userMin, userMax

Events

Axis events are configured in the axis options:
Common axis events:
  • afterSetExtremes - After extremes are set
  • setExtremes - When extremes are being set (preventable)
  • afterBreaks - After axis breaks are recalculated
  • pointBreak - When a point is broken by axis breaks

Example: Dynamic Axis Control

Example: Multiple Axes

See Also