Problem when using Google Charts

I am trying to complete the voting app. As a part of this I am using the Google Charts API to render the chart on the poll page. However when I run the JavaScript to render the chart, I get the following error in console.

Uncaught TypeError: Cannot read property 'DataTable' of undefined

From what I can understand, my javascript file is getting loaded before the Google API script. Here is the code which I am using, the drawInfo callback takes the data returned by the API call to the server, parses it to appropriate format, and gives it to the Google API to render the graph, the error occurs around line 20.

    var poll = window.location.href.split([1].split('/')[2]
        url: '/polls/api/'+poll,
        type: 'GET',
        success: function(data) {

    function getChart(data) {
        google.charts.load('visualization', "1", {'packages':['corechart']});
    function drawChart(info) {
    var data = new google.visualization.DataTable();
        data.addColumn('string', 'Options');
        data.addColumn('number', 'Votes');
        chartData = []
        for (var i=0;i<info.options.length;i++) {
            chartData.push([info.options[i], info.votes[i]])

    var options = {'title':'How Much Pizza I Ate Last Night',

    var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
        chart.draw(data, options);