Using Where in a Query

12 views
Skip to first unread message

samuel.ma...@bbva.com

unread,
Sep 15, 2015, 2:20:23 PM9/15/15
to Google Visualization API
I'm trying to set up a query using a "where" and I don't know what I'm doing wrong.

Here is my data   

If I just do "SELECT B, C" the whole code works but when introducing the where is when the problem came up. so the issue is in 'SELECT B, C where B='Alabama''

Thank you very much

<html>
 
<head>
   
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
   
<script type="text/javascript">
    google
.load("visualization", "1", {packages:["corechart"]});
    google
.setOnLoadCallback(drawSheetName);


function drawSheetName() {


   
var queryString = encodeURIComponent('SELECT B, C where B='Alabama'');
   
var magicIncantation = '/gviz/tq?sheet=Selector&headers=1&tq=';


   
var query = new google.visualization.Query(
       
'https://docs.google.com/spreadsheets/d/1xfb9trifQA5KDPc9Nh5hBL4MJ290Mxcc1Uod2VTPzYI' +
        magicIncantation
+ queryString);
    query
.send(handleSampleDataQueryResponse);
}


function handleSampleDataQueryResponse(response) {
   
if (response.isError()) {
        alert
('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
       
return;
   
}

       
var optionsColumnChart = {
          height
: 400,
          title
: 'This is the title On Column Chart',
       
};

   
var data = response.getDataTable();

   
var chart = new google.visualization.ColumnChart(document.getElementById('Columnchart_div'));
    chart
.draw(data, optionsColumnChart);
}


</script>


 
</head>
 
<body>
       
<div id="Columnchart_div" style="width: 100%;"></div>
 
</body>
</html>

Reply all
Reply to author
Forward
0 new messages