google visualization query can't run maximum and sum query

139 Views Asked by At

I'm trying to get the data from my fusion tables. when I use SELECT query the data show successfull. but when I'm using SUM and MAXIMUM query the firebug show error : "SyntaxError: syntax error Error 500 (There's a p"

when i test my query from fusion query the query works.

when i search based from firebug error, it's because i'm not specify the script tag to script type="text/javascript" .

but i think it's not actualy the error i get, because yesterday my code works. and today i don't know why my code doesn't works.

Can anybody help me? thanks for any help.

<!DOCTYPE html>
<html>
 <head>
  <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  <script type="text/javascript"> 
   // Fusion Table data ID
   var FT_TableID = '1j1AG2s_IgNBQmm0QP9yYGHFg2_rNSZoEH4ee80In';
   var FT_TableIDSP = '1O5aIPnHBCimWsYg0gOXIeRH6eL-6byD95Nd2pdXR';
   google.load('visualization', '1', {'packages':['corechart', 'table', 'geomap']});
   
   function getKP() {
    // set the query using the parameters
    var FT_Query_KP = "SELECT 'Kelompok Penanam', count() FROM "+FT_TableID+" GROUP by 'Kelompok Penanam' ORDER by 'idPenanam'";
    //var FT_Query_KP = "SELECT SUM('Tinggi Pohon') FROM 1O5aIPnHBCimWsYg0gOXIeRH6eL-6byD95Nd2pdXR";
    //var FT_Query_KP = "SELECT MAXIMUM('Tinggi Pohon') FROM 1O5aIPnHBCimWsYg0gOXIeRH6eL-6byD95Nd2pdXR";
    var queryText = encodeURIComponent(FT_Query_KP);
    var query = new google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq='  + queryText);
    //set the callback function
    query.send(KP);
   }
   // Set a callback to run when the Google Visualization API is loaded.
   function KP(response) {
    if (!response) {
     alert('no response');
     return;
    }
    if (response.isError()) {
     alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
     return;
    } 
    var KPname = response.getDataTable().getValue(0,0);
   
    document.getElementById('dropdownKP').innerHTML = KPname;
   }
  </script>
  <script type="text/javascript">
   getKP();
  </script>
 </head>
 <body>
  <div id="dropdownKP"></div> 
 </body>
</html>

2

There are 2 best solutions below

0
On BEST ANSWER

Thanks Rod and Juvian, I change code from google visualization query to google fusion v1 query from this link

4
On

We've identified a problem in the code for summaries with no second column in the projection; pie charts are the only ones that allow that, so it slipped past us. We are working on a fix and will update this question when it's available.

That said, the pie charts resulting from such queries wouldn't be too useful because they only have a single value.