需要在HighChart中链接URL

Don*_*Den 0 javascript php jquery highcharts

我正在使用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]
            ]
        }]
    });
});
Run Code Online (Sandbox Code Playgroud)

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

它们没有为部件传递ID,因此我无法为饼图部件编写任何事件.

Nit*_*mar 8

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

在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
              }
          }
        }
    }
Run Code Online (Sandbox Code Playgroud)

看看演示