HTMLcopy
1
<button onclick="chart.saveAsJpg(360, 350, 0.9, true);">Save image</button>
2
<div id="container"></div>
CSScopy
9
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
button {
8
margin: 10px 0 0 10px;
9
}
JavaScriptcopy
14
1
var chart;
2
anychart.onDocumentReady(function () {
3
chart = anychart.line([
4
{x: 'Meat', value: 10},
5
{x: 'Fruit', value: 12},
6
{x: 'Nuts', value: 18},
7
{x: 'Milk', value: 11},
8
{x: 'Fish', value: 9}
9
]);
10
chart.width('100%').height('95%');
11
chart.title('Save chart as JPG file');
12
chart.container('container');
13
chart.draw();
14
});