Tom Hammond
Tom Hammond

Reputation: 6090

Highcharts Click Function Not Being Called?

I'm trying to dynamically add a label to the highcharts pie section, but for some reason the click event doesn't seem to be triggering. Any ideas what I'm doing wrong/how to get the console message to log out? Here's the link to the Highcharts documentation I was following.

$('#genderChart').highcharts({
        chart: {
          marginTop: 0,
          marginBottom: 73,
          marginRight: 50,
          plotBackgroundColor: null,
          plotBorderWidth: null,
          plotShadow: false,
          events: {
            click: (e) ->
              console.log "click"
          }
        },
        title: {
          text: '',
          style: {
            fontSize: 10
          }
        },
        tooltip: {
          pointFormat: '<b>{point.percentage:.1f}%</b>'
        },
        credits: {
          enabled: false
        },
        exporting: {
          enabled: false
        },
        plotOptions: {
          pie: {
            size: 300,
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
              enabled: false
            },
            showInLegend: true
          }
        },
        series: [{
          type: 'pie',
          name: 'Gender Breakdown',
          data: [
            {
              name: "Male",
              y: male,
              color: "#9A3334"
            },
            {
              name: "Female",
              y: female,
              color: "#217C7E"
            }
          ]
        }]
      })

Upvotes: 0

Views: 741

Answers (1)

Brewal
Brewal

Reputation: 8199

You are using the wrong event. Use this one :

http://api.highcharts.com/highcharts#plotOptions.pie.events.click

plotOptions: {
    pie: {
        size: 300,
        allowPointSelect: true,
        cursor: 'pointer',
        dataLabels: {
            enabled: false
        },
        showInLegend: true,
        events: {
            click: function(e){} // your event
        }
    }
},

Upvotes: 1

Related Questions