Sunburst - only level 1 data
Ring chart
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');
var myData = [{
id: '0.0'
}, {
id: 'Consumer',
parent: '0.0',
name: 'Consumer',
color: colors[1],
value: 100
}, {
id: 'Corporate',
parent: '0.0',
name: 'Corporate',
color: colors[2],
value: 200
}, {
id: 'Home office',
parent: '0.0',
name: 'Home office',
color: colors[3],
value: 150
}, {
id: 'Small Business',
parent: '0.0',
name: 'Small Business',
color: colors[4],
value: 220
}];
Highcharts.chart('container', {
chart: {
height: '100%',
type: 'sunburst'
},
title: {
text: 'World population 2017'
},
plotOptions: {
series: {}
},
series: [{
data: myData.slice(),
//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'
}
}, {
level: 3,
colorVariation: {
key: 'brightness',
to: -0.4 //Tells the gradation extent
}
}, {
level: 4,
colorVariation: {
key: 'brightness',
to: 0.5 //Tells the gradation extent
}
}]
}],
tooltip: {
headerFormat: "",
pointFormat: 'The population of <b>{point.name}</b> is <b>{point.value}</b>'
}
});