Using jQuery.on
is a start, it allows us to handle events. However, what if .on()
is too verbose for us? What about handling events on multiple objects?
To set up a basic page and install jQuery and Highcharts, refer to the Getting ready section of the Creating your first chart recipe in Chapter 1, Getting Started with Highcharts.
To get started, perform the following steps:
Define the chart options as shown in the following code:
var options = { /* our chart options */};
Render our chart, maintaining a reference to the chart, as shown in the following code:
var chart = $('#container').highcharts(options).highcharts();
Register a handler as shown in the following code:
$(chart).click(function() { console.log('Our chart has been clicked!'); });
Register a handler using
.on()
as shown in the following code:$(chart.series[0].data[0]).on('mouseOver', function() { console.log('Mouseover on first point!'); });
Register a handler on several...