Doing a Query and showing it using Gauge!

54 views
Skip to first unread message

far m

unread,
May 28, 2012, 1:23:44 PM5/28/12
to google-visua...@googlegroups.com
So, I can do a query and get the right columns out of a file and create a data = response.getDataTable()
But I want to extract the last value of each column and display each on a separate gauge. Here is the basic idea: 
http://jsfiddle.net/essonoma/tQry2/#base 

google.load('visualization''1'{packages['gauge']});
google.setOnLoadCallback(drawVisualization);


function drawVisualization({

    var query new google.visualization.Query('https://docs.google.com/spreadsheet/ccc?key=0AqzQGhNv6cV-dDBzZmZ2NzVGSkVVTUEwMEZPOG5YTHc#gid=0');

    // Apply query language.
    query.setQuery('SELECT A,B,C')//<<< -- Should I use??? LAST()?

    // Send the query with a callback function.
    query.send(handleQueryResponse);
end of th efunction 

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

    var data response.getDataTable();

///////////////////////////
 ////// I am trying to displa the last value of each column 
//////////////////////////
        // Create and draw the visualization.
visualization new google.visualization.Gauge({
    containerId'visualization3',
    view{columns[0,1]// << I am stuck here!
});
            draw(data);
      }
    

Jinji

unread,
May 30, 2012, 8:25:59 AM5/30/12
to google-visua...@googlegroups.com
In this example you're creating a google.visualization.Gauge, but don't follow the Gauge API. It seems you're confusing with ChartWrapper, as the parameters match those of ChartWrapper.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/E8WBllfq-ysJ.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

asgallant

unread,
May 30, 2012, 10:08:06 AM5/30/12
to google-visua...@googlegroups.com
You need to make a small fix and then add a 'rows' parameter to the Gauge's 'view' option:

visualization new google.visualization.ChartWrapper({
    containerId'visualization3',
    chartType'gauge',
    dataTabledata,
    view{
        columns[0,1],
        rows[data.getNumberOfRows(1// set the view to use the last row only
    }
});
visualization.draw() 

far m

unread,
May 31, 2012, 7:57:06 PM5/31/12
to google-visua...@googlegroups.com
Thank you so much. I am going to try it! I got distracted by another problem. 
Reply all
Reply to author
Forward
0 new messages