Pie with Drilldown
Pet Preference with Drilldown Breeds
by Emre Bolat
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
<div id="container" style="min-width: 310px; max-width: 600px; height: 400px; margin: 0 auto"></div>
JavaScript
$(function () {
// Create the chart
$('#container').highcharts({
chart: {
type: 'pie'
},
title: {
text: 'Pet Preference'
},
subtitle: {
text: 'Click the slices to view breeds.'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{point.name}: {point.y:.1f}%'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},
series: [{
name: 'Pets',
colorByPoint: true,
data: [{
name: 'Cats',
y: 56.33,
drilldown: 'Cats'
}, {
name: 'Dogs',
y: 24.03,
drilldown: 'Dogs'
}, {
name: 'Bunnies',
y: 10.38,
drilldown: 'Bunnies'
}, {
name: 'Fish',
y: 4.77,
drilldown: 'Fish'
}, {
name: 'Hamsters',
y: 0.91,
drilldown: 'Hamsters'
}, {
name: 'Ferrets',
y: 0.2,
drilldown: null
}]
}],
drilldown: {
series: [{
name: 'Cats',
id: 'Cats',
data: [
['Persian', 1.18],
['Siamese', 15.5],
['Ragdoll', 8.15],
['American Shorthair', 3.73],
['Oriental', 4.22],
['Maine Coon', 7.05]
]
}, {
name: 'Dogs',
id: 'Dogs',
data: [
...