Error in the google-charts console?

0

The graphics are drawn correctly in the html, but this error remains in the console.

  

VM6537: 108 Uncaught Error: Container is not defined

/*Graficos*/
google.charts.load('current', {packages: ['corechart']});
google.charts.setOnLoadCallback(drawChartTicketsByClient);

function drawChartTicketsByClient() {
    var jsonData = $.ajax({
        url: "/client/ajax",
        dataType: "JSON",
        async: false
    }).responseJSON;

    var dataArray = [
        ['Name', 'Tickets'],
    ];

    for (var i = 0; i < jsonData.length; i++) {
        var row = [jsonData[i].Name, jsonData[i].Tickets];
        dataArray.push(row);
    }
    var options = {
        title: 'Tickets por cliente',
        curveType: 'function',
        series:{0 :{"color":'#57c8f2'}}
    };

    var data = google.visualization.arrayToDataTable(dataArray);

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

//**************************//
google.charts.setOnLoadCallback(drawChartTicketsByType);

function drawChartTicketsByType() {
    var jsonData = $.ajax({
        url: "/ticket/ajax",
        dataType: "JSON",
        async: false
    }).responseJSON;

    var dataArray = [
        ['Description', 'Tickets'],
    ];

    for (var i = 0; i < jsonData.length; i++) {
        var row = [jsonData[i].Description, jsonData[i].Tickets];
        dataArray.push(row);
    }
    var options = {
        title: 'Tickets por tipo',
        curveType: 'function',
        series:{0 :{"color":'#E9D460'}}
    };

    var data = google.visualization.arrayToDataTable(dataArray);

    var chart = new google.visualization.LineChart(document.getElementById('chart_div_ticket'));
    chart.draw(data, options);
}

//**************************//
google.charts.setOnLoadCallback(drawChartTicketsByTerm);

function drawChartTicketsByTerm() {
    var jsonData = $.ajax({
        url: "/ticket/term-on/ajax",
        dataType: "JSON",
        async: false
    }).responseJSON;


    var dataArray = [
        ['Name', 'Tickets'],
        ['No prazo', jsonData[0][0].Tickets],
        ['Fora do prazo', jsonData[1][0].Tickets],
    ];


    var options = {
        title: 'Tickets por prazo',
        curveType: 'function',
        series:{0 :{"color":'#57c8f2'},
                1: {"color": '#ff6c60'}}
    };

    var data = google.visualization.arrayToDataTable(dataArray);
    var chart = new google.visualization.PieChart(document.getElementById('chart_div_ticket_term'));
    chart.draw(data, options);
}

Does anyone know what to say?

    
asked by anonymous 01.08.2016 / 17:05

1 answer

0

I discovered the problem, I was calling these functions even if the id did not exist in the html view, the solution was to split into more than one file and import the files into their respective views.

    
01.08.2016 / 19:40