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
// create pie chart with passed data
3
var chart = anychart.pie();
4
var data = [
5
['Android', 4.13],
6
['Playstation', 69.17],
7
['Wii', 12],
8
['Xbox', 14.71]
9
]
10
var series = chart.data(data);
11
12
chart.normal().stroke("#ffffff00", 5);
13
14
// change the selected points look
15
series.select([0]);
16
17
// creates palette
18
var palette = anychart.palettes.distinctColors();
19
palette.items([
20
{ color: '#7d9db6'},
21
{ color: 'lightgreen' },
22
{ color: '#f38367' },
23
{ color: '#b97792' }
24
]);
25
26
chart.interactivity().selectionMode("none");
27
28
// set chart radius
29
chart
30
.radius('43%')
31
// create empty area in pie chart
32
.innerRadius('60%')
33
// set chart palette
34
.palette(palette);
35
36
37
// format tooltip
38
chart.tooltip().format('Percent Value: {%PercentValue}%');
39
40
// create standalone label and set label settings
41
var label = anychart.standalones.label();
42
label
43
.enabled(true)
44
.text('Operating System Market\nShare (Console)')
45
.width('100%')
46
.height('100%')
47
.adjustFontSize(true, true)
48
.minFontSize(10)
49
.maxFontSize(25)
50
.fontColor('#60727b')
51
.position('center')
52
.anchor('center')
53
.hAlign('center')
54
.vAlign('middle');
55
56
// set label to center content of chart
57
chart.center().content(label);
58
59
// set container id for the chart
60
chart.container('container');
61
// initiate chart drawing
62
chart.draw();
63
});