Pie Chart Demo

Pet Preferences

by Emre Bolat

HTML

<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>

JavaScript

$(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false,
            type: 'pie'
        },
        title: {
            text: 'Pet Preferences'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                }
            }
        },
        series: [{
            name: 'Brands',
            colorByPoint: true,
            data: [{
                name: 'Cats',
                y: 39.38
            }, {
                name: 'Dogs',
                y: 35.12,
                sliced: true,
                selected: true
            }, {
                name: 'Bunnies',
                y: 15.02
            }, {
                name: 'Fish',
                y: 5.33
            }, {
                name: 'Hamsters',
                y: 3.29
            }, {
                name: 'Ferrets',
                y: 1.83
            }]
        }]
    });
});