change pie slice color on pie chart - Javascript highcharts

Javascript examples for highcharts:Pie Chart

Description

change pie slice color on pie chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function () {/*from www .ja v a2  s  .c  o m*/
    $('#container').highcharts({
        chart: {
            type: 'pie'
        },
        series: [{
            data: [29.9, 71.5, 106.4],
            dataLabels: {
                format: '{point.y}'
            }
        }]
    });
    // button handler
    var chart = $('#container').highcharts();
    $('#button').click(function () {
        chart.series[0].data[0].update({
            color: 'red'
        });
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container" style="height: 400px"></div> 
      <button id="button" class="autocompare">Update first slice</button>  
   </body>
</html>

Related Tutorials