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