HTMLcopy
1
<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
// The data used in this sample can be obtained from the CDN
3
// https://cdn.anychart.com/samples/sunburst-charts/the-population-of-the-europe/data.json
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/sunburst-charts/the-population-of-the-europe/data.json',
6
function (data) {
7
// makes tree from the data for the sample
8
var dataTree = anychart.data.tree(data, 'as-table');
9
10
// create sunburst chart
11
var chart = anychart.sunburst(dataTree);
12
13
// set calculation mode
14
chart.calculationMode('parent-independent');
15
16
// set chart title
17
chart.title('Europe Population');
18
19
// set custom palette
20
chart.palette(['#0288d1', '#d4e157', '#ff6e40', '#f8bbd0']);
21
22
// format chart labels
23
chart
24
.labels()
25
.format('{%Name}\n{%Value}{scale:(1000000)(1)|( mln)}');
26
27
// format chart tooltip
28
chart
29
.tooltip()
30
.format('Population: {%Value}{scale:(1000000)(1)|( mln)}');
31
32
// the fill specified in the data has priority
33
// set point fill
34
chart.fill(function () {
35
return anychart.color.darken(this.parentColor, 0.15);
36
});
37
38
// set container id for the chart
39
chart.container('container');
40
// initiate chart drawing
41
chart.draw();
42
}
43
);
44
});