I have copied the Google Code example into a php script however I am getting the error "undefined is not a function"
it is happening specifically on this line:
var table = new google.visualization.Table(document.getElementById('table_sort_div'));
It appeats that the Table function does not exist???
I have copied the code directly from Googles Code examples so I can't understand what I have done wrong... I'm tending to believe that there is an issue with the example but I'm gonna assume I'd make a mistake before google would?
Code was copied directly from: http://code.google.com/apis/chart/interactive/docs/examples.html#interaction_example
You need to wait for the scripts to load. For example:
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['table']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
function drawChart() {
var table = new google.visualization.Table(document.getElementById('table_sort_div'));
}
should work, because the scripts have been loaded. A better table reference here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With