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="csv" onclick="csv()">
4
<textarea style="width: 100%;" rows="5" cols="70" id="csv"></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
var chart;
2
anychart.onDocumentReady(function () {
3
var data = [
4
["John", 10000],
5
["Jake", 12000],
6
["Peter", 13000],
7
["James", 10000],
8
["Mary", 9000]
9
];
10
11
// create a chart
12
chart = anychart.column(data);
13
14
// set the chart title
15
chart.title("Header formatter function for csv.");
16
17
// set the titles of the axes
18
chart.xAxis().title("Manager");
19
chart.yAxis().title("Sales, $");
20
21
// set the container id
22
chart.container("container");
23
24
// initiate drawing the chart
25
chart.draw();
26
});
27
28
function csv() {
29
// Get chart data as CSV with parameters using function.
30
var value = chart.toCsv('default', {
31
headers: function (header) {
32
switch (header) {
33
case 'x':
34
return 'name';
35
case 'value':
36
return 'sales';
37
default:
38
return header;
39
}
40
}
41
});
42
var csv = document.getElementById('csv');
43
csv.value = value;
44
}