I'm building a python web app to work with google's earth engine API,
I display data through javascript using chart API and want to allow users to download the data as CSV. I am confused however when reading online there are multiple ways to load the chart / visualization api's and I can't seem to find out what I am doing wrong to be able to have access to the dataTableToCsv() function.
I found this code somewhere online and checked the docs to see that this is actually a valid function:
$('#download-csv').click(function () {
var csvFormattedDataTable = google.visualization.dataTableToCsv(this.chartData);
var encodedUri = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csvFormattedDataTable);
this.href = encodedUri;
this.download = 'table-data.csv';
this.target = '_blank';
});
I'm loading the charts api as follows:
google.load('maps', '3', {'other_params': 'key=' + key + '&libraries=drawing'});
google.setOnLoadCallback(function () {
google.charts.load('current', {packages: ['corechart']});
google.charts.setOnLoadCallback(function () {
precipitation.instance = new precipitation.App();
precipitation.instance.initVals();
});
});Now if someone could give some additional advice on how to correctly load the api nowadays that'd be great :)
When I click the button I get the following error:

Line 60 being:
var csvFormattedDataTable = google.visualization.dataTableToCsv(this.chartData);
In my index.html I have both loaders: