Skip to main content

Event handling

Attach event listeners​

Use the chart.events.on() method to attach event listeners:

chart.events.on("resize", function({ width, height }){
console.log("The size of the chart has changed");
});

Related sample: Chart. Events

Detach event listeners​

The chart.events.detach() method removes a listener:

chart.events.on("resize", function({ width, height }){
console.log("The size of the chart has changed");
});

chart.events.detach("resize");

Trigger events​

Call chart.events.fire() to trigger an event manually:

chart.events.fire("name",args);
// where args is an array of arguments

Event list​

For the full event list, see the API section.