Skip to main content

Chart Class

The Chart class is the main entry point for creating and managing Highcharts visualizations. It controls rendering, updates, and lifecycle management. Source: ts/Core/Chart/Chart.ts:285

Constructor

Highcharts.Chart()

Creates a new chart instance.
string | HTMLElement
The DOM element to render to, or its id
Highcharts.Options
required
The chart configuration object
Function
Function to run when the chart has loaded. Equivalent to chart.events.load

Static Methods

Highcharts.chart()

Factory function for creating basic charts (recommended approach).
Returns: Highcharts.Chart Source: ts/Core/Chart/Chart.ts:333

Properties

chart.axes

Array<Highcharts.Axis>
required
All axes in the chart (xAxis, yAxis, colorAxis, etc.)

chart.series

Array<Highcharts.Series>
required
All series in the chart

chart.xAxis

Array<Highcharts.Axis>
All x-axes in the chart

chart.yAxis

Array<Highcharts.Axis>
All y-axes in the chart

chart.container

HTMLElement
required
The HTML container element

chart.chartWidth

number
required
Current pixel width of the chart

chart.chartHeight

number
required
Current pixel height of the chart

chart.options

Highcharts.Options
required
Current chart configuration options

chart.index

number
required
Position in the Highcharts.charts array

Methods

chart.addSeries()

Add a new series to the chart after render time.
SeriesOptions
required
Series configuration object
boolean
default:"true"
Whether to redraw the chart after adding
boolean | AnimationOptions
Animation options for the series
Returns: Highcharts.Series

chart.addAxis()

Add a new axis to the chart after render time.
AxisOptions
required
Axis configuration object
boolean
default:"false"
Whether it’s an X axis (true) or Y axis (false)
boolean
default:"true"
Whether to redraw the chart
Returns: Highcharts.Axis

chart.get()

Get an axis, series, or point object by ID.
string
required
The ID of the object to find
Returns: Highcharts.Axis | Highcharts.Series | Highcharts.Point | undefined

chart.update()

Update the chart options after initialization.
Highcharts.Options
required
New chart options to merge
boolean
default:"true"
Whether to redraw the chart
boolean
default:"false"
Whether to update one-to-one or recursively merge
boolean | AnimationOptions
Animation configuration

chart.redraw()

Redraw the chart after changes have been made.
boolean | AnimationOptions
Animation options

chart.reflow()

Reflow the chart to fit the container size.

chart.setSize()

Resize the chart to specific dimensions.
number | null
New width in pixels (null to maintain current)
number | null
New height in pixels (null to maintain current)
boolean | AnimationOptions
Animation configuration

chart.setTitle()

Set the chart title and subtitle.
TitleOptions
New title options
SubtitleOptions
New subtitle options
boolean
default:"true"
Whether to redraw

chart.showLoading()

Display a loading indicator.
string
Custom loading message

chart.hideLoading()

Hide the loading indicator.

chart.destroy()

Destroy the chart and free resources.

chart.zoomOut()

Zoom out from a zoomed chart.
Source: ts/Core/Chart/ChartBase.ts:163

chart.showResetZoom()

Display the zoom reset button. Source: ts/Core/Chart/ChartBase.ts:156

Events

Chart events are configured in the chart.events option:
See Events API for complete event documentation.

Example: Complete Chart Lifecycle

See Also