Highcharts test tool

by Pranav Kulkarni

HTML

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

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

JavaScript

// Format all percentage values with two decimals
(function() {
    var uberTranslate = Highcharts.seriesTypes.pie.prototype.translate;
    Highcharts.seriesTypes.pie.prototype.translate = function() {
        
        uberTranslate.apply(this, arguments);
        
        var points = this.points,
            i = points.length;
    
        while (i--) {
            points[i].percentage = Highcharts.numberFormat(points[i].percentage, 2);
        }
    };
    
}());
        


// Create the chart
var chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container',
        type: 'pie'
    },
    
    tooltip: {
        pointFormat: '<strong>{point.percentage}</strong>'
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]

});