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:

<https://dl.dropboxusercontent.com/s/q6ky19ulfnggf41/idea64_2018-07-11_14-57-32.png>

Line 60 being: 

var csvFormattedDataTable = google.visualization.dataTableToCsv(this.chartData);


In my index.html I have both loaders:

<script type="text/javascript" src="https://www.google.com/jsapi";></script>
<script type="text/javascript" 
src="https://www.gstatic.com/charts/loader.js";></script>


-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/8904d60a-39c2-43dc-97e2-3f2975f432bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to