Error in the google-Charts console?

Asked

Viewed 52 times

0

The graphics are drawn correctly in html, but this error is 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 can be?

  • I don’t see the word Container in that code. What is the line 108?

  • This is the problem, can’t see why it doesn’t have kkkkk

1 answer

0


I discovered the problem, I was calling these functions even if 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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.