I'm working on GoogleCharts project, I wanted add function export data to CSV. I tried to make, but didin´t worked. In fiddle URL is my chart where I want add export to CSV data. Please could someone help me how to do it?? thanks, Here is code for CSV function.
Fiddle Chart: http://jsfiddle.net/ZmVcZ/292/
function drawToolbar() {
var components = [
{type: 'csv', datasource: 'https://spreadsheets.google.com/tq?key=pCQbetd-CptHnwJEfo8tALA'}
];
var container = document.getElementById('toolbar_div');
google.visualization.drawToolbar(container, components);
};
google.charts.setOnLoadCallback(draw);
as stated in the documentation for toolbar usage...
since you're creating a
DataTable
from scratch, the toolbar will not work for you...however, there is a static method for
dataTableToCsv
this method does not include the column headings,
have to add those manually...
to use this method, you could add a button to build the download content,
see following working snippet...
note: recommend using the
loader.js
library for google charts, according to the release notes...this will only change the
load
statement, see above snippet...