You are not required to draw the chart on page load, you just have to make sure that it doesn't start until after the API has finished loading. You can do this with AJAX requests as long as you are loading something other than the API with the AJAX. Here's a rough workup you could use (uses jQuery's AJAX function to fetch a json representation of a DataTable from a php script and draw a chart):
google.load('visualization', '1', {packages: ['corechart']}); google.setOnLoadCallback(init); function init () { $.ajax({ url: 'path/to/data.php', type: 'json', success: function (json) { // do something with json // the draw the chart here, maybe: var data = new google.visualization.DataTable(json); var chart = new google.visualization.LineChart(document. getElementById('myChart')); chart.draw(data, { title: 'My Chart' }); } }); } On Thursday, July 12, 2012 11:12:35 AM UTC-4, Jose Miguel Ramírez Escobedo wrote: > > ok thank you, because i didn't know how to do it, well so is there a way > to draw the chart when i click a link, this because i need to load the data > that come from an a function with ajax request, so first need to wait until > the ajax request finishes after that catch the values, but all this in > click event and i said this because i saw that this is made with this code > google.setOnLoadCallback draw the chart on load right? > > El miércoles, 11 de julio de 2012 17:26:00 UTC-5, Jose Miguel Ramírez > Escobedo escribió: >> >> Hello, I have one cuestion, ok in the exaples that I have seen in a html >> file you load the api libraries of google chart, but I want to know if it’s >> possible use them in a javascript file and if is possible how can i load >> the libraries >> > -- 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/-/T2sueocHQ7MJ. To post to this group, send email to google-visualization-api@googlegroups.com. To unsubscribe from this group, send email to google-visualization-api+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.