Jugal | Percentage in Pie | Highcharts & Highstock

http://stackoverflow.com/questions/12529934/displaying-percentage-inside-pie-item-for-highcharts http://jugal.me/ Jugal Thakkar

by tin nguyen

HTML

<script src="http://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 400px"></div>

JavaScript

$(function () {
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            type:'pie'
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr']
        },
        
        plotOptions: {
            series: {
                dataLabels: {
                    enabled: true,
                    formatter: function() {
                        return Math.round(this.percentage*100)/100 + ' %';
                    },
                    distance: -30,
                    color:'white'
                }
            }
        },
        
        series: [{
            data: [29.9, 71.5, 106.4, 129.2]        
        }]
    });
});