HTMLcopy
1
<button onclick="pdf()">Save as PDF</button>
2
<div id="container"></div>
CSScopy
15
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
button {
8
margin: 10px 0 0 10px;
9
}
10
#container {
11
position: absolute;
12
width: 100%;
13
top: 35px;
14
bottom: 0;
15
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// data
4
var data = [
5
["Chocolate paste", 5],
6
["White honey", 2],
7
["Strawberry jam", 2],
8
["Condensed milk", 1]
9
];
10
11
// set chart type
12
chart = anychart.pie(data);
13
14
// set chart title
15
chart.title("Save as PDF Button");
16
17
// display chart
18
chart.container("container").draw();
19
});
20
21
// save the chart as pdf
22
function pdf() {
23
chart.saveAsPdf();
24
};