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.