HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function() {
2
3
// set data and create a pie chart
4
var chart = anychart.pie([
5
["Ash Trees", 138],
6
["Elms", 521],
7
["Maples", 1395],
8
["Oaks", 857],
9
["Pines", 1966],
10
]);
11
12
// get statistical data (the sum of all the values)
13
numberOfTrees = chart.getStat("sum");
14
15
// set the title of the chart
16
chart.title("There Are " + numberOfTrees + " Trees in the Forest");
17
18
// set the container id for the chart
19
chart.container("container");
20
21
// initiate drawing the chart
22
chart.draw();
23
});