Your data table only has two rows in it.  If your data returned by the AJAX 
call has more than two rows, the script would bomb on the third row.  You 
might consider either adding a row immediately before setting the values or 
passing the values in an array to the addRow method, ie:

data.addRow([new Date(year, month, day), numQueries]);

I believe you will also need to parse the numQueries value as a number, as 
the jQuery#text method returns a string, which the DataTable won't accept 
as valid input in a number column; you could use something like this to 
make it work:

var numQueries = parseInt($(this).find('numOfQueries').text());  

On Wednesday, February 29, 2012 2:42:24 PM UTC-5, Craig Bridges wrote:
>
> Hi, 
>
> I am trying to dynamically load data in to a graph but when i add the 
> lines 
>
> data.setValue(x, 0, new Date(year, month, day)); 
>                                                   data.setValue(x, 1, 
> numQueries); 
>
> In the ajax call it hangs and will not work.  When I take those lines 
> out my data is returned as expected and the graph displays but says 
> there is no data.  here is what i am working with: 
>
> function drawVisualization() { 
>
>
>                       var data = new google.visualization.DataTable(); 
>                       data.addColumn('date', 'Date'); 
>                       data.addColumn('number', 'Number of Users'); 
>                       var numOfRows = 2; 
>                       data.addRows(numOfRows); 
>
>
>
>
>                       $.ajax({ 
>                                   url: "/WebServiceURL", 
>                                   type: "GET", 
>                                   dataType: "xml", 
>                                   data: "inputReportName=S,N", 
>                                   success: function(xml) { 
>
>
>                                         var x = 0; 
>                  
>                          $(xml).find("UsageMetricsDTO").each(function() 
>                                           { 
>                                                   var date = 
> $(this).find('logDate').text(); 
>
>                                                   var dateArray = 
> date.split('-'); 
>                                                   var year = dateArray[0]; 
>                                                   var month = 
> dateArray[1]; 
>                                                   var day = dateArray[2]; 
>                                                   var numQueries = 
> $(this).find('numOfQueries').text(); 
>                                                   if(x == 1){ 
>                                                   day = 02; 
>                                                   } 
>                                                   data.setValue(x, 0, new 
> Date(year, month, day)); 
>                                                   data.setValue(x, 1, 
> numQueries); 
>                                                   alert("year: "+year+" 
> <br/>month: "+month+"<br/> day: "+day 
> +"<br/>numqueries: "+numQueries+"<br/>x: "+x); 
>                                                   x++; 
>
>                                           }); 
>
>
>
>                                   }, 
>                                   error: function() { 
>                  
>                          $("#tabs-1").writeErrorMessage(); 
>                                   } 
>
>                           }); 
>                       var annotatedtimeline = new 
> google.visualization.AnnotatedTimeLine( 
>                           document.getElementById('visualization')); 
>                       annotatedtimeline.draw(data, {'displayAnnotations': 
> true}); 
>                     } 
>
> Any ideas why this is happening?

-- 
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/-/19U0i6ufU40J.
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.

Reply via email to