I am having trouble displaying google charts from an external JS script, inline script on my HTML works.
I called the loader on the <head> of my HTML file. <head> <script type="text/javascript" src= "https://www.gstatic.com/charts/loader.js"></script> </head> And then I have an external JS file (app.js) being loaded as well on my HTML file. This is the content. $(function() { google.charts.load('current', {packages: ['corechart']}); google.setOnLoadCallback(drawLineChart); function drawLineChart(values, labels){ // Define the chart to be drawn. var data = new google.visualization.DataTable(); var speed = values.speed; var soc = values.soc; var dataArray = []; for (i=0;i<labels.length;i++){ var tempArray = [] tempArray.push(new Date(labels[i])) tempArray.push(speed[i]) tempArray.push(soc[i]) dataArray.push(tempArray) } console.log(dataArray); data.addColumn('datetime', 'Time of Day'); data.addColumn('number', 'Speed'); data.addColumn('number', 'SOC'); data.addRows(dataArray); var options = { legend: { position: 'top', maxLines: 3 } } // Instantiate and draw the chart. var chart = new google.visualization.LineChart(document.getElementById( "lineChart")); console.log("chart: ", chart); chart.draw(data, options); } }); It gives me this error. jQuery.Deferred exception: google.setOnLoadCallback is not a function TypeError: google.setOnLoadCallback is not a function Any idea how to load it properly? Thank you. -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsubscr...@googlegroups.com. To post to this group, send email to google-visualization-api@googlegroups.com. Visit this group at https://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/ebd21b81-4fa4-4ae4-8b4c-cc3d0bb7690d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.