admin管理员组

文章数量:1303452

I am working with HighChart Plugin to draw piecharts/Bar Graphs. While clicking the pie-chart parts I want to link other pages or in other words i want to redirect to other page.

Demo Link:

$(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]
            ]
        }]
    });
});

Fiddle Link: /

They are not passing ID for the Parts so I am not able to write any event for the pie-chart parts.

I am working with HighChart Plugin to draw piecharts/Bar Graphs. While clicking the pie-chart parts I want to link other pages or in other words i want to redirect to other page.

Demo Link: http://www.highcharts./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]
            ]
        }]
    });
});

Fiddle Link: http://jsfiddle/aravindkumarit/M8a3X/

They are not passing ID for the Parts so I am not able to write any event for the pie-chart parts.

Share Improve this question asked Oct 16, 2013 at 9:10 DonOfDenDonOfDen 4,10812 gold badges69 silver badges114 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Add

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

in plotOptions.pie

like this

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

SEE DEMO

本文标签: javascriptNeed to link URL in HighChartStack Overflow