I have just figure out the problem.

Google Chart and more specific the drawToolbar expects that the datasource 
must interpret the parameter qtx. When choosing to export to CSV the 
drawToolbar will change the base datasource url from: 
http://localhost/general/lines/data/?code=scl 
<http://localhost/general/lines/data/?code=scl%27> to
http://localhost/general/lines/data/?code=scl 
<http://localhost/general/lines/data/?code=scl%27>&qtx=out:csv

My data source must delivery all the data in the CSV format.

This is disappointing, once my first impression was that I just need to 
delivery the data in a specific MAIN format that the drawToolbar will 
handle al the transformations to CSV or HTML. It is not what happens and I 
don't see any advantages to use the drawToolbar feature once the unique 
think this feature does is do draw a simple listbox and put some parameters 
in the datasource original URL.

I think the documentation must be more explicit on that, because it makes 
us lost some time to figure out all the drawToolbar limitations and what it 
really does.

Regards,
Fabio



On Wednesday, October 15, 2014 11:04:18 AM UTC-3, Fabio Batalha wrote:
>
> Hello,
>
> I'm having problems to export a given DataTable to CSV or HTML using the 
> drawToolbar. As you can see in the code below, I'm using a URL for the 
> datasource, including, the datasource URL is been used also to draw a 
> LineChart.
>
> The LineChart is been rendered well, instead of it, the CSV or HTML export 
> using the drawToolbar is not working. When clicking the CSV or HTML options 
> in the drawToolbar. I'm been redirected to the URL informed in the 
> datasource, neither the CSV is a downloaded neither a table in HTML format 
> is shown.
>
> I don't know why this is happening once the given URL is correct and the 
> returned data is also correct.
>
> This is the return of the url:
>
>
> google.visualization.Query.setResponse({"status":"ok","table":{"rows":[{"c":[{"v":"Jan"},null,{"v":22559631},{"v":24988050}]},{"c":[{"v":"Feb"},null,{"v":29148952},{"v":35208770}]},{"c":[{"v":"Mar"},null,{"v":41851612},{"v":48550349}]},{"c":[{"v":"Apr"},null,{"v":31600469},{"v":42562065}]},{"c":[{"v":"May"},null,{"v":37927751},{"v":54594585}]},{"c":[{"v":"Jun"},null,{"v":32671124},{"v":41565746}]},{"c":[{"v":"Jul"},null,{"v":24036201},{"v":46408293}]},{"c":[{"v":"Aug"},{"v":857963},{"v":32732199},{"v":46392829}]},{"c":[{"v":"Sep"},{"v":25105259},{"v":35221952},{"v":51264782}]},{"c":[{"v":"Oct"},null,{"v":47943186},null]},{"c":[{"v":"Nov"},null,{"v":50861875},null]},{"c":[{"v":"Dec"},{"v":376794},{"v":27099103},null]}],"cols":[{"type":"string","id":"months","label":"months"},{"type":"number","id":"2012","label":"2012"},{"type":"number","id":"2013","label":"2013"},{"type":"number","id":"2014","label":"2014"}]},"reqId":"0","version":"0.6"});
>
>
> This is my JS, that is almost the same comparing with the sample (
> https://developers.google.com/chart/interactive/docs/gallery/toolbar).
>
> <script type="text/javascript" src="https://www.google.com/jsapi
> "></script>
> <script type="text/javascript">
>     google.load("visualization", "1", {packages:["corechart"]});
>     google.setOnLoadCallback(drawVisualization);
>     var options = {"pointSize": 5, "hAxis": {"title": "Months"}, "title": 
> "fulltext and abstract accesses", "curveType": "function", "height": 500, 
> "width": "100%", "vAxis": {"title": "Accesses"}, "legend": {"position": 
> "rigth"}}
>         function drawVisualization() {
>           drawToolbar();
>           query = new google.visualization.Query('
> http://localhost/general/lines/data/?code=scl');
>           query.send(queryCallback);
>         }
>         function queryCallback(response) {
>           visualization = new 
> google.visualization.LineChart(document.getElementById('chart'));
>           visualization.draw(response.getDataTable(), options);
>         }
>
>         function drawToolbar() {
>           var components = [
>               {type: 'html', datasource: '
> http://localhost/general/lines/data/?code=scl'},
>               {type: 'csv', datasource: '
> http://localhost/general/lines/data/?code=scl'}
>           ];
>           
> google.visualization.drawToolbar(document.getElementById('toolbar'), 
> components);
>         };
>
> </script>
> <div id="chart"></div>
> <div id="toolbar"></div>
>
> Thanks in advance,
> Regards,
> Fabio
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to