Kevin
Kevin

Reputation: 85

How can I change highcharts events after the chart has been initialized

How can I change highcharts events after the chart has been initialized?

<div id='report'></div>

var chart = $('#container').highcharts({
        chart: {
        },

        xAxis: {
        },

        plotOptions: {
            series: {
                point: {
                    events: {
                        mouseOver: function() {
                            $reporting.html('inner x: '+ this.x +', y: '+ this.y);
                        }
                    }
                },
                events: {
                    mouseOut: function() {                        
                        $reporting.empty();
                    }
                }
            }
        },

        tooltip: {
            enabled: false
        },

        series: [{
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]        
        }]
    });

chart.options.plotOptions.series.point.events.mouseOver = function() {
$('#report').html('outer x: ' + this.x + ', y: ' + this.y);
}

I want to override the mouseOver event as above, but it seems not effected. I'll be very appriciated for anyone could help.

Upvotes: 0

Views: 1756

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

It's not supported to update plotOptions in real time. jsFiddle.

You can update one-series options in that way:

chart.series[0].update({
  point: {
    events: {
      mouseOver: function() {
        $('#report').html('outer x: ' + this.x + ', y: ' + this.y);
      }
    }
  } 
});

Upvotes: 2

Related Questions