HTMLcopy
1
<script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-core.min.js"></script>
2
<script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-sunburst.min.js"></script>
3
<script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-data-adapter.min.js"></script>
4
5
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
anychart.data.loadJsonFile('https://gist.githubusercontent.com/shacheeswadia/3bbe6eb041166e259f1712e6766fa5a2/raw/341d2796dd63e6e6defc1ec52dd4e73c7828c38c/sunburstDataUpdated.json',
3
function (data) {
4
5
// create a data tree from the dataset
6
var dataTree = anychart.data.tree(data);
7
8
// create a sunburst chart
9
var chart = anychart.sunburst(dataTree);
10
11
// set the calculation mode
12
chart.calculationMode('parent-independent');
13
14
// set the ascending sort order
15
chart.sort('asc');
16
17
// set the chart title
18
chart.title("COVID-19 Cases Across the World");
19
20
// enable HTML in labels
21
chart.labels().useHtml(true);
22
// customize the format of the sunburst chart labels
23
chart
24
.level(1)
25
.labels()
26
.fontFamily("Verdana, sans-serif")
27
.format("<span style='font-size:16px'>{%name}</span>");
28
chart
29
.level(0)
30
.labels()
31
.fontFamily("Verdana, sans-serif")
32
.fontWeight(500)
33
.format("<span style='font-size:16px'>TOTAL CASES</span><br><br><span style='font-size:16px'>{%value}{groupsSeparator:\\,}</span>");
34
35
// enable HTML in tooltips
36
chart.tooltip().useHtml(true);
37
// customize the format of the sunburst chart tooltip
38
chart
39
.tooltip()
40
.fontFamily("Verdana, sans-serif")
41
.format("<h5 style='font-size:14px; margin: 0.25rem 0;'>{%name}</h5><h6 style='font-size:14px; font-weight:400; margin: 0.2rem 0;'>Total Cases: <b>{%value}{groupsSeparator:\\,}</b></h6><h6 style='font-size:14px; font-weight:400; margin: 0.2rem 0;'>Total Deaths: <b>{%total_deaths}{groupsSeparator:\\,}</b></h6>");
42
43
// set the chart container element id
44
chart.container('container');
45
46
// initiate chart drawing
47
chart.draw();
48
49
});
50
});