HTMLcopy
1
<div id="container"></div>
2
<div style="position: absolute; top: 40px; right: 25px; width: 31%;">
3
<input style="margin-bottom: 10px;" type="button" value="getPngBase64String" onclick="getPngBase64String()">
4
<textarea style="width: 100%;" rows="5" cols="70" id="getPngBase64String"></textarea>
5
</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
chart = anychart.line([
3
{x: 'January', value: 2},
4
{x: 'February', value: 5},
5
{x: 'March', value: 3},
6
{x: 'April', value: 9},
7
{x: 'May', value: 4}
8
]);
9
chart.margin([0, '45%', 0, 0]);
10
chart.title('Returns PNG as base64 string');
11
chart.container('container');
12
chart.draw();
13
});
14
15
function getPngBase64String() {
16
17
// Get PNG as base64 string.
18
chart.getPngBase64String(function (response) {
19
var base64String = document.getElementById('getPngBase64String');
20
base64String.innerHTML = response;
21
});
22
}