TypeError: google.visualization.DataTable is not a constructor
I got the same message, but just because I forgot to load the package
// was -> google.charts.load('current', {'packages':['bar', 'corechart']});
google.charts.load('current', {'packages':['bar', 'corechart', 'table']});
I don't think you can add more than one callback like that.
Also, you can define the callback in the load
method, like so...
google.load('visualization', '1.0', {'packages':['corechart'], 'callback': drawCharts});
function drawCharts() {
drawAltitudeChart();
drawDisplacementChart();
drawDistanceChart();
}
EDIT
the above load
statement is for the older library...
<script src="http://www.google.com/jsapi"></script>
according to the release notes...
The version of Google Charts that remains available via the
jsapi
loader is no longer being updated consistently. Please use the new gstatic loader from now on.
using the new library...
<script src="https://www.gstatic.com/charts/loader.js"></script>
changes the load
statement to...
google.charts.load('current', {'packages': ['corechart'], 'callback': drawCharts});
EDIT 2
you can also load all the packages you need in one load
statement, e.g.
instead of...
google.charts.load('current', { 'packages': ['table'] });
google.charts.load('current', { 'packages': ['bar'] });
google.charts.load('current', { 'packages': ['pie'] }); // <-- 'pie' package does not exist
google.charts.load('current', { 'packages': ['corechart'] });
google.charts.setOnLoadCallback(drawCharts);
it should be...
google.charts.load('current', {
callback: drawCharts,
packages: ['bar', 'corechart', 'table']
});