Sunburst - Default config
Common top nodes + tooltip
by amrutaJgtp
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/sunburst.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container"></div>
CSS
#container {
min-width: 310px;
max-width: 600px;
margin: 0 auto
}
JavaScript
var colors = Highcharts.getOptions().colors;
// Splice in transparent for the center circle
Highcharts.getOptions().colors.splice(0, 0, 'transparent');
Highcharts.chart('container', {
chart: {
height: '100%'
},
title: {
text: 'Sales for Product Category by Region'
},
plotOptions: {
sunburst: {}
},
series: [{
type: "sunburst",
data: [{
id:'11.0'
},{
id: '1.0',
parent: '11.0',
name: 'Furniture',
value: 400,
color: colors[1]
}, {
id: '2.0',
parent: '11.0',
name: 'Technology',
value: 100,
color: colors[2]
}, {
id: '3.0',
parent: '11.0',
name: 'Stationery',
value: 200,
color: colors[3]
}],
allowDrillToNode: true,
cursor: 'pointer',
dataLabels: {
/**
* A custom formatter that returns the name only if the inner arc
* is longer than a certain pixel size, so the shape has place for
* the label.
*/
formatter: function() {
var shape = this.point.node.shapeArgs;
var innerArcFraction = (shape.end - shape.start) / (2 * Math.PI);
var perimeter = 2 * Math.PI * shape.innerR;
var innerArcPixels = innerArcFraction * perimeter;
if (innerArcPixels > 16) {
return this.point.name;
}
}
},
levels: [{
level: 2,
dataLabels: {
rotationMode: 'parallel'
}
}]
}],
tooltip: {
headerFormat: "",
pointFormat: 'Sales:{point.value} [ {point.name} ]'
}
});