HTMLcopy
1
<button onclick="saveAsJson();">Save JSON config</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
x
1
var chart;
2
anychart.onDocumentReady(function () {
3
chart = anychart.line([
4
{x: 'January', value: 49},
5
{x: 'February', value: 45},
6
{x: 'March', value: 9},
7
{x: 'April', value: 4},
8
{x: 'May', value: 17}
9
]);
10
chart.width('100%').height('95%');
11
chart.title('Save chart as JSON file');
12
chart.container('container');
13
chart.draw();
14
});
15
16
function saveAsJson() {
17
18
// Save into JSON file.
19
chart.saveAsJson('ChartJSON');
20
21
}