0

我正在使用 HighChart 插件来绘制饼图/条形图。在单击饼图部分时,我想链接其他页面,或者换句话说,我想重定向到其他页面。

演示链接:http ://www.highcharts.com/demo/pie-basic

$(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: 'Browser market shares at a specific website, 2010'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                }
            }
        },
        series: [{
            type: 'pie',
            name: 'Browser share',
            data: [
                ['Firefox',   45.0],
                ['IE',       26.8],
                {
                    name: 'Chrome',
                    y: 12.8,
                    sliced: true,
                    selected: true
                },
                ['Safari',    8.5],
                ['Opera',     6.2],
                ['Others',   0.7]
            ]
        }]
    });
});

小提琴链接:http: //jsfiddle.net/aravindkumarit/M8a3X/

他们没有传递零件的 ID,因此我无法为饼图零件编写任何事件。

4

1 回答 1

8

添加

  events:{
      click: function (event) {
                 alert(event.point.name);
              // add your redirect code and u can get data using event.point
     }
 }

在 plotOptions.pie

像这样

 plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                enabled: true,
                color: '#000000',
                connectorColor: '#000000',
                format: '<b>{point.name}</b>: {point.percentage:.1f} %'
            },
            events:{
              click: function (event) {
                  alert(event.point.name);
                  // add your redirect code and u can get data using event.point
              }
          }
        }
    }

演示

于 2013-10-16T09:16:50.577 回答