Highcharts点击功能未被调用?

时间:2014-09-26 15:04:25

标签: javascript jquery highcharts coffeescript

我试图动态地将标签添加到highcharts饼图部分,但由于某种原因,点击事件似乎没有触发。我有什么想法,或者如何让控制台消息退出?这是我关注的Highcharts documentation链接。

$('#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"
            }
          ]
        }]
      })

1 个答案:

答案 0 :(得分:1)

您使用的是错误的事件。使用这个:

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
        }
    }
},