Ok... Asgallant - I want to be able to import the correct packages for the type of chart specified by the user, whether that be corechart or table, whatever. I don't see how using setOnLoadCallback(drawChart); rather than setOnLoadCallback(loadPackages); will make any difference to whether google.visualization is defined or not, the only thing that is changing is the name of the function. On a side note, why would you use an intermediary function rather than specifying parameters inside the draw function?
NA - Ok, so if I use google.setOnLoadCallback(loadPackages); when can I call the function loadPackages with the parameters to return the boolean value? Also, that other thread is by someone else. Just to check that I have got it correct though, the HTML page that I am using to test functionality of this library has two script tags. The first is the JS API from google and the second is the library that I am writing. Will the library be able to call functions from JS API like this? I appreciate the help guys! Cheers, Dan On Jul 20, 9:04 pm, NA <nabeel.a...@gmail.com> wrote: > You had: > > if (google.setOnLoadCallback(loadPackages(myChart.type)) > > You need to pass setOnLoadCallback a function object. In your case, > you're actually calling the function, not passing a function object. > So what happens is that: > > 1) loadPackages(myChart.type) is executed > 2) the output of that function call is passed to setOnLoadCallback > > That's not what you want to do. You want to pass the function > instead. So you should do: > > google.setOnLoadCallback(loadPackages); > > Here, we aren't actually calling the loadPackages function. We are > just referring to it by its name. > > Also, is all this because you had difficulty loading multiple packages > at once? This was just a typo you were making. I responded to your > thread about that here: > > http://groups.google.com/group/google-visualization-api/browse_thread... > > Personally, I just load all the packages I need and don't worry too > much about not using something. Much easier that way. > > On Jul 20, 2:48 pm, Dan Prince <danielpri...@hotmail.co.uk> wrote: > > > > > > > > > Ok, cheers for the reply. The function it is calling is this: > > > function loadPackages(type) > > { > > switch(type) > > { > > case 'line': > > google.load('visualization', '1', {packages: > > ['corechart']}); > > chart = new > > google.visualization.LineChart(document.getElementById(myChart.type)); > > writeDebug('You have loaded the specific Google packages.'); > > return true; > > > default: > > writeError('We could not find a package for the chart type > > <b><i> > > '+type+' </b></i>. Check that you referenced it correctly.');break; > > return false; > > } > > > } > > > and it being called in the line > > > if (google.setOnLoadCallback(loadPackages(myChart.type))) > > > I am still getting the google.visualization is undefined error. Am I > > using the setOnLoadCallback correctly? > > > Cheers -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. 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.