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
3
// set the data
4
var data = [
5
{x: '达到报废条件', value: 721, exploded: true},
6
{x: '未达到报废条件', value: 534},
7
];
8
var labels = chart.labels();
9
labels.fontColor('white');
10
labels.fontFamily('Arial');
11
labels.fontSize(30);
12
13
var legend = chart.legend();
14
legend.fontColor('black');
15
legend.fontFamily('yahei');
16
legend.fontSize(20);
17
18
// create the chart
19
var chart = anychart.pie();
20
21
// set the chart title
22
chart.title(' ');
23
24
// add the data
25
chart.data(data);
26
27
// sort elements
28
chart.sort('desc');
29
30
// set legend position
31
chart.legend().position('right');
32
// set items layout
33
chart.legend().itemsLayout('vertical');
34
35
// display the chart in the container
36
chart.container('container');
37
chart.draw();
38
});