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 data = anychart.data.set([
4
['> USD 1 million', 69.2, 24.2],
5
['USD 100,000 to 1 million', 85, 334],
6
['USD 10,000 to 100,000', 32.1, 1045],
7
['< 10,000 USD', 8.2, 3038]
8
]);
9
10
var wealth = data.mapAs({ x: 0, value: 1 });
11
12
var chart = anychart.pie(wealth);
13
chart
14
.labels()
15
.hAlign('center')
16
.position('outside')
17
.format('{%Value} trn.n({%PercentOfCategory}%)');
18
19
// set chart title text settings
20
chart.title('The global wealth pie');
21
22
// set legend title text settings
23
chart
24
.legend()
25
// set legend position and items layout
26
.position('center-bottom')
27
.itemsLayout('horizontal')
28
.align('center');
29
30
// set container id for the chart
31
chart.container('container');
32
// initiate chart drawing
33
chart.draw();
34
});