I load lots of charts on one page and would like to do that asynchronously 
so that the page does not lock waiting for each chart.

The chart call with async:false is as follows. When removing the 
async:false and the responseText on other routines, everything works fine 
but on the chart routines that call JSON.parse(jsonData) in the 
visualization object as in the example below (instead of just jsonData), 
the chart does not print.  The url in the ajax call seems to contain the 
right data, but there's no rendering of the chart. Any suggestion welcome.



google.load('visualization', '1.0', {'packages':['corechart']});     // 
Load the Visualization API and the piechart package.        
google.setOnLoadCallback(drawChart);     // Set a callback to run when the 
Google Visualization API is loaded.   

// Callback that creates and populates a data table, instantiates the 
chart, passes in the data and draws it.      
function drawChart() {      
  var jsonData = $.ajax({          
    url: 
"http://www.beladv.com/charts/chart_handler.php?chart=chart_NAVgrowth";,     
     
    dataType:"json",          
    async: false          
  }).responseText;  
  
  var data = new google.visualization.DataTable(JSON.parse(jsonData));  // 
Create our data table out of JSON data loaded from server.           
  
  var options = {          
  'lineWidth': 1, 
  'legend': {position: 'top'},  
  'backgroundColor':'#f8f8ea', // same color as background box
  'width':850, 
  'height':200, 
  'hAxis': {textStyle: {fontSize:10, color:'black', bold:'true'}, 
viewWindowMode: 'maximized', gridlines: {count:-1} },
  'vAxis': {textStyle: {fontSize:10, color:'black'}, logScale: 'true', 
gridlines: {count:-1} },
  'fontName':'Trebuchet MS'         
  };

  var chart = new 
google.visualization.LineChart(document.getElementById('chart_NAVgrowth')); 
 // Instantiate chart  
  chart.draw(data, options);    // draw chart, passing in some options.  
}    

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to