Use different radius when click a pie slice - Javascript highcharts

Javascript examples for highcharts:Pie Chart

Description

Use different radius when click a pie slice

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div> 
      <script type="text/javascript">
function resizeSlice(point, change) {
  var shape = point.shapeArgs;/*from  www. j a  va 2s  . co m*/
  if (point.graphic) {
    point.graphic.attr({
      r: shape.r + change,
      innerR: shape.innerR - change
    });
  }
}
// Build the chart
Highcharts.chart('container', {
  chart: {
    type: 'pie',
    events: {
      // On window resize, apply change:
      redraw: function() {
        Highcharts.each(this.series[0].points, function(point) {
          resizeSlice(point, point.customResized ? 5 : 0)
        });
      }
    }
  },
  plotOptions: {
    pie: {
      innerSize: '90%',
      cursor: 'pointer',
      dataLabels: {
        enabled: false
      },
      point: {
        events: {
          click: function() {
          console.log(this.series);
          Highcharts.each(this.series.points, function(point) {
            resizeSlice(point, 0)
          });
            var change = 0;
            this.customResized = !this.customResized;
            if (this.customResized) {
              change = 5;
            }
            resizeSlice(this, change);
          }
        }
      }
    }
  },
  series: [{
    data: [3, 4, 5, 6]
  }]
});

      </script>  
   </body>
</html>

Related Tutorials