Skip to main content

Event Handling

Highcharts provides a comprehensive event system for handling user interactions and chart lifecycle events.

Event Configuration

Events are configured in the events option of chart elements:

Chart Events

Source: ts/Core/Chart/ChartOptions.ts:83

load

Fires when the chart has finished loading.
Context: this = Chart instance

render

Fires after the chart has rendered.

redraw

Fires when the chart is redrawn.

click

Fires when the plot background is clicked.
Event Object:
  • xAxis - Array of axis objects with click coordinates
  • yAxis - Array of axis objects with click coordinates
  • Native DOM event properties

selection

Fires when area is selected (zooming).
Event Object:
  • xAxis[0].min - Selection start
  • xAxis[0].max - Selection end
  • yAxis[0].min/max - Y-axis selection
  • resetSelection - True if reset zoom button was clicked
Return: false to prevent default zoom behavior

addSeries

Fires when a series is added.
Event Object:
  • options - Series options being added
Return: false to prevent adding

beforePrint / afterPrint

Fires before and after the chart is printed.

Axis Events

afterSetExtremes

Fires after axis extremes are set.
Event Object:
  • min - New minimum
  • max - New maximum
  • dataMin - Data minimum
  • dataMax - Data maximum
  • trigger - Event trigger: ‘zoom’, ‘navigator’, etc.

setExtremes

Fires when extremes are being set (before actual change).
Return: false to prevent the change

afterBreaks

Fires after axis breaks are recalculated.

pointBreak

Fires when a point is broken by axis breaks.

Series Events

Source: ts/Core/Series/SeriesOptions.ts:111

click

Fires when the series is clicked.
Event Object:
  • point - Nearest point to click

show / hide

Fires when series is shown or hidden.

legendItemClick

Fires when legend item is clicked.
Return: false to prevent default hide/show

mouseOver / mouseOut

Fires when mouse enters or leaves series.

afterAnimate

Fires after series animation completes.

Point Events

click

Fires when a point is clicked.
Context: this = Point instance

mouseOver / mouseOut

Fires when mouse enters or leaves a point.

select / unselect

Fires when point is selected or unselected.

update

Fires when point is updated.

remove

Fires when point is removed.

drag / drop

Fires when point is dragged (requires draggable-points module).

Event Utilities

addEvent()

Add event listener to chart element.

removeEvent()

Remove event listener.

fireEvent()

Manually fire an event.

Complete Example

See Also