Hi Mr.Viz,
I got the answer for this question from one of your reply in other
post.
I have got a different quesiton and I guess I can explain it clearly.
Please help me out.
In the below code, I am trying to use "query.setQuery" for 4 times
for showing different cells but its just showing the output only for
the last one i.e query.setQuery('select N,F'); and not for the ones
above this. I would like to know how we can do this or if we can do
this. I tried doing this by copying the query with query.setQuery('')
and the draw(response) function for four times and that works fine but
I feel its kind of redundancy. IS there any thing that I am missing
here. Waiting for your reply!. If you would like to run this program,
please copy paste it and it should work.
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></
script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ["table"]});
google.setOnLoadCallback(initialize);
function initialize() {
var query = new google.visualization.Query(
'http://spreadsheets.google.com/pub?
range=b2:q2&headers=-2&key=pCECuvKSpwpNJZB_pXSUdcg&gid=0&single=true&output=html');
query.setQuery('select B,C,D,E,Q');
query.setQuery('select B,F,Q');
query.setQuery('select F,Q');
query.setQuery('select N,F');
query.send(draw);
}
function draw(response) {
if (response.isError()) {
alert("Error in query")
}
var Data1 = response.getDataTable();
var table1 = new google.visualization.Table
(document.getElementById('table1_div'));
table1.draw(Data1, {});
}
</script>
</head>
<body>
<div id="table1_div" ></div><br />
</body>
</html>
On Dec 3, 2:54 pm, Pragan <[EMAIL PROTECTED]> wrote:
> hi,
>
> Please check the below example. In this example, I can get the data
> from the spreadsheet for the range I have specified(a12:B12).
>
> seMy question is: As I have the complete data set for this row 12, I
> want to display the value from C12 in one place, E12 in other place
> and so on in my website.
>
> I will be able to do this if I keep adding more queries for each cell
> like this:
> var query = new google.visualization.Query('http://
> spreadsheets.google.com/pub?
> range=c12&headers=-1&key=pCECuvKSpwpOhprF4JsyUQA&gid=0');
> or
> var query = new google.visualization.Query('http://
> spreadsheets.google.com/pub?
> range=E12&headers=-1&key=pCECuvKSpwpOhprF4JsyUQA&gid=0');
>
> so I want to know if I can achieve the above case as I have the entire
> row through my one query(using range).
> I am ready to use any other scripting language(like php) to make this
> happen..but I want to know if its going to be more straight forward
> and easy way than I think.
>
> thanksPragan
>
> Example:
> <html>
> <head>
>
> <style type=text/css>
> .google-visualization-table-td-right {color:#ff0000;font-
> weight:bold;}
> </style>
> <script type="text/javascript" src="http://www.google.com/jsapi"></
> script>
> <script type="text/javascript">
> google.load('visualization', '1', {packages: ['table']});
> google.setOnLoadCallback(drawTable);
> google.load("visualization", "1", {packages:["annotatedtimeline"]});
> google.setOnLoadCallback(drawChart);
>
> function drawChart() {
> var query = new google.visualization.Query('http://
> spreadsheets.google.com/pub?
> range=a12:Q12&headers=-1&key=pCECuvKSpwpOhprF4JsyUQA&gid=0');
> query.send(error);
> }
> function error(response) {
> if (response.isError()) {
> alert('Error in query: ' + response.getMessage() + ' ' +
> response.getDetailedMessage());
> return;
> }
> var data = response.getDataTable();
> var table_excel = new google.visualization.Table
> (document.getElementById('table_div'));
> table_excel.draw(data, {showRowNumber: false});
>
> }
> function drawTable() {
> var data = new google.visualization.DataTable();
> }
>
> </script>
> </head>
> <body>
> <div id="table_div"></div>
> </body>
> </html>
>
> On Dec 2, 4:56 pm,Pragan<[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > thanks again. I guess you got me right. I will post an example in
> > sometime and then ask my question with better explanation.
>
> > thankspragan.
>
> > On Dec 2, 4:38 pm, VizGuy <[EMAIL PROTECTED]> wrote:
>
> > > So if I get you right, you will send a query to a range.Then you KNOW that
> > > your data table has 2 columns, and x rows.
> > > It should be quite simple to map a cell in the spreadsheet to a cell in
> > > the
> > > data table.
>
> > > Am I missing anything?
>
> > > VizGuy
>
> > > On Tue, Dec 2, 2008 at 9:47 PM,Pragan<[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > > 2. You can query for the whole range, and then use only the cells you
> > > > > want. This might end up as a lower latency approach, as the size is
> > > > > still
> > > > > small, and you save a round trip.
>
> > > > Thanks for the clarification. I can go with the second approach, but
> > > > how we can just show the required cell after getting the data? For
> > > > example, if my query for a range(c2:Q2) is giving the whole row with
> > > > data then how can I just display D2 in one place and R2 in other
> > > > place?
>
> > > > Thanks again.
> > > >Pragan.
>
> > > > On Dec 2, 12:56 pm, VizGuy <[EMAIL PROTECTED]> wrote:
> > > > > If you are not using a gadget, but writing your own js, you can do
> > > > > one of
> > > > > two things:1. To send two queries to the same spreadsheet, each to a
> > > > single
> > > > > cell (or any other range).
> > > > > 2. You can query for the whole range, and then use only the cells you
> > > > > want. This might end up as a lower latency approach, as the size is
> > > > > still
> > > > > small, and you save a round trip.
> > > > > There is no way to specify more than one range in the request.
>
> > > > > VizGuy
>
> > > > > On Tue, Dec 2, 2008 at 7:10 PM,Pragan<[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi,
>
> > > > > > I am using visualization api by having spreadsheet as data source. I
> > > > > > am able to get the output for the range I define. For example, if I
> > > > > > just want to show the data from A1-Q1 or A1-Q20, then I specify the
> > > > > > range and it
> > > > > > works fine. Same way I am able to define the individual cell like A5
> > > > > > or B8.
>
> > > > > > My question is : In a page, if I want to show data from A5 in one
> > > > > > place and in other place if I want to show B10 then how
> > > > > > can I do it without repeating the query again? Is there any way to
> > > > > > store all the data(complete data from that sheet) in our local db
> > > > > > like
> > > > > > mysql
> > > > > > and then show the specific value based on the query? Or Can we store
> > > > > > the complete data in an array format and then show the required
> > > > > > values
> > > > > > by calling the element?
> > > > > > If the above methods are possible, how to do it??
>
> > > > > > Please let me know, if there is any other simple or easy solution.
>
> > > > > > thanks
> > > > > >pragan.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en
-~----------~----~----~----~------~----~------~--~---