HTMLcopy
1
<script src="https://cdn.anychart.com/releases/8.10.0/js/anychart-core.min.js"></script>
2
<script src="https://cdn.anychart.com/releases/8.10.0/js/anychart-pie.min.js"></script>
3
<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
3
// add data
4
var data = anychart.data.set([
5
['Spotify', 34],
6
['Apple Music', 21],
7
['Amazon Music', 15],
8
['Tencent apps', 11],
9
['YouTube Music', 6],
10
['Others', 13]
11
]);
12
13
// create a pie chart with the data
14
var chart = anychart.pie(data)
15
16
// set the chart radius making a donut chart
17
chart.innerRadius('55%')
18
19
// set the chart title
20
chart.title('Music Streaming Apps Global Market Share');
21
22
// create a color palette
23
var palette = anychart.palettes.distinctColors();
24
25
// set the colors according to the brands
26
palette.items([
27
{ color: '#1dd05d' },
28
{ color: '#000000' },
29
{ color: '#00a3da' },
30
{ color: '#156ef2' },
31
{ color: '#f60000' },
32
{ color: '#96a6a6' }
33
]);
34
35
// apply the donut chart color palette
36
chart.palette(palette);
37
38
// set container id for the chart
39
chart.container('container');
40
41
// initiate chart drawing
42
chart.draw();
43
44
});