Hello Guys,

Problem solved, the endpoint of my API, responsible to retrieve the data 
for the given url 'http://localhost/general/lines/data/?code=scl' 
<http://localhost/general/lines/data/?code=scl&req_id=12%27>, was not 
handling the parameter qtx=regId:0.

Now it is working fine!

Regards,

On Tuesday, October 14, 2014 3:02:44 PM UTC-3, Fabio Batalha wrote:
>
> Hello Guys,
>
> I'm having a problem to display charts and toolbars while using an URL to 
> delivery data for a DataTable.
>
> I'm using the same sample from the Google Chart website, the unique 
> difference is the data source, that is a url from my application.
>
> <html>
> <head>
>   <script type="text/javascript" src="https://www.google.com/jsapi
> "></script>
>   <script type="text/javascript">
>     google.load('visualization', '1', {packages: ['corechart']});
>     var visualization;
>
>     function draw() {
>       drawVisualization();
>       drawToolbar();
>     }
>
>     function drawVisualization() {
>       var container = document.getElementById('visualization_div');
>       visualization = new google.visualization.LineChart(container);
>       new google.visualization.Query('
> http://localhost/general/lines/data/?code=scl&req_id=12').
>           send(queryCallback);
>     }
>
>     function queryCallback(response) {
>       visualization.draw(response.getDataTable());
>     }
>
>     function drawToolbar() {
>       var components = [
>           {type: 'html', datasource: '
> http://localhost/general/lines/data/?code=scl&req_id=12'},
>           {type: 'csv', datasource: '
> http://localhost/general/lines/data/?code=scl&req_id=12'}
>       ];
>
>       var container = document.getElementById('toolbar_div');
>       google.visualization.drawToolbar(container, components);
>     };
>
>     google.setOnLoadCallback(draw);
>   </script>
> </head>
> <body>
>   <div id="visualization_div" style="width: 270px; height: 200px;"></div>
>   <div id="toolbar_div"></div>
> </body>
> </html>
>
> I have noticed that the browser is fetching the url '
> http://localhost/general/lines/data/?code=scl&req_id=12' and retrieving 
> 200, but the Google Chart always retrieve the error "DATA TABLE IS NOT 
> DEFINE". 
>
> This is the response for the above 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":3272821},{"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":"12","version":"0.6"});
>
> It is a valid response including the reqId that is mandatory for multiple 
> requests. I know that it is not the situation in the example above, because 
> I'm doing a simple request and expecting just one response.
>
> I'm doing these tests in my local machine, so the browser will not have 
> problemas to reach the url 
> http://localhost/general/lines/data/?code=scl&req_id=12.
>
> The same response is working fine if I change the code to build the chart 
> without using the google.visualization.Query, as you can see in the code 
> below.
>
> <script type="text/javascript" src="https://www.google.com/jsapi
> "></script>
> <script type="text/javascript">
>     google.load("visualization", "1", {packages:["corechart"]});
>     google.setOnLoadCallback(drawVisualization);
>
>     function 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"}}
>         var visualization = new 
> google.visualization.LineChart(document.getElementById('chart'));
>         var data = new 
> google.visualization.DataTable({"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":3272821},{"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"}]});
>         visualization.draw(data, options);
>
>     }
> </script>
> <div id="chart"></div>
>
>
> Sorry if it is a huge e-mail but I'm almost 1 entire day trying to figure 
> out what I'm doing wrong. 
>
> Thanks in advance for guidance.
>
> 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