Highcharts Demo

author(s): Torstein Hønsi

by Ayyoub CHAMMAKH

HTML

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

<div id="container" style="height: 400px; margin-top: 1em"></div>

JavaScript

$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: 'Browser market shares at a specific website, 2010'
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
                }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: false
                    },
                    showInLegend: true
                }
            },
            tooltip:{
                formatter: function(){
                    console.log(this);
                    return '<b>' + this.point.name + ':</b>' + this.y.toFixed(1) + "%"
                }                    
            },
            series: [{
                type: 'pie',
                name: 'Browser share',
                data: [
                    ['Firefox',   37.23],
                    ['IE',       31.3],
                    ['Safari',    15.31],
                    ['Opera',     918.365],
                    ['Others',   36.1]
                ]
            }]
        });
    });    
});