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/coffee-flavour-wheel/data.json
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/sunburst-charts/coffee-flavour-wheel/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('ordinal-from-root');
15
16
// set chart title
17
chart.title('Coffee Flavour Wheel');
18
19
// set settings for the penultimate level labels
20
chart.level(-2).labels().position('radial');
21
22
// set chart labels settings
23
chart.labels().hAlign('center');
24
25
// set settings for leaves labels
26
chart.leaves().labels().minFontSize(8).textOverflow('...');
27
28
// the fill specified in the data has priority
29
// set point fill
30
chart.fill(function () {
31
return anychart.color.darken(this.parentColor, 0.15);
32
});
33
34
// set container id for the chart
35
chart.container('container');
36
// initiate chart drawing
37
chart.draw();
38
}
39
);
40
});