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
// create data
4
var data = [
5
["Winter", 20000, 40000, 20000],
6
["Spring", 20000, 40000, 40000],
7
["Summer", 40000, 30000, 30000],
8
["Autumn", 20000, 20000, 40000]
9
];
10
11
// create a chart
12
var chart = anychart.area();
13
14
// set data
15
chart.data(data);
16
17
// enable the percent stacking mode
18
chart.yScale().stackMode("percent");
19
20
// configure tooltips
21
chart.tooltip().format("{%yPercentOfCategory}{decimalsCount:2}%");
22
23
// configure labels on the y-axis
24
chart.yAxis().labels().format("{%value}%");
25
26
// set the chart title
27
chart.title("Percent Stacked Area Chart");
28
29
// set the container id
30
chart.container("container");
31
32
// initiate drawing the chart
33
chart.draw();
34
});