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
var stage = anychart.graphics.create("container");
4
5
var chart = anychart.line([1.1, 1.4, 1.2, 1.6]);
6
chart.left("5%");
7
chart.title("Save chart as SVG file with width and height set.");
8
chart.container(stage);
9
chart.draw();
10
11
var customLabel = anychart.standalones.label();
12
customLabel.background({fill: "#9E9E9E"});
13
customLabel.text("Save image");
14
customLabel.fontColor("#fff");
15
customLabel.padding(5);
16
customLabel.offsetX(5);
17
customLabel.listen("click", function () {
18
19
// Saves into SVG file.
20
chart.saveAsSvg(400, 300);
21
22
});
23
customLabel.container(stage);
24
customLabel.draw();
25
});