Channel > Country > Customer Class
by linhpham84
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>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<script src="https://code.highcharts.com/themes/adaptive.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
Sunburst charts are used to visualize hierarchical data in a
circular shape. The inner elements are parent nodes, with
child nodes distributed on the outer rings. Click on a parent
node to drill down and inspect the tree in more detail.
</p>
</figure>
JavaScript
const createChart = data => Highcharts.chart('container', {
chart: {
height: '100%'
},
// Let the center circle be white transparent
colors: ['#ffffff01'].concat(Highcharts.getOptions().colors),
title: {
text: 'Channel > Country > Customer Class'
},
series: [{
type: 'sunburst',
data: data,
name: 'Root',
allowTraversingTree: true,
borderRadius: 3,
cursor: 'pointer',
dataLabels: {
format: '{point.name}'
},
levels: [{
level: 1,
levelIsConstant: false
}, {
level: 2,
colorByPoint: true
},
{
level: 3,
colorVariation: {
key: 'brightness',
to: -1
}
}, {
level: 4,
colorVariation: {
key: 'brightness',
to: 1
}
}]
}],
tooltip: {
headerFormat: '',
pointFormat: '<b>{point.label} {point.name}</b>:<b> ' +
'{point.value}</b>'
}
});
// Define the data
const data = [
{
id: '1',
parent: '',
name: ' '
},
{
id: 'Retail',
parent: '1',
name: 'Retail',
label: 'Channel'
},
{
id: 'Retail.France',
parent: 'Retail',
name: 'France',
label: 'Country'
},
{
id: 'Retail.Germany',
parent: 'Retail',
name: 'Germany',
label: 'Country'
},
{
id: 'null',
parent: '1',
name: 'null',
label: 'Channel'
},
{
id: 'null.France',
parent: 'null',
name: 'France',
label: 'Country'
},
{
id: 'null.Germany',
parent: 'null',
name: 'Germany',
label:...