I\'ve got several functions that instantiate various charts using Google Charts API.
When I call them without jQuery\'s $(document).ready
method, everything
Here is the paradigm I am using. Set a callback for the google.load method, and don't use the google.setOnLoadCallback at all (AFAIK this is not needed).
MyChart.prototype.render = function() {
var self = this;
google.load("visualization",
"1",
{ callback: function() { self.visualize(); },
packages: ["corechart"] }
);
}
MyChart.prototype.visualize = function() {
var data = google.visualization.arrayToDataTable(
[
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var options = {
title: 'Company Performance',
hAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
};
var chart = new google.visualization.ColumnChart(document.getElementById("mychart_div"));
chart.draw(data, options);
}